/**
 * Auth Pages CSS - Premium Dark MekryPro Style
 * Käytetään: login.php, register.php, forgot_password.php
 * @author    Kaido Mägi
 * @copyright 2025
 */

/* ============================================================
   TAUSTA (ei valkoista läikkää)
   ============================================================ */
body.login-page,
body.auth-page {
    min-height: 100vh;
    margin: 0;
    display: flex;
    align-items: center; /* Keskitys pystysuunnassa */
    justify-content: center; /* Keskitys vaakatasossa */
    background:
        radial-gradient(
            circle at 30% 20%,
            rgba(46, 94, 255, 0.18),
            rgba(10, 15, 30, 0.95) 60%
        ),
        linear-gradient(
            180deg,
            #0a0f1e 0%,
            #0b1224 100%
        );
    background-attachment: fixed;
    color: #e5e7eb;
    position: relative;
    padding: 20px;
    padding-top: 80px; /* Varmistaa että sisältö ei peity kielinappien alle */
    padding-bottom: 20px; /* Tasapainottaa padding-top */
    box-sizing: border-box;
}

/* ============================================================
   WRAPPER (yksi keskitetty column layout)
   ============================================================ */
.login-wrapper {
    width: 100%;
    max-width: 380px;
    padding: 16px;
    position: relative;
    z-index: 1;
    margin: 0 auto; /* Keskittää wrapperin vaakatasossa */
}

/* Register-wrapper (laajempi - valintasivulle) */
.register-wrapper-wide {
    max-width: 800px;
    margin: 0 auto; /* Keskittää wrapperin vaakatasossa */
}

/* ============================================================
   KIELIVALINTA (desktop: oikea yläkulma, mobiili: keskellä)
   ============================================================ */
/* Wrapper: position fixed - desktop oikealla, mobiili keskellä (mobile.css hoitaa) */
.login-lang-switcher {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    margin-right: 0;
}

/* Sama tyyli kuin home.php:ssa topbarissa - tumma läpinäkyvä tausta wrapperissa */
.login-lang-switcher .lang-switch {
    display: flex;
    gap: 8px;
    margin-right: 0;
    /* Tumma läpinäkyvä tausta - sama kuin home.php topbarissa */
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    padding: 6px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    /* Position on wrapperissa, ei tässä elementissä */
}

.login-lang-switcher .lang-btn {
    min-width: 44px;
    height: 32px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    line-height: 1;
    transition: all 0.2s ease;
    cursor: pointer;
}

.login-lang-switcher .lang-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
}

.login-lang-switcher .lang-btn.is-active,
.login-lang-switcher .lang-btn.active {
    background: rgba(40, 120, 255, 0.35);
    border-color: rgba(40, 120, 255, 0.8);
    color: #fff;
    cursor: default;
}

/* ============================================================
   BRANDI + TEKSTIT (kortin yläpuolella, keskitetty)
   ============================================================ */
/* Vanha .login-brand piilotetaan (ei enää käytössä) */
.login-brand {
    display: none;
}

/* Uusi .auth-brand (wrapperin sisällä, kortin yläpuolella) */
.auth-brand {
    text-align: center;
    margin-bottom: 24px;
    position: relative;
    z-index: 1;
}

.auth-brand-logo {
    color: #ffffff;
    font-size: 24px;
    font-weight: 600;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
}

.auth-brand-slogan {
    color: #c7d2fe;
    font-size: 13px;
    margin-top: 4px;
    font-weight: 400;
}

/* ============================================================
   LOGIN-KORTTI (premium card)
   ============================================================ */
.login-card {
    background: rgba(15, 23, 42, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 14px;
    padding: 24px;
    box-shadow:
        0 25px 50px rgba(0, 0, 0, 0.55),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    position: relative;
    z-index: 1; /* Varmistaa että kortti on kielinappien alla */
}

.login-card h1 {
    margin: 0 0 8px;
    font-size: 24px;
    font-weight: 600;
    color: #ffffff;
    line-height: 1.3;
}

.login-card p.subtle {
    margin: 0 0 24px;
    font-size: 14px;
    color: #cbd5f5;
    line-height: 1.5;
}

/* ============================================================
   LOMAKERIVIT
   ============================================================ */
.login-card .form-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.login-card .form-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 13px;
}

/* ============================================================
   LABELIT / INPUTIT (luettavuus)
   ============================================================ */
.login-card label,
.login-card .form-row label {
    color: #cbd5f5;
    font-size: 13px;
    font-weight: 500;
}

.login-card input[type="text"],
.login-card input[type="password"],
.login-card input[type="email"],
.login-card input[type="tel"] {
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    padding: 8px 10px;
    font-size: 14px;
    background: #0b1224;
    color: #ffffff;
    outline: none;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
    width: 100%;
    box-sizing: border-box;
}

.login-card input[type="text"]::placeholder,
.login-card input[type="password"]::placeholder,
.login-card input[type="email"]::placeholder,
.login-card input[type="tel"]::placeholder {
    color: #64748b;
    opacity: 1;
}

.login-card input[type="text"]:focus,
.login-card input[type="password"]:focus,
.login-card input[type="email"]:focus,
.login-card input[type="tel"]:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.4);
    background: #0b1224;
    outline: none;
}

/* ============================================================
   PÄÄNAPPI (MekryPro sininen)
   ============================================================ */
/* Varmista että lang-btn ei koske submit-nappeja */
.login-card button[type="submit"]:not(.lang-btn),
.login-primary-btn:not(.lang-btn) {
    margin-top: 6px;
    width: 100%;
    border-radius: 10px;
    border: none;
    background: linear-gradient(135deg, #2563eb, #3b82f6);
    color: #ffffff;
    padding: 0;
    height: 44px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.2s ease, transform 0.05s ease;
}

.login-card button[type="submit"]:not(.lang-btn):hover,
.login-primary-btn:not(.lang-btn):hover {
    filter: brightness(1.05);
    transform: translateY(-1px);
}

.login-card button[type="submit"]:not(.lang-btn):active,
.login-primary-btn:not(.lang-btn):active {
    transform: translateY(0);
}

/* ============================================================
   LINKIT (Unohditko / Rekisteröidy)
   ============================================================ */
.login-card a,
.login-links a {
    color: #93c5fd;
    text-decoration: none;
    transition: color 0.2s ease, text-decoration 0.2s ease;
    font-size: 13px;
    font-weight: 400;
}

.login-card a:hover,
.login-links a:hover {
    color: #bfdbfe;
    text-decoration: underline;
}

/* ============================================================
   ERROR / SUCCESS / ALERT -VIESTIT
   ============================================================ */
.login-card .error,
.login-card .alert,
.login-card .success {
    margin-bottom: 20px;
    border-radius: 10px;
    padding: 12px 14px;
    font-size: 13px;
    line-height: 1.5;
}

.login-card .error {
    background: rgba(127, 29, 29, 0.3);
    color: #fecaca;
    border: 1px solid rgba(254, 202, 202, 0.3);
}

.login-card .alert.alert-info {
    background: rgba(30, 58, 138, 0.3);
    color: #bfdbfe;
    border: 1px solid rgba(191, 219, 254, 0.3);
}

.login-card .success {
    background: rgba(6, 95, 70, 0.3);
    color: #d1fae5;
    border: 1px solid rgba(209, 250, 229, 0.3);
}

/* ============================================================
   PASSWORD TOGGLE (jos lisätään)
   ============================================================ */
.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: #64748b;
    cursor: pointer;
    padding: 4px;
    font-size: 18px;
    line-height: 1;
    transition: color 0.2s ease;
}

.password-toggle:hover {
    color: #cbd5f5;
}

.form-row.password-field {
    position: relative;
}

/* ============================================================
   REGISTER-SPECIFIC STYLES
   ============================================================ */
body.login-page.register-choice {
    background: radial-gradient(circle at top, #2563eb 0, #0f172a 45%, #020617 100%);
}

/* Poistettu - siirretty ylempään */

.register-choice-card {
    background: rgba(17, 24, 39, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 32px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    z-index: 1; /* Varmistaa että kortti on kielinappien alla */
    width: 100%;
}

.register-choice-card h1 {
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 12px 0;
    background: linear-gradient(135deg, #ffffff 0%, #e0e7ff 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.register-choice-card .subtle {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.8);
    margin-bottom: 28px;
}

.register-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 24px;
    margin: 32px 0;
}

.register-option {
    display: block;
    text-decoration: none;
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 32px;
    text-align: center;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.register-option::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    transition: left 0.5s ease;
}

.register-option:hover::before {
    left: 100%;
}

.register-option:hover {
    transform: translateY(-8px);
    border-color: rgba(255, 255, 255, 0.3);
    background: rgba(255, 255, 255, 0.1);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.register-option-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    display: block;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.3));
}

.register-option-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0 0 12px 0;
    display: block;
}

.register-option-desc {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
    line-height: 1.5;
}

.register-option.primary {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.2) 0%, rgba(59, 130, 246, 0.1) 100%);
    border-color: rgba(59, 130, 246, 0.3);
}

.register-option.primary:hover {
    background: linear-gradient(135deg, rgba(37, 99, 235, 0.3) 0%, rgba(59, 130, 246, 0.2) 100%);
    border-color: rgba(59, 130, 246, 0.5);
}

.register-option.secondary {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2) 0%, rgba(168, 85, 247, 0.1) 100%);
    border-color: rgba(168, 85, 247, 0.3);
}

.register-option.secondary:hover {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.3) 0%, rgba(168, 85, 247, 0.2) 100%);
    border-color: rgba(168, 85, 247, 0.5);
}

.register-oauth-buttons {
    margin-bottom: 32px;
}

/* Register form helpers */
.form-row-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 10px;
}

.form-field-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.register-help-text {
    color: #6b7280;
    font-size: 12px;
}

.register-back-link {
    margin-top: 20px;
    text-align: center;
}

.register-back-link a {
    color: #3b82f6;
    text-decoration: none;
    transition: color 0.2s ease;
}

.register-back-link a:hover {
    color: #2563eb;
    text-decoration: underline;
}

.register-footer {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid #e5e7eb;
    text-align: center;
}

.register-footer p {
    color: #6b7280;
    font-size: 14px;
    margin: 0;
}

.register-footer a {
    color: #3b82f6;
    text-decoration: none;
    transition: color 0.2s ease;
}

.register-footer a:hover {
    color: #2563eb;
    text-decoration: underline;
}

/* ============================================================
   2FA PAGE STYLES
   ============================================================ */
.form-hint {
    color: #9ca3af;
    font-size: 12px;
    margin-top: 4px;
    display: block;
}

.form-link {
    color: #60a5fa;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s ease;
}

.form-link:hover {
    color: #93c5fd;
    text-decoration: underline;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.auth-footer-link {
    margin-top: 20px;
    text-align: center;
}

.auth-footer-link a {
    color: #9ca3af;
    text-decoration: none;
    font-size: 14px;
    transition: color 0.2s ease;
}

.auth-footer-link a:hover {
    color: #cbd5f5;
    text-decoration: underline;
}

/* Verify email page */
.verify-email-actions {
    margin-top: 16px;
}

.verify-email-actions .btn {
    display: inline-block;
}

.password-status {
    margin-top: 8px;
    font-size: 13px;
}

.password-suggestions {
    margin-top: 8px;
    font-size: 12px;
    color: #6b7280;
}

@media (max-width: 768px) {
    .register-choice-card {
        padding: 24px 20px;
    }
    
    .register-choice-card h1 {
        font-size: 2rem;
    }
    
    .register-options {
        grid-template-columns: 1fr;
        gap: 16px;
        margin: 24px 0; /* Pienempi marginaali mobiilissa */
    }
    
    .register-option {
        padding: 24px 20px; /* Pienemmät paddingit mobiilissa */
    }
    
    .form-row-grid {
        grid-template-columns: 1fr;
    }
}

/* ============================================================
   OAUTH BUTTONS
   ============================================================ */
.oauth-buttons {
    margin-bottom: 24px;
}

.oauth-btn {
    display: block;
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    text-align: center;
    background: #fff;
    color: #333;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.oauth-btn:last-child {
    margin-bottom: 0;
}

.oauth-btn:hover {
    background: #f9fafb;
    border-color: #bbb;
}

.oauth-divider {
    text-align: center;
    margin: 20px 0;
    position: relative;
}

.oauth-divider span {
    background: #1f2937;
    padding: 0 12px;
    position: relative;
    z-index: 1;
    color: #9ca3af;
    font-size: 14px;
}

.oauth-divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    z-index: 0;
}

/* ============================================================
   LOGIN FOOTER LINKS
   ============================================================ */
.login-card .login-footer-link {
    margin-top: 20px;
    text-align: center;
}

.login-card .login-footer-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.login-card .login-footer-text {
    color: #9ca3af;
    font-size: 14px;
    margin: 0;
}

.login-card .login-footer-hint {
    margin-top: 16px;
    font-size: 12px;
    color: #9ca3af;
    text-align: center;
}











