/* Theme Variables */
:root[data-theme="light"] {
    --primary-color: #06b6d4;
    --primary-hover: #0891b2;
    --secondary-color: #64748b;
    --background-color: linear-gradient(135deg, #e9ecef 0%, #dee2e6 50%, #ced4da 100%);
    --surface-color: linear-gradient(135deg, #ffffff 0%, #f3f4f6 50%, #e9ecef 100%);
    --surface-color-solid: #ffffff;
    --card-bg: #ffffff;
    --bg-secondary: #f8fafc;
    --border-color: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --success-color: #059669;
    --warning-color: #d97706;
    --error-color: #dc2626;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

:root[data-theme="Solarized Dark"] {
    --primary-color: #3b82f6;
    --primary-hover: #2563eb;
    --secondary-color: #94a3b8;
    --background-color: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #334155 100%);
    --surface-color: linear-gradient(135deg, #1e293b 0%, #334665 50%, #49638f 100%);
    --surface-color-solid: #1e293b;
    --card-bg: #1e293b;
    --bg-secondary: #334155;
    --border-color: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #64748b;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.3);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.3), 0 2px 4px -2px rgb(0 0 0 / 0.3);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.3), 0 4px 6px -4px rgb(0 0 0 / 0.3);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.3), 0 8px 10px -6px rgb(0 0 0 / 0.3);
}

:root[data-theme="dark"],
:root {
    --primary-color: #8d6c1f;
    --primary-hover: #7e5c25;
    --secondary-color: #8b949e;
    --background-color: linear-gradient(135deg, #0d1117 0%, #161b22 50%, #21262d 100%);
    --surface-color: linear-gradient(135deg, #161b22 0%, #252d39 50%, #343f50 100%);
    --surface-color-solid: #161b22;
    --card-bg: #161b22;
    --bg-secondary: #21262d;
    --border-color: #30363d;
    --text-primary: #f0f6fc;
    --text-secondary: #c9d1d9;
    --text-muted: #8b949e;
    --success-color: #3fb950;
    --warning-color: #d29922;
    --error-color: #f85149;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.4);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.4), 0 8px 10px -6px rgb(0 0 0 / 0.4);
}

:root[data-theme="Aubergine"] {
    --primary-color: #178F65;
    --primary-hover: #127A56;
    --secondary-color: #83388A;
    --background-color: linear-gradient(135deg, #611F69 0%, #83388A 60%, #DF9FF4 100%);
    --surface-color: linear-gradient(135deg, #611F69 0%, #83388A 100%);
    --surface-color-solid: #611F69;
    --card-bg: #611F69;
    --bg-secondary: #83388A;
    --border-color: #83388A;
    --text-primary: #F4F0F5;
    --text-secondary: #CFA7E6;
    --text-muted: rgba(207, 167, 230, 0.75);
    --success-color: #178F65;
    --warning-color: #d29922;
    --error-color: #f85149;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.4);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4), 0 2px 4px -2px rgb(0 0 0 / 0.4);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.4), 0 4px 6px -4px rgb(0 0 0 / 0.4);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.4), 0 8px 10px -6px rgb(0 0 0 / 0.4);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    overflow-x: hidden;
    overflow-y: auto;
    background: var(--background-color);
    color: var(--text-primary);
}

.container {
    position: relative;
    width: 100vw;
    height: 100vh;
    background: var(--background-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.particles {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.particle {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, var(--primary-color) 0%, var(--primary-hover) 60%, transparent 100%);
    box-shadow: 0 0 10px color-mix(in srgb, var(--primary-color) 40%, transparent);
    animation: shimmer ease-in-out infinite;
    pointer-events: none;
}

@keyframes shimmer {
    0%, 100% {
        opacity: 0.3;
        transform: translateY(0);
    }
    50% {
        opacity: 0.7;
        transform: translateY(-10px);
    }
}

.time {
    position: absolute;
    top: 32px;
    right: 48px;
    color: var(--text-primary);
    font-size: 24px;
    font-weight: 300;
    white-space: nowrap;
}

.content {
    position: relative;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.login-container {
    background: color-mix(in srgb, var(--text-primary) 1%, transparent);
    backdrop-filter: blur(8px) saturate(110%);
    -webkit-backdrop-filter: blur(8px) saturate(110%);
    border: 1px solid var(--border-color);
    border-radius: 32px;
    padding: 64px 80px;
    box-shadow: var(--shadow-xl);
    display: flex;
    flex-direction: column;
    align-items: center;
    min-width: 480px;
}

h1 {
    color: var(--text-secondary);
    font-family: Georgia, 'Times New Roman', Times, serif;
    font-size: 48px;
    font-weight: 300;
    margin-bottom: 16px;
    letter-spacing: -0.5px;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 20px;
    margin-bottom: 48px;
    font-weight: 400;
}

.login-form {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.input-group {
    position: relative;
    width: 100%;
}

.input-group input {
    width: 100%;
    padding: 16px 20px;
    background: color-mix(in srgb, var(--text-primary) 3%, transparent);
    backdrop-filter: blur(10px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    color: var(--text-primary);
    font-size: 16px;
    outline: none;
    transition: all 0.3s ease;
}

.input-group input::placeholder {
    color: var(--text-muted);
}

.input-group input:focus {
    background: color-mix(in srgb, var(--text-primary) 6%, transparent);
    border-color: var(--primary-color);
    box-shadow: 0 4px 16px color-mix(in srgb, var(--primary-color) 10%, transparent);
}

.input-group input:-webkit-autofill,
.input-group input:-webkit-autofill:hover,
.input-group input:-webkit-autofill:focus,
.input-group input:-webkit-autofill:active {
    -webkit-background-clip: text !important;
    background-clip: text !important;
    -webkit-text-fill-color: var(--text-primary) !important;
    box-shadow: inset 0 0 0 1px var(--border-color), inset 0 0 0 100px color-mix(in srgb, var(--text-primary) 3%, transparent) !important;
    caret-color: var(--text-primary) !important;
}

.password-group {
    position: relative;
}

.password-group input {
    padding-right: 56px;
}

.eye-btn {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease;
}

.eye-btn:hover {
    opacity: 0.7;
}

.eye-btn svg {
    width: 24px;
    height: 24px;
    color: var(--text-muted);
}

.login-btn {
    width: 100%;
    padding: 16px;
    background: color-mix(in srgb, var(--primary-color) 15%, transparent);
    backdrop-filter: blur(10px);
    border: 1px solid var(--primary-color);
    border-radius: 16px;
    color: var(--primary-color);
    font-size: 18px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 12px;
    box-shadow: var(--shadow-sm);
}

.login-btn:hover {
    background: color-mix(in srgb, var(--primary-color) 25%, transparent);
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.login-btn:active {
    transform: scale(0.98);
}

.footer {
    position: absolute;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-muted);
    font-size: 14px;
    text-align: center;
    z-index: 10;
}

.logo {
    position: absolute;
    top: 32px;
    left: 28px;
    height: 85px;
    width: auto;
    z-index: 10;
}

.session-warning {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.session-warning.active {
    opacity: 1;
    visibility: visible;
}

.session-warning__dialog {
    width: min(440px, 100%);
    background: var(--surface-color-solid);
    border-radius: 20px;
    padding: 32px;
    box-shadow: var(--shadow-xl);
    text-align: center;
    border: 1px solid color-mix(in srgb, var(--border-color) 60%, transparent);
}

.session-warning__icon {
    width: 68px;
    height: 68px;
    border-radius: 14px;
    margin: 0 auto 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--warning-color) 12%, transparent);
    color: var(--warning-color);
}

.session-warning__dialog h2 {
    font-size: 1.4rem;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.session-warning__dialog p {
    color: var(--text-secondary);
    line-height: 1.5;
}

.session-warning__note {
    margin-top: 10px;
    font-size: 0.95rem;
}

.session-warning__actions {
    display: flex;
    gap: 16px;
    margin-top: 24px;
    justify-content: center;
}

.session-warning__actions--single {
    justify-content: center;
}

.session-warning__actions--single .modal-btn {
    flex: 0 0 auto;
    min-width: 160px;
}

.modal-btn {
    flex: 1;
    padding: 12px 0;
    border-radius: 999px;
    border: 1px solid transparent;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.modal-btn.primary {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.modal-btn.primary:hover {
    background: var(--primary-hover);
}

.modal-btn.secondary {
    background: transparent;
    color: var(--text-secondary);
    border-color: color-mix(in srgb, var(--text-secondary) 35%, transparent);
}

.modal-btn.secondary:hover {
    color: var(--text-primary);
    border-color: color-mix(in srgb, var(--text-primary) 35%, transparent);
}

/* 1. Mobile phones (portrait or landscape, up to 767px wide) */
@media only screen and (max-width: 767px) {
    body {
        overflow-x: hidden;
        overflow-y: auto;
        padding: 12px 0 24px;
        min-height: auto;
    }

    .container {
        height: auto;
        min-height: 90vh;
        padding: 12px 16px 32px;
        align-items: center;
        justify-content: flex-start;
        gap: 16px;
        flex-direction: column;
    }

    .particles {
        position: fixed;
    }

    .logo {
        position: relative;
        display: block;
        height: 85px;
        z-index: 1;
        margin-right: 2rem;
    }
    
    .time {
        display: none;
    }

    .content {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        flex: 1;
        padding-top: 0;
    }

    .login-container {
        width: 92%;
        max-width: 330px;
        padding: 20px 18px 26px;
        border-radius: 24px;
        box-shadow: var(--shadow-lg);
        margin: 80px auto 0;
        min-width: auto;
    }

    h1 {
        font-size: 27px;
        text-align: center;
    }

    .subtitle {
        font-size: 14px;
        margin-bottom: 22px;
        text-align: center;
    }

    .login-form {
        gap: 14px;
    }

    .session-warning__dialog {
        width: min(340px, 100%);
        padding: 20px;
    }

    .session-warning__actions {
        flex-direction: column;
        width: 100%;
    }

    .footer {
        position: sticky;
        bottom: calc(env(safe-area-inset-bottom, 0px) + 12px);
        left: 0;
        transform: none;
        width: 100%;
        text-align: center;
        margin-top: auto;
        padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px);
        background: transparent;
    }
}

/* 2. Small landscape screens (height up to 500px, width between 768px and 999px) */
@media only screen and (orientation: landscape) and (min-width: 768px) and (max-width: 999px) and (max-height: 500px) {
    body {
        overflow-x: hidden;
        overflow-y: auto;
        padding: 12px 0 24px;
        min-height: auto;
    }

    .container {
        height: auto;
        min-height: 90vh;
        padding: 0;
        align-items: center;
        justify-content: center;
        position: relative;
        flex-direction: column;
        gap: 0;
    }

    .content {
        width: 100%;
        align-items: center;
        justify-content: center;
    }

    .logo {
        position: absolute;
        top: 16px;
        left: 24px;
        height: 58px;
    }

    .time {
        position: absolute;
        top: 16px;
        right: 24px;
        font-size: 18px;
    }

    .login-container {
        width: 40%;
        padding: 22px 26px 28px;
        border-radius: 20px;
        margin: 0 auto;
        min-width: auto;
    }

    h1 {
        font-size: 24px;
        margin-bottom: 10px;
    }

    .subtitle {
        font-size: 14px;
        margin-bottom: 18px;
    }

    #username,
    #password {
        padding: 10px 14px;
    }

    .login-form {
        gap: 14px;
    }

    .login-btn {
        padding: 10px 14px;
        margin-top: 10px;
    }

    .footer {
        position: absolute;
        bottom: 5px;
        left: 50%;
        font-size: 13px;
        text-align: center;
        width: auto;
    }
}

/* 3. Mid-range tablets and small laptops (width 800px-899px, height 431px-700px) */
@media only screen and (min-width: 800px) and (max-width: 899px) and (min-height: 431px) and (max-height: 700px) {
    body {
        overflow-y: auto;
    }

    .container {
        align-items: flex-start;
        padding: 40px 32px 64px;
        height: auto;
        min-height: 100vh;
    }

    .login-container {
        min-width: auto;
        width: min(460px, 90vw);
        padding: 44px 52px;
        margin: 0 auto;
    }

    h1 {
        font-size: 38px;
    }

    .subtitle {
        font-size: 18px;
    }
}

/* 4. Medium desktops/laptops (width 1000px-1200px, height 701px-850px, landscape) */
@media only screen and (orientation: landscape) and (min-width: 1000px) and (max-width: 1200px) and (min-height: 701px) and (max-height: 850px) {
    .container {
        padding: 32px;
    }

    .login-container {
        min-width: 520px;
        padding: 56px 64px;
    }

    h1 {
        font-size: 42px;
    }

    .subtitle {
        font-size: 18px;
    }

    .time {
        top: 24px;
        right: 32px;
    }

    .footer {
        bottom: calc(env(safe-area-inset-bottom, 0px) + 16px);
        padding-bottom: calc(env(safe-area-inset-bottom, 0px));
        bottom: 10%;
    }
}

/* 5. Tablets in portrait (device width 768px-1024px, portrait only, excluding <768px phones) */
@media only screen and (min-width: 768px) and (max-width: 1024px) and (orientation: portrait) {
    body {
        overflow: hidden;
        padding: 0;
        height: 100vh;
    }

    .container {
        height: 100vh;
        min-height: 100vh;
        padding: 32px 32px 48px;
        align-items: center;
        justify-content: center;
        gap: 24px;
        flex-direction: column;
        position: relative;
    }

    .particles {
        position: fixed;
    }

    .logo {
        position: absolute;
        top: 24px;
        left: 32px;
        transform: none;
        height: 78px;
        z-index: 10;
    }
    
    .time {
        position: absolute;
        top: 28px;
        right: 32px;
        display: block;
        font-size: 20px;
    }

    .content {
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        flex: 1;
        justify-content: center;
        padding-top: 32px;
        height: auto;
    }

    .login-container {
        width: 85%;
        max-width: 520px;
        padding: 32px 40px;
        border-radius: 24px;
        margin: 0 auto;
        min-width: auto;
    }

    h1 {
        font-size: 34px;
        text-align: center;
    }

    .subtitle {
        font-size: 18px;
        margin-bottom: 26px;
        text-align: center;
    }

    .login-form {
        gap: 18px;
    }

    .session-warning__dialog {
        width: min(340px, 100%);
        padding: 20px;
    }

    .session-warning__actions {
        flex-direction: column;
        width: 100%;
    }

    .footer {
        position: absolute;
        bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
        left: 50%;
        bottom: 8%;
        transform: translateX(-50%);
        width: auto;
        text-align: center;
        margin-top: 0;
        padding-bottom: calc(env(safe-area-inset-bottom, 0px));
    }
}

@media (prefers-reduced-motion: reduce) {
    .particles {
        display: none;
    }

    .particle {
        animation: none;
    }
}
