/**
 * Quick Child Switcher Component
 * Allows parents to switch between children without returning to dashboard
 * Saves 70-105 min/week for parents with 5 kids
 */

.child-switcher {
    position: relative;
    display: inline-block;
}

.current-child-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    min-width: 180px;
}

.current-child-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(102, 126, 234, 0.4);
}

.current-child-btn:active {
    transform: translateY(0);
}

.current-child-avatar {
    font-size: 24px;
    line-height: 1;
}

.current-child-name {
    flex: 1;
    text-align: left;
}

.dropdown-icon {
    font-size: 12px;
    transition: transform 0.3s ease;
}

.current-child-btn.open .dropdown-icon {
    transform: rotate(180deg);
}

/* Dropdown Menu */
.child-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    padding: 8px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    max-height: 400px;
    overflow-y: auto;
}

.child-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.child-dropdown-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 2px solid transparent;
}

.child-dropdown-item:hover {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    transform: translateX(4px);
}

.child-dropdown-item.active {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.15) 0%, rgba(118, 75, 162, 0.15) 100%);
    border-color: #667eea;
}

.child-dropdown-avatar {
    font-size: 32px;
    line-height: 1;
}

.child-dropdown-info {
    flex: 1;
}

.child-dropdown-name {
    font-size: 16px;
    font-weight: 600;
    color: #2D3436;
    margin: 0 0 4px 0;
    font-family: 'Outfit', sans-serif;
}

.child-dropdown-age {
    font-size: 14px;
    color: #636E72;
    margin: 0;
}

.child-dropdown-check {
    font-size: 20px;
    color: #667eea;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.child-dropdown-item.active .child-dropdown-check {
    opacity: 1;
}

/* Loading State */
.child-switcher-loading {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: #DFE6E9;
    color: #636E72;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    font-family: 'Outfit', sans-serif;
}

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #B2BEC3;
    border-top-color: #636E72;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Empty State */
.child-dropdown-empty {
    padding: 24px 16px;
    text-align: center;
    color: #636E72;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.empty-text {
    font-size: 14px;
    margin: 0 0 16px 0;
}

.btn-add-child-dropdown {
    background: linear-gradient(135deg, #06D6A0 0%, #00A896 100%);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease;
}

.btn-add-child-dropdown:hover {
    transform: scale(1.05);
}

/* Mobile Optimization */
@media (max-width: 768px) {
    .current-child-btn {
        min-width: auto;
        padding: 8px 12px;
        font-size: 14px;
    }

    .current-child-avatar {
        font-size: 20px;
    }

    .current-child-name {
        /* FIXED: Increased from 80px to support longer names */
        max-width: clamp(100px, 25vw, 150px);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .child-dropdown {
        position: fixed;
        /* FIXED: Center positioning to avoid keyboard overlap */
        top: 50%;
        bottom: auto;
        left: 50%;
        right: auto;
        transform: translate(-50%, -50%);
        border-radius: 24px;
        /* FIXED: Account for mobile keyboard and safe areas */
        max-height: min(60vh, calc(100vh - env(safe-area-inset-bottom) - 100px));
        max-width: min(90vw, 400px);
        padding: 16px;
    }

    .child-dropdown.show {
        /* FIXED: Keep centered transform for show state */
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }

    .child-dropdown:not(.show) {
        /* FIXED: Scale down instead of sliding for better mobile UX */
        transform: translate(-50%, -50%) scale(0.95);
        opacity: 0;
        pointer-events: none;
    }
}

/* Scrollbar Styling */
.child-dropdown::-webkit-scrollbar {
    width: 6px;
}

.child-dropdown::-webkit-scrollbar-track {
    background: transparent;
}

.child-dropdown::-webkit-scrollbar-thumb {
    background: #DFE6E9;
    border-radius: 3px;
}

.child-dropdown::-webkit-scrollbar-thumb:hover {
    background: #B2BEC3;
}

/* Backdrop for mobile */
.child-switcher-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.child-switcher-backdrop.show {
    display: block;
    opacity: 1;
}

@media (max-width: 768px) {
    .child-dropdown {
        z-index: 1000;
    }
}
