:root {
    --primary: #004c4c; /* Teekse Professional Teal */
    --primary-light: rgba(0, 76, 76, 0.08);
    --primary-shadow: rgba(0, 76, 76, 0.15);
    --bg: #ffffff;
    --surface: #ffffff;
    --text: #0f172a;
    --text-muted: #94a3b8;
    --border: #f1f5f9;
}


body { 
    font-family: 'Outfit', sans-serif; 
    background-color: #f8fafc;
    color: var(--text);
    margin: 0;
    padding: 0;
    /* min-height: 100vh; */
    min-height: 100dvh;
    width: 100%;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}
* {
  box-sizing: border-box;
}

img {
    max-width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}


#app {
    background-color: var(--surface);
    height: 100vh; /* Fallback for older browsers */
    height: 100dvh; /* Use dynamic viewport height for mobile browsers */
    min-height: -webkit-fill-available; /*iOS Safari fix */
    width: 100%; 
    max-width: 100%;
    margin: 0 auto;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Prevent body scroll, let view-container or chat handle it */
}

/* iOS Safari only */
@supports (-webkit-touch-callout: none) {
  #app {
    min-height: -webkit-fill-available;
  }
}

@media (max-width: 639px) {
    html, body {
        overscroll-behavior-y: contain;
    }

    #view-container {
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-y;
    }
}

/* Safe Area Adjustments for Mobile Notches & Home Bars */
@supports (padding-top: env(safe-area-inset-top)) {
    header {
        padding-top: env(safe-area-inset-top, 0px) !important;
        height: auto !important;
        min-height: calc(72px + env(safe-area-inset-top, 0px)) !important;
    }

    /* Only apply fixed positioning on actual mobile screens.
       On desktop (>=768px) the app is a card inside the page — absolute is correct there. */
    @media (max-width: 767px) {
        #bottom-nav {
            position: fixed !important; /* must escape overflow:hidden on #app on iOS/Android */
            bottom: 0 !important;
            left: 0 !important;
            right: 0 !important;
            width: 100% !important;
            max-width: 100% !important;
            padding-bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px)) !important;
            z-index: 50;
        }
    }

    /* Provide extra scroll padding at bottom of views */
    #view-container {
        padding-bottom: env(safe-area-inset-bottom, 0px);
    }
}

/* Premium Desktop/Tablet Presentation */
@media (min-width: 768px) {
    body {
        background-color: #f1f5f9;
        padding: 2rem 1rem;
        align-items: center; /* Center horizontally/vertically */
    }
    #app {
        width: 440px; 
        max-width: 100%;
        min-height: 850px;
        max-height: 95vh;
        border-radius: 3.5rem;
        box-shadow: 0 40px 100px -20px rgba(0, 76, 76, 0.15);
        border: 1px solid rgba(0, 76, 76, 0.05);
        overflow: hidden;
    }
    #map-picker-overlay {
        position: absolute !important;
        padding: 0 !important;
    }
    #map-picker-overlay > div {
        width: 100% !important;
        height: 100% !important;
        max-width: 100% !important;
        max-height: 100% !important;
        border-radius: 0 !important;
        border: none !important;
    }
}

/* --- THE PREMIUM TEMPLATE --- */

.header-premium {
    background: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    transition: all 0.3s ease;
}

.input-premium {
    background-color: #ffffff;
    border: 2px solid #0f172a; /* Strong identity border */
    padding: 1.1rem 1.5rem;
    border-radius: 9999px; /* Official Pill Shape */
    width: 100%;
    font-size: 0.9rem;
    font-weight: 700;
    color: #0f172a;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    outline: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* ── Date & Time inputs: fully clickable on desktop + correct pill shape on Android ── */
input[type="date"].input-premium,
input[type="time"].input-premium {
    position: relative;       /* Required for absolute-positioned indicator trick */
    height: 2.8rem;
    line-height: 2.8rem;
    /* appearance: none keeps our custom pill shape on Android (prevents OS override of border-radius).
       The ::-webkit-calendar-picker-indicator pseudo-element still works even with appearance:none,
       and we stretch it to cover the full input — fixing desktop click-not-working. */
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    text-align: left;
    padding-top: 0;
    padding-bottom: 0;
    padding-left: 1rem;
    padding-right: 2.5rem;  /* Reserve space for the custom icon on the right */
    min-width: 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    border-radius: 9999px;
    font-size: 0.78rem;
    cursor: pointer;
    display: block;
    background-repeat: no-repeat;
    background-position: right 0.85rem center;
    background-size: 1.1rem;
    overflow: hidden;
}

/* Calendar icon for date inputs */
input[type="date"].input-premium {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z'/%3E%3C/svg%3E");
}

/* Clock icon for time inputs */
input[type="time"].input-premium {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2364748b' stroke-width='2.5'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M12 6v6h4.5m4.5 0a9 9 0 11-18 0 9 9 0 0118 0z'/%3E%3C/svg%3E");
}

/* Stretch the invisible picker indicator across the ENTIRE input so clicking anywhere
   on the input (not just the right-side icon) opens the native date/time picker.
   This works on both desktop Chrome/Edge AND Android Chrome. */
input[type="date"].input-premium::-webkit-calendar-picker-indicator,
input[type="time"].input-premium::-webkit-calendar-picker-indicator {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    padding: 0;
    opacity: 0;          /* Invisible but fully interactive — background-image icon remains visible */
    cursor: pointer;
    background: transparent;
    border: none;
    z-index: 1;
}

/* Style inner text/date edit fields */
input[type="date"].input-premium::-webkit-datetime-edit,
input[type="time"].input-premium::-webkit-datetime-edit {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    background: transparent;
    padding-left: 0;
    padding-right: 0;
    width: 100%;
    height: 100%;
    box-sizing: border-box;
}

input[type="date"].input-premium::-webkit-datetime-edit-fields-wrapper,
input[type="time"].input-premium::-webkit-datetime-edit-fields-wrapper {
    padding: 0;
    display: inline-flex;
    align-items: center;
    background: transparent;
}

/* Custom Arrow for Premium Selects */
select.input-premium {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%230f172a' stroke-width='3'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19 9l-7 7-7-7' /%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1.5rem center;
    background-size: 1.25rem;
    padding-right: 3.5rem;
}

.input-premium:focus {
    border-color: var(--primary);
    box-shadow: 0 10px 25px -5px var(--primary-shadow);
}

.btn-modern {
    background-color: var(--primary);
    color: white;
    width: 100%;
    height: 2.8rem; /* Professional compact height */
    border-radius: 9999px;
    font-weight: 900;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.25em;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.85rem;
    transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    border: none;
    cursor: pointer;
    box-shadow: 0 12px 24px -8px var(--primary-shadow);
}

.btn-modern:hover {
    filter: brightness(1.1);
    transform: translateY(-2px);
    box-shadow: 0 20px 40px -12px var(--primary-shadow);
}

.btn-modern:active { 
    transform: scale(0.96); 
}

.btn-modern:disabled {
    background-color: #f1f5f9;
    color: #94a3b8;
    box-shadow: none;
    cursor: not-allowed;
}

.card-premium {
    background: white;
    border: 1px solid #f1f5f9;
    border-radius: 2.25rem;
    padding: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.02);
    transition: all 0.3s ease;
}
.card-premium:hover {
    box-shadow: 0 20px 40px -12px rgba(15, 23, 42, 0.08);
    transform: translateY(-2px);
}

.section-label {
    font-size: 10px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.3em;
    color: var(--text-muted);
    padding-left: 0.25rem;
}

.btn-action-premium {
    width: 3rem; /* Compact Circular Action */
    height: 3rem;
    border-radius: 9999px; /* Perfect Circle */
    background-color: #ffffff; /* Clean Minimal White */
    border: 2px solid #f1f5f9;
    color: var(--primary); /* Plant Green Accent Splash */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: pointer;
    box-shadow: 0 4px 10px -2px rgba(15, 23, 42, 0.05);
    flex-shrink: 0; /* Never shrink button regardless of text */
}

.btn-action-premium:hover {
    background-color: var(--primary); /* Splash of green on interaction */
    border-color: var(--primary);
    color: #ffffff;
    transform: translateY(-3px) scale(1.08);
    box-shadow: 0 15px 30px -10px var(--primary-shadow);
}

.btn-action-premium:active {
    transform: scale(0.94);
}

/* Premium Global Alert System (System-style Modals) */
.modal-alert-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2.5rem;
    animation: modal-fade-in 0.3s ease-out forwards;
}

@keyframes modal-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-alert-card {
    background: #ffffff;
    width: 100%;
    max-width: 320px;
    border-radius: 2.5rem;
    padding: 2.5rem 2rem;
    text-align: center;
    box-shadow: 0 40px 100px -20px rgba(0, 0, 0, 0.25);
    transform: scale(0.9);
    opacity: 0;
    animation: modal-pop 0.4s cubic-bezier(0.16, 1, 0.3, 1) 0.1s forwards;
    border: 1px solid rgba(0, 76, 76, 0.05);
}

@keyframes modal-pop {
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-alert-icon {
    width: 4rem;
    height: 4rem;
    margin: 0 auto 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 9999px;
    background: #f1f5f9;
    color: #004c4c;
}

.modal-alert-icon.error {
    background: #fef2f2;
    color: #b91c1c;
}

.modal-alert-icon.success {
    background: #f0fdf4;
    color: #15803d;
}

.modal-alert-title {
    font-size: 1.15rem;
    font-weight: 900;
    color: #0f172a;
    letter-spacing: -0.02em;
    margin-bottom: 0.75rem;
    line-height: 1.2;
}

.modal-alert-message {
    font-size: 0.85rem;
    color: #64748b;
    line-height: 1.6;
    font-weight: 500;
    margin-bottom: 2rem;
}

.modal-alert-btn {
    width: 100%;
    padding: 1.25rem;
    background: #0f172a;
    color: #ffffff;
    border-radius: 1.5rem;
    font-size: 0.85rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    transition: all 0.3s ease;
    box-shadow: 0 10px 20px -5px rgba(15, 23, 42, 0.3);
}

.modal-alert-btn:active {
    transform: scale(0.96);
    opacity: 0.8;
}

.modal-alert-btn.success {
    background: #004c4c;
    box-shadow: 0 10px 20px -5px rgba(0, 76, 76, 0.3);
}

/* Side Menu Transition */
#side-menu {
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    transform: translateX(100%);
}
#side-menu.open {
    transform: translateX(0);
}
#menu-overlay {
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}
#menu-overlay.open {
    opacity: 1;
    pointer-events: auto;
}

/* utility classes */
.no-scrollbar::-webkit-scrollbar { display: none; }

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
.animate-fade-up { animation: fadeUp 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

/* Map & Modal Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
.animate-fade-in { animation: fadeIn 0.4s ease-out forwards; }

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}
.animate-fade-out { animation: fadeOut 0.4s ease-out forwards; }

@keyframes scaleUp {
    from { opacity: 0; transform: scale(0.9); }
    to { opacity: 1; transform: scale(1); }
}
.animate-scale-up { animation: scaleUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards; }

/* Premium Custom Tooltips */
.tooltip-container {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.premium-tooltip {
    position: absolute;
    bottom: calc(100% + 12px);
    right: -10px;
    width: 200px;
    background: #0f172a;
    color: #ffffff;
    padding: 1rem 1.25rem;
    border-radius: 1.5rem;
    font-size: 0.72rem;
    font-weight: 600;
    line-height: 1.5;
    box-shadow: 0 20px 40px -12px rgba(15, 23, 42, 0.4);
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transform: translateY(10px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    border: 1px solid rgba(255, 255, 255, 0.08);
    text-align: left;
    text-transform: none;
    letter-spacing: normal;
}

.tooltip-container:hover .premium-tooltip {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.premium-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 20px;
    border-width: 6px;
    border-style: solid;
    border-color: #0f172a transparent transparent transparent;
}

/* Filter Buttons */
.spec-filter-btn {
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.spec-filter-btn.active {
    background-color: var(--primary) !important;
    color: #ffffff !important;
    box-shadow: 0 10px 20px -5px var(--primary-shadow) !important;
    transform: translateY(-1px);
}

/* Toast Styles */
.toast-simple {
    position: fixed;
    bottom: 120px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    color: white;
    padding: 0.35rem 1rem;
    border-radius: 1rem;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    z-index: 20000;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
    animation: toast-fade-in 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.toast-simple.fade-out {
    animation: toast-fade-out 0.5s ease-out forwards;
}

@keyframes toast-fade-in {
    from { opacity: 0; transform: translate(-50%, 20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes toast-fade-out {
    from { opacity: 1; transform: translate(-50%, 0); }
    to { opacity: 0; transform: translate(-50%, -10px); }
}

/* Base positioning for #bottom-nav — overridden to fixed on real iOS/Android devices via the @supports block above */
#bottom-nav {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
}

.chat-input-container {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
}

/* Remove safe area bottom padding when keyboard is open (inputs/textarea focused) */
:root:has(input:focus, textarea:focus) .chat-input-container {
    padding-bottom: 1rem !important;
}
