/**
 * UTO Shared Nested Popup Styles
 * Extracted from inline styles for performance
 * Uses CSS custom properties for dynamic theming
 * 
 * @since 4.5.0
 */

/* ===== UTO Shared Nested Popup – 75% height bottom sheet on mobile, 50% on desktop ===== */
@import url('https://fonts.googleapis.com/css2?family=Saira:wght@400;500;600;700;800&display=swap');

.uto-nested-overlay {
    position: fixed;
    inset: 0;
    z-index: 1000002;
    background: rgba(0,0,0,.5);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .3s ease-out, visibility 0s .3s;
    font-family: "Saira", system-ui, -apple-system, sans-serif;
}
.uto-nested-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity .3s ease-out, visibility 0s 0s;
}
.uto-nested-overlay * {
    box-sizing: border-box;
}

/* Enhanced overlay with backdrop blur for modern browsers */
.uto-nested-overlay {
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

/* Desktop: 50% height centered panel with max-width matching booking form (~520px) */
.uto-nested-sheet {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    width: calc(100% - 32px);
    max-width: 520px;
    height: 50vh;
    max-height: 50vh;
    background: #fff;
    border-radius: 15px 15px 0 0;
    box-shadow: 0 -8px 40px rgba(0,0,0,.18);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: transform .3s cubic-bezier(.32,.72,0,1);
}
.uto-nested-overlay.active .uto-nested-sheet {
    transform: translateX(-50%) translateY(0);
}

/* Mobile: full width, 70% height */
@media (max-width: 600px) {
    .uto-nested-sheet {
        left: 0;
        right: 0;
        width: 100%;
        max-width: 100%;
        height: 70vh;
        max-height: 70vh;
        border-radius: 15px 15px 0 0;
        transform: translateX(0) translateY(100%);
    }
    .uto-nested-overlay.active .uto-nested-sheet {
        transform: translateX(0) translateY(0);
    }
}

/* Header with drag handle */
.uto-nested-header {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    padding-top: 24px;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
}
.uto-nested-header::before {
    content: '';
    position: absolute;
    top: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 36px;
    height: 4px;
    background: #d1d5db;
    border-radius: 2px;
}
.uto-nested-title {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #111827;
}
.uto-nested-close {
    width: 36px;
    height: 36px;
    border: none;
    background: #f3f4f6;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6b7280;
    transition: all .2s;
    touch-action: manipulation;
}
.uto-nested-close:hover {
    background: #e5e7eb;
    color: #111;
}

/* Search bar - sticky at top */
.uto-nested-search {
    position: sticky;
    top: 0;
    z-index: 9;
    padding: 12px 20px;
    border-bottom: 1px solid #e5e7eb;
    background: #fff;
    flex-shrink: 0;
}
.uto-nested-search input {
    width: 100%;
    height: 48px;
    padding: 0 16px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    font-size: 16px !important;
    font-family: "Saira", sans-serif;
    background: #f3f4f6;
    color: #111827;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}
.uto-nested-search input:focus {
    border-color: var(--uto-primary, #FACB05);
    background: #fff;
}

/* Scrollable list */
.uto-nested-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    min-height: 0;
    padding: 8px 0;
}

/* List items */
.uto-nested-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    cursor: pointer;
    transition: background .15s;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
    font-family: "Saira", sans-serif;
    touch-action: manipulation;
}
.uto-nested-item:hover,
.uto-nested-item:focus {
    background: #f8fafc;
}
.uto-nested-item.selected {
    background: #fffbf8;
}
.uto-nested-item.selected::after {
    content: '';
    width: 22px;
    height: 22px;
    margin-left: auto;
    background: var(--uto-primary, #FACB05);
    border-radius: 50%;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' stroke='%23000' stroke-width='3' viewBox='0 0 24 24'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M5 13l4 4L19 7'/%3E%3C/svg%3E");
    background-size: 13px;
    background-repeat: no-repeat;
    background-position: center;
    flex-shrink: 0;
}
.uto-nested-item-text {
    font-size: 16px;
    font-weight: 500;
    color: #111827;
}
.uto-nested-item-sub {
    font-size: 14px;
    color: #6b7280;
    margin-left: auto;
}
.uto-nested-empty {
    padding: 40px 20px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
}
.uto-country-flag {
    width: 24px;
    height: 18px;
    border-radius: 2px;
    object-fit: cover;
    flex-shrink: 0;
}

/* Calendar grid */
.uto-nested-cal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    border-bottom: 1px solid #e5e7eb;
}
.uto-nested-cal-title {
    font-size: 16px;
    font-weight: 600;
    color: #111827;
}
.uto-nested-cal-nav {
    width: 36px;
    height: 36px;
    border: 1px solid #e5e7eb;
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #111827;
    transition: all .15s;
}
.uto-nested-cal-nav:hover {
    background: #f3f4f6;
}
.uto-nested-cal-weekdays {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    padding: 12px 20px 8px;
    gap: 4px;
}
.uto-nested-cal-weekday {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
}
.uto-nested-cal-days {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    padding: 8px 20px 20px;
}
.uto-nested-cal-day {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    color: #111827;
    background: #fff;
    cursor: pointer;
    transition: all .15s;
    font-family: "Saira", sans-serif;
}
.uto-nested-cal-day:hover:not(.disabled) {
    border-color: var(--uto-primary, #FACB05);
    background: #fffbf8;
}
.uto-nested-cal-day.selected {
    background: var(--uto-primary, #FACB05);
    border-color: var(--uto-primary, #FACB05);
    color: #000;
    font-weight: 600;
}
.uto-nested-cal-day.disabled {
    opacity: .4;
    cursor: not-allowed;
    pointer-events: none;
}
.uto-nested-cal-day.today:not(.selected) {
    border-color: #3b82f6;
    color: #3b82f6;
}

/* Time grid */
.uto-nested-time-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    padding: 16px 20px;
    overflow-y: auto;
    max-height: calc(50vh - 80px);
}
@media (max-width: 600px) {
    .uto-nested-time-grid {
        max-height: calc(70vh - 80px);
    }
}
.uto-nested-time-item {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 500;
    color: #111827;
    background: #fff;
    cursor: pointer;
    transition: all .15s;
    font-family: "Saira", sans-serif;
}
.uto-nested-time-item:hover {
    border-color: var(--uto-primary, #FACB05);
    background: #fffbf8;
}
.uto-nested-time-item.selected {
    background: var(--uto-primary, #FACB05);
    border-color: var(--uto-primary, #FACB05);
    color: #000;
    font-weight: 600;
}

/* Flatpickr z-index override (if used) */
.flatpickr-calendar {
    z-index: 1000005 !important;
}

/* Empty state for search */
.uto-nested-empty {
    padding: 40px 20px;
    text-align: center;
    color: #9ca3af;
    font-size: 14px;
}

/* ===== PART C: Mobile nested popup corner radius 20px ===== */
@media (max-width: 767px) {
    .uto-nested-sheet {
        border-top-left-radius: 20px !important;
        border-top-right-radius: 20px !important;
        overflow: hidden;
    }
}

/* ===== PART A (Nested Popup): Readability — Darker text + bolder ===== */
.uto-nested-item-text {
    color: #1f2937 !important;
    font-weight: 500 !important;
}
.uto-nested-search input {
    color: #1f2937 !important;
    font-weight: 500 !important;
}
.uto-nested-search input::placeholder {
    color: #6b7280 !important;
    font-weight: 500 !important;
    opacity: 1 !important;
}
