/* ======================================= */
/* 1. LOGIN PANEL THEME & LAYOUT - MOBILE OPTIMIZED */
/* ======================================= */
:root {
    --purple: #975ab7;
    --brown: #502325;
    --purple-light: #b388d1;
    --purple-dark: #6d4087;
}

/* --- Enhanced Overlay with Depth --- */
.login-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: 
        radial-gradient(circle at 30% 20%, rgba(151, 90, 183, 0.15) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(80, 35, 37, 0.2) 0%, transparent 50%),
        rgba(0, 0, 0, 0.7);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.8s cubic-bezier(0.4, 0, 0.2, 1), 
                visibility 0.8s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(0px);
    /* Mobile: Prevent scrolling on body when overlay is open */
    overscroll-behavior: contain;
}

.login-overlay.is-open {
    opacity: 1;
    visibility: visible;
    backdrop-filter: blur(5px);
    /* Disable animation on mobile for performance */
}

/* Desktop-only animation */
@media (min-width: 769px) and (prefers-reduced-motion: no-preference) {
    .login-overlay.is-open {
        animation: overlayPulse 8s ease-in-out infinite;
    }
}

@keyframes overlayPulse {
    0%, 100% { 
        background: 
            radial-gradient(circle at 30% 20%, rgba(151, 90, 183, 0.15) 0%, transparent 50%),
            radial-gradient(circle at 80% 80%, rgba(80, 35, 37, 0.2) 0%, transparent 50%),
            rgba(0, 0, 0, 0.7);
    }
    50% { 
        background: 
            radial-gradient(circle at 40% 30%, rgba(151, 90, 183, 0.25) 0%, transparent 60%),
            radial-gradient(circle at 70% 70%, rgba(80, 35, 37, 0.3) 0%, transparent 60%),
            rgba(0, 0, 0, 0.75);
    }
}

/* --- 3D Side Panel with Advanced Perspective --- */
.side-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 450px;
    max-width: 90%;
    height: 100%;
    height: 100dvh; /* Use dynamic viewport height for mobile browsers */
    background: rgba(80, 35, 37, 0.7);
    backdrop-filter: blur(15px);
    border-left: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: -10px 0 30px rgba(0,0,0,0.3);
    z-index: 999;
    transform: translateX(100%);
    transition: transform 0.6s cubic-bezier(0.25, 1, 0.5, 1);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    border-radius: 20px 0 0 20px;
    /* Prevent pull-to-refresh on mobile */
    overscroll-behavior-y: contain;
}

.side-panel.is-open {
    transform: translateX(0);
    box-shadow: 
        -20px 0 60px rgba(0,0,0,0.5),
        -8px 0 30px rgba(151, 90, 183, 0.3),
        inset 2px 0 0 rgba(255, 255, 255, 0.15);
}

/* Desktop-only float animation */
@media (min-width: 769px) and (prefers-reduced-motion: no-preference) {
    .side-panel.is-open {
        animation: panelFloat 6s ease-in-out infinite;
    }
}

@keyframes panelFloat {
    0%, 100% { transform: translateX(0) translateY(0px); }
    50% { transform: translateX(0) translateY(-5px); }
}

.panel-content {
    padding: 50px 40px;
    padding-bottom: 80px; /* Extra padding for mobile keyboards */
    border-radius: 20px 0 0 20px;
    min-height: 100%;
    display: flex;
    flex-direction: column;
    color: white;
    position: relative;
    overflow: hidden;
}

/* Animated Background Pattern - Disabled on mobile for performance */
@media (min-width: 769px) and (prefers-reduced-motion: no-preference) {
    .panel-content::before {
        content: '';
        position: absolute;
        top: -50%;
        left: -50%;
        width: 200%;
        height: 200%;
        background: 
            radial-gradient(circle at 25% 25%, rgba(151, 90, 183, 0.1) 0%, transparent 25%),
            radial-gradient(circle at 75% 75%, rgba(255, 255, 255, 0.05) 0%, transparent 25%);
        animation: backgroundShift 20s linear infinite;
        z-index: -1;
    }
}

@keyframes backgroundShift {
    0% { transform: rotate(0deg) scale(1); }
    100% { transform: rotate(360deg) scale(1.1); }
}

/* --- Enhanced Close Button --- */
.close-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 45px;
    height: 45px;
    /* Minimum touch target size for mobile */
    min-width: 44px;
    min-height: 44px;
    color: rgba(255, 255, 255, 0.7);
    font-size: 1.3rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease; /* Faster transition for touch */
    /* Remove 3D transforms on mobile */
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on iOS */
    user-select: none;
    z-index: 10;
}

.close-btn:hover {
    background: rgba(151, 90, 183, 0.3);
    border-color: rgba(151, 90, 183, 0.5);
    color: white;
}

/* Desktop-only 3D effects */
@media (min-width: 769px) and (hover: hover) {
    .close-btn {
        transform-style: preserve-3d;
        transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    }
    
    .close-btn:hover {
        transform: rotate(180deg) scale(1.1) translateZ(10px);
        box-shadow: 
            0 10px 25px rgba(151, 90, 183, 0.4),
            inset 0 2px 5px rgba(255, 255, 255, 0.2);
    }
    
    .close-btn:active {
        transform: rotate(180deg) scale(0.95) translateZ(5px);
    }
}

/* Mobile touch feedback */
@media (max-width: 768px) {
    .close-btn:active {
        background: rgba(151, 90, 183, 0.4);
        transform: scale(0.95);
    }
}

/* --- 3D Tabs with Depth --- */
.tabs {
    display: flex;
    gap: 10px;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 30px;
}

.tab-link {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.05));
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 15px 15px 0 0;
    color: rgba(255, 255, 255, 0.6);
    font-size: 1rem;
    font-weight: 500;
    padding: 15px 20px;
    cursor: pointer;
    position: relative;
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    flex: 1;
    text-align: center;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    /* Minimum touch target */
    min-height: 44px;
}

/* Desktop-only effects */
@media (min-width: 769px) and (hover: hover) {
    .tab-link {
        transform-style: preserve-3d;
        perspective: 500px;
    }
    
    .tab-link::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
        transition: left 0.6s ease;
    }
    
    .tab-link:hover::before {
        left: 100%;
    }
    
    .tab-link:hover {
        background: linear-gradient(145deg, rgba(255, 255, 255, 0.15), rgba(255, 255, 255, 0.08));
        transform: translateY(-2px) rotateX(5deg);
        box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
        color: rgba(255, 255, 255, 0.9);
    }
}

.tab-link::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 50%;
    width: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--purple-light), var(--purple), var(--purple-dark));
    border-radius: 2px;
    transform: translateX(-50%);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 10px rgba(151, 90, 183, 0.5);
}

.tab-link.active {
    background: linear-gradient(145deg, rgba(151, 90, 183, 0.3), rgba(151, 90, 183, 0.1));
    border-color: rgba(151, 90, 183, 0.4);
    color: white;
    font-weight: bold;
    box-shadow: 
        0 8px 25px rgba(151, 90, 183, 0.3),
        inset 0 2px 5px rgba(255, 255, 255, 0.1);
}

.tab-link.active::after {
    width: 100%;
}

/* Mobile touch feedback for tabs */
@media (max-width: 768px) {
    .tab-link:active {
        background: linear-gradient(145deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.1));
        transform: scale(0.98);
    }
}

/* --- Enhanced Forms with 3D Effects --- */
.form-container { 
    display: none; 
    opacity: 0;
    transition: opacity 0.4s ease;
}

.form-container.active { 
    display: block; 
    opacity: 1;
    animation: formSlideIn 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes formSlideIn {
    0% { 
        transform: translateY(20px); 
        opacity: 0; 
    }
    100% { 
        transform: translateY(0); 
        opacity: 1; 
    }
}

/* Disable 3D transforms on mobile */
@media (prefers-reduced-motion: reduce) {
    @keyframes formSlideIn {
        0% { opacity: 0; }
        100% { opacity: 1; }
    }
}

form h1 { 
    font-family: 'Playfair Display', serif; 
    margin-bottom: 15px;
    font-size: 2rem;
    line-height: 1.2;
    background: linear-gradient(135deg, #ffffff, #e6d3f7);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    text-shadow: 0 2px 10px rgba(151, 90, 183, 0.3);
}

form span { 
    font-size: 14px; 
    color: rgba(255, 255, 255, 0.7); 
    margin-bottom: 25px; 
    display: block;
    line-height: 1.5;
}

/* 3D Input Fields */
.input-group {
    position: relative;
    margin: 15px 0;
}

form input {
    width: 100%;
    padding: 15px 20px;
    background: 
        linear-gradient(145deg, rgba(0,0,0,0.3), rgba(0,0,0,0.15)),
        rgba(255, 255, 255, 0.05);
    border: 2px solid transparent;
    border-radius: 12px;
    color: white;
    font-size: 16px; /* Prevents zoom on iOS */
    backdrop-filter: blur(10px);
    transition: all 0.3s ease;
    box-shadow: 
        inset 0 2px 5px rgba(0, 0, 0, 0.3),
        0 1px 0 rgba(255, 255, 255, 0.1);
    -webkit-appearance: none; /* Remove iOS styling */
    appearance: none;
    /* Minimum height for touch targets */
    min-height: 48px;
}

form input::placeholder {
    color: rgba(255, 255, 255, 0.5);
    transition: all 0.3s ease;
}

form input:focus {
    outline: none;
    border-color: var(--purple);
    background: 
        linear-gradient(145deg, rgba(0,0,0,0.4), rgba(0,0,0,0.2)),
        rgba(151, 90, 183, 0.1);
    box-shadow: 
        0 10px 25px -10px rgba(151, 90, 183, 0.4),
        inset 0 2px 5px rgba(0, 0, 0, 0.3),
        0 0 0 3px rgba(151, 90, 183, 0.2);
}

/* Desktop-only 3D transform */
@media (min-width: 769px) and (hover: hover) {
    form input {
        transform-style: preserve-3d;
    }
    
    form input:focus {
        transform: translateY(-2px) rotateX(2deg);
    }
}

form input:focus::placeholder {
    color: rgba(255, 255, 255, 0.3);
}

/* Floating Label Effect - Desktop only */
@media (min-width: 769px) {
    .input-group::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 2px;
        background: linear-gradient(90deg, transparent, var(--purple), transparent);
        transform: scaleX(0);
        transition: transform 0.4s ease;
        border-radius: 2px;
    }
    
    form input:focus + .input-group::before {
        transform: scaleX(1);
    }
}

/* 3D Submit Button */
form button {
    width: 100%;
    padding: 16px 40px;
    margin-top: 30px;
    border-radius: 50px;
    border: 2px solid var(--purple);
    background: linear-gradient(145deg, var(--purple), var(--purple-dark));
    color: white;
    font-weight: bold;
    font-size: 16px;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    box-shadow: 
        0 8px 25px rgba(151, 90, 183, 0.3),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    /* Minimum touch target */
    min-height: 48px;
    -webkit-appearance: none;
    appearance: none;
}

/* Desktop-only effects */
@media (min-width: 769px) and (hover: hover) {
    form button {
        transform-style: preserve-3d;
    }
    
    form button::before {
        content: '';
        position: absolute;
        top: 0;
        left: -100%;
        width: 100%;
        height: 100%;
        background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.3), transparent);
        transition: left 0.6s ease;
    }
    
    form button:hover {
        background: linear-gradient(145deg, var(--purple-light), var(--purple));
        transform: translateY(-4px) scale(1.02);
        box-shadow: 
            0 15px 40px rgba(151, 90, 183, 0.4),
            inset 0 2px 0 rgba(255, 255, 255, 0.3);
    }
    
    form button:hover::before {
        left: 100%;
    }
}

form button:active {
    transform: scale(0.98);
    box-shadow: 
        0 4px 15px rgba(151, 90, 183, 0.4),
        inset 0 2px 5px rgba(0, 0, 0, 0.2);
}

/* Enhanced Form Messages */
.form-message {
    margin-top: 20px;
    font-size: 14px;
    line-height: 1.5;
    padding: 12px 18px;
    border-radius: 8px;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.05);
    animation: messageSlideIn 0.5s ease;
}

@keyframes messageSlideIn {
    0% { 
        transform: translateY(10px); 
        opacity: 0; 
    }
    100% { 
        transform: translateY(0); 
        opacity: 1; 
    }
}

/* ======================================= */
/* RESPONSIVE BREAKPOINTS */
/* ======================================= */

/* Large phones and small tablets (landscape) */
@media (max-width: 768px) and (orientation: landscape) {
    .side-panel {
        width: 100%;
        max-width: 100%;
        border-radius: 0;
    }
    
    .panel-content {
        padding: 20px 30px 60px;
    }
    
    form h1 {
        font-size: 1.6rem;
    }
}

/* Tablets and below */
@media (max-width: 768px) {
    .side-panel {
        width: 100%;
        max-width: 100%;
        border-radius: 0;
    }
    
    .panel-content {
        padding: 30px 25px 100px; /* Extra bottom padding for keyboard */
    }
    
    form h1 {
        font-size: 1.8rem;
    }
    
    .tab-link {
        padding: 12px 15px;
        font-size: 0.95rem;
    }
    
    .tabs {
        gap: 8px;
    }
}

/* Small phones */
@media (max-width: 480px) {
    .panel-content {
        padding: 25px 20px 100px;
    }
    
    form h1 {
        font-size: 1.6rem;
    }
    
    .tab-link {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
    
    .close-btn {
        width: 40px;
        height: 40px;
        top: 15px;
        right: 15px;
        font-size: 1.1rem;
    }
    
    form input,
    form button {
        padding: 14px 18px;
        font-size: 15px;
    }
    
    form button {
        padding: 14px 30px;
    }
}

/* Very small phones */
@media (max-width: 360px) {
    .panel-content {
        padding: 20px 15px 100px;
    }
    
    form h1 {
        font-size: 1.4rem;
    }
    
    .tab-link {
        padding: 10px 8px;
        font-size: 0.85rem;
    }
    
    form input,
    form button {
        font-size: 14px;
    }
}

/* Particle effects - Desktop only */
@media (min-width: 769px) and (prefers-reduced-motion: no-preference) {
    @keyframes particleFloat {
        0%, 100% { 
            transform: translateY(0px) rotate(0deg); 
            opacity: 0.1; 
        }
        50% { 
            transform: translateY(-20px) rotate(180deg); 
            opacity: 0.3; 
        }
    }

    .panel-content::after {
        content: '';
        position: absolute;
        top: 20%;
        right: 10%;
        width: 4px;
        height: 4px;
        background: rgba(151, 90, 183, 0.6);
        border-radius: 50%;
        animation: particleFloat 8s ease-in-out infinite;
        box-shadow: 
            20px 20px 0 -1px rgba(255, 255, 255, 0.1),
            -20px 40px 0 -1px rgba(151, 90, 183, 0.3),
            40px -10px 0 -1px rgba(255, 255, 255, 0.2);
    }
}

/* iOS Safe Area Support */
@supports (padding-top: env(safe-area-inset-top)) {
    .side-panel {
        padding-top: env(safe-area-inset-top);
    }
    
    .panel-content {
        padding-top: calc(50px + env(safe-area-inset-top));
        padding-bottom: calc(80px + env(safe-area-inset-bottom));
    }
    
    .close-btn {
        top: calc(20px + env(safe-area-inset-top));
    }
}

/* Prevent zoom on input focus for iOS */
@media (max-width: 768px) {
    input,
    textarea,
    select {
        font-size: 16px !important;
    }
}

/* High DPI displays optimization */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .side-panel {
        backdrop-filter: blur(10px); /* Reduce blur on high DPI for performance */
    }
}