/* === CSS Variables === */
:root {
    /* Light Theme */
    --bg-primary: #f5f6f8;
    --bg-card: #ffffff;
    --bg-input: #f0f2f5;
    --bg-input-focus: #ffffff;
    --border-color: #e2e5ea;
    --border-focus: #22d3ee;
    --text-primary: #1a1d23;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --accent: #22d3ee;
    --accent-hover: #06b6d4;
    --accent-glow: rgba(34, 211, 238, 0.15);
    --error-bg: rgba(239, 68, 68, 0.08);
    --error-border: rgba(239, 68, 68, 0.3);
    --error-text: #ef4444;
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.06), 0 4px 16px rgba(0, 0, 0, 0.04);
    --shadow-card-hover: 0 2px 8px rgba(0, 0, 0, 0.08), 0 8px 32px rgba(0, 0, 0, 0.06);
}

[data-theme="dark"] {
    --bg-primary: #0f1117;
    --bg-card: #1a1d23;
    --bg-input: #22262e;
    --bg-input-focus: #2a2e37;
    --border-color: #2e3340;
    --border-focus: #22d3ee;
    --text-primary: #e8eaed;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --accent: #22d3ee;
    --accent-hover: #67e8f9;
    --accent-glow: rgba(34, 211, 238, 0.12);
    --error-bg: rgba(239, 68, 68, 0.1);
    --error-border: rgba(239, 68, 68, 0.3);
    --error-text: #f87171;
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.2), 0 4px 16px rgba(0, 0, 0, 0.15);
    --shadow-card-hover: 0 2px 8px rgba(0, 0, 0, 0.3), 0 8px 32px rgba(0, 0, 0, 0.2);
}

/* === Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    transition: background 0.3s ease, color 0.3s ease;
    -webkit-font-smoothing: antialiased;
}

/* === Login Layout === */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 1.5rem;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 2.5rem;
    box-shadow: var(--shadow-card);
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.login-card:hover {
    box-shadow: var(--shadow-card-hover);
}

/* === Header === */
.login-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo {
    font-size: 2rem;
    font-weight: 700;
    letter-spacing: 0.25em;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.subtitle {
    font-size: 0.875rem;
    color: var(--text-muted);
    font-weight: 400;
}

/* === Form === */
.login-form {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    outline: none;
    transition: all 0.2s ease;
    font-family: inherit;
}

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

.form-group input:focus {
    background: var(--bg-input-focus);
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

/* === Password Toggle === */
.password-wrapper {
    position: relative;
}

.password-wrapper input {
    padding-right: 3rem;
}

.toggle-password {
    position: absolute;
    right: 0.75rem;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    display: flex;
    align-items: center;
    transition: color 0.2s ease;
}

.toggle-password:hover {
    color: var(--text-secondary);
}

.toggle-password svg {
    width: 20px;
    height: 20px;
}

/* === Error Message === */
.error-message {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: var(--error-bg);
    border: 1px solid var(--error-border);
    border-radius: 10px;
    color: var(--error-text);
    font-size: 0.875rem;
    animation: shake 0.4s ease;
}

.error-message[hidden] {
    display: none;
}

.error-message svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

/* === Login Button === */
.btn-login {
    width: 100%;
    padding: 0.8125rem;
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    background: var(--accent);
    color: #0f1117;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    margin-top: 0.25rem;
}

.btn-login:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--accent-glow);
}

.btn-login:active:not(:disabled) {
    transform: translateY(0);
}

.btn-login:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.btn-spinner svg {
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
}

.btn-spinner[hidden] {
    display: none;
}

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

/* === Footer / Theme Toggle === */
.login-footer {
    display: flex;
    justify-content: center;
    margin-top: 1.5rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--border-color);
}

.theme-toggle {
    background: none;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.theme-toggle:hover {
    color: var(--text-primary);
    border-color: var(--text-muted);
    background: var(--bg-input);
}

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

/* === Dashboard (post-login) === */
.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
}

/* === Responsive === */
@media (max-width: 480px) {
    .login-card {
        padding: 1.75rem;
        border-radius: 12px;
    }

    .logo {
        font-size: 1.75rem;
    }
}
