/* =========================
   Login page – colors from preferences (inject in app_login.ejs):
   - background        -> page background, footer
   - background_primary -> form card
   - button           -> Login button
   - text             -> form text
   ========================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
}

/* =========================
   PAGE LAYOUT
   ========================= */
body.theme-light {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--pref-background, #0061B0);
    min-height: 100vh;
    min-height: 100dvh;
    color: #ffffff;
    overflow-x: hidden;
}
body.theme-light button {
    background: var(--pref-button, #00C7C8);
    color: #fff;
}
body.theme-light .login-footer {
    background-color: var(--pref-background_hover, #0061B0);
    color: #fff;
}
.login-page {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Top logo */
.login-logo {
    margin-top: clamp(40px, 10vh, 100px);
    margin-bottom: clamp(24px, 5vh, 55px);
}
.login-logo img {
    max-width: min(400px, 90vw);
    height: auto;
    display: block;
}

/* Form container area */
.login-main {
    width: 100%;
    max-width: 420px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Bottom footer */
.login-footer {
    text-align: center;
    font-size: 0.8rem;
    padding: 12px 16px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
    width: 100%;
    margin-top: auto;
}

/* =========================
   CARD LOGIN
   ========================= */
.login-container,
.theme-light .login-container {
    background: var(--pref-background-primary, #E8E8E8);
    box-shadow: 0 2px 10px 2px rgba(0, 0, 0, 0.25);
    width: 100%;
    padding: clamp(16px, 4vw, 24px) clamp(20px, 5vw, 32px);
    margin-bottom: 15px;
    color: var(--pref-text, #090909);
    border-radius: 10px;
}

/* Form */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    color: var(--pref-text, #090909);
    font-weight: 400;
    margin-bottom: 6px;
    font-size: 0.95em;
}

.form-group input {
    width: 100%;
    padding: 12px 14px;
    min-height: 44px;
    border: 1.5px solid #939393;
    border-radius: 8px;
    font-size: 16px;
    background: var(--pref-background-primary, #E8E8E8);
    color: var(--pref-text, #090909);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}
.form-group input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.25);
}
.form-group input::placeholder {
    color: #666;
}

/* Button – touch-friendly, full width */
.btn-login {
    width: 100%;
    min-height: 44px;
    padding: 12px 16px;
    background: var(--pref-button, #00C7C8);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-size: 1.05em;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.15s ease;
    margin-top: 10px;
    -webkit-tap-highlight-color: transparent;
}
.btn-login:hover {
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
    filter: brightness(1.05);
}
.btn-login:active {
    transform: translateY(0);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

/* Messages */
.error-message {
    background: #fee2e2;
    color: #b91c1c;
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #fecaca;
    display: none;
}
.error-message.show {
    display: block;
    animation: shake 0.5s;
}
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-10px); }
    75% { transform: translateX(10px); }
}

.success-message {
    background: #dcfce7;
    color: #15803d;
    padding: 12px 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid #bbf7d0;
    display: none;
}
.success-message.show {
    display: block;
}

/* Login header (used in forgot password) */
.login-header {
    text-align: center;
    margin-bottom: 20px;
}
.login-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--pref-text, #090909);
    margin: 0 0 6px 0;
}
.login-header p {
    font-size: 0.9em;
    color: #666;
    margin: 0;
}

/* Form step title (forgot password) */
.form-step-title {
    text-align: center;
    margin-bottom: 20px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--pref-text, #333);
}
.otp-hint {
    text-align: center;
    margin-bottom: 15px;
    color: #666;
    font-size: 0.9em;
}

/* OTP input */
.input-otp {
    text-align: center !important;
    letter-spacing: 4px;
    font-size: 1.2em !important;
}

/* Link inside card (e.g. Resend OTP) */
.link-in-card {
    text-align: center;
    margin-top: 16px;
}
.link-in-card a {
    color: var(--pref-button, #00C7C8);
    text-decoration: none;
    font-size: 0.9em;
}
.link-in-card a:hover {
    text-decoration: underline;
}

/* Forgot password link below card, white color */
.back-link {
    text-align: center;
}
.back-link a {
    color: #ffffff;
    text-decoration: none;
    font-size: 0.9em;
    transition: color 0.3s ease;
    padding: 8px 12px;
    display: inline-block;
    min-height: 44px;
    line-height: 28px;
    -webkit-tap-highlight-color: transparent;
}
.back-link a:hover {
    color: #e0f2fe;
    text-decoration: underline;
}

/* Loading text */
.loading {
    display: none;
    text-align: center;
    color: #667eea;
    margin-top: 10px;
}
.loading.show {
    display: block;
}

/* =========================
   RESPONSIVE – Mobile & Tablet
   ========================= */
@media (max-width: 600px) {
    .login-page {
        padding: 0 16px;
    }

    .login-logo {
        margin-top: clamp(24px, 6vh, 48px);
        margin-bottom: clamp(16px, 4vh, 32px);
    }
    .login-logo img {
        max-width: min(320px, 85vw);
    }

    .login-container {
        padding: 20px 18px 24px;
    }

    .form-group input {
        padding: 12px 14px;
    }

    .btn-login {
        margin-top: 12px;
    }

    .back-link a {
        font-size: 0.88em;
    }

    .login-footer {
        font-size: 0.75rem;
        padding: 10px 12px;
    }
}

@media (max-width: 380px) {
    .login-logo img {
        max-width: 80vw;
    }
    .login-container {
        padding: 16px 14px 20px;
    }
}

/* Small height screens (landscape / short phones) */
@media (max-height: 500px) {
    .login-logo {
        margin-top: 16px;
        margin-bottom: 12px;
    }
    .login-logo img {
        max-height: 60px;
        object-fit: contain;
    }
}

/* =========================
   DARK THEME OVERRIDES
   (when preferences.ui.theme === 'dark')
   ========================= */
body.theme-dark {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--pref-background, #333333);
    min-height: 100vh;
    min-height: 100dvh;
    color: #ffffff;
    overflow-x: hidden;
}
body.theme-dark button {
    background: var(--pref-button, #8BD131);
    color: #4B5E32;
}
body.theme-dark .login-footer {
    background-color: var(--pref-background_hover, #444444);
    color: #cccccc;
}