/* ==========================================================================
   assets/portal.css
   The ONE stylesheet for the whole portal. Link it from every page with:
     <link rel="stylesheet" href="/assets/portal.css?v=<?= (int)@filemtime($_SERVER['DOCUMENT_ROOT'] . '/assets/portal.css') ?>">
   (the ?v= part makes browsers pick up changes straight away)

   Fonts: Roboto Thin (headings) + Nunito Sans (text) load via the @import
   below. If a page already links Google Fonts in <head>, you can remove the
   @import and add these families to that link instead (slightly faster).

   Layout of this file:
     1. Theme variables (colours shared by every page; change the brand colour here)
     2. Shared bits (icon circle)
     3. 2FA page   (<body class="auth-page">)
     4. Login page (<body class="login-page">)
   Page styles are scoped under a class on <body> (e.g. .auth-page) so moving a
   page's CSS in here can never change how other pages look.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Nunito+Sans:wght@400;600;700&family=Roboto:wght@100;300&display=swap');


/* ==========================================================================
   1. THEME VARIABLES
   If header.php / other pages define these same variables, remove those copies
   once this file is linked there, so there is only one place to edit.
   ========================================================================== */
:root {
    --bg-base: #ffffff;          /* page background */
    --bg-surface: #ffffff;       /* cards */
    --bg-input: #f7f9fc;         /* form fields */
    --bg-hover: #eef3f9;
    --primary: #004F94;
    --primary-hover: #003b6f;
    --primary-soft: rgba(0, 79, 148, 0.12);   /* focus rings */
    --text-main: #1f2933;
    --text-muted: #6b7280;
    --border-color: #e3e8ef;

    --font-heading: 'Roboto', sans-serif;
    --font-body: 'Nunito Sans', sans-serif;

    --radius-card: 16px;
    --radius-field: 10px;
    --radius-pill: 999px;
    --shadow-card: 0 10px 30px rgba(0, 0, 0, 0.08);
    --shadow-icon: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
}


/* ==========================================================================
   2. SHARED BITS
   .icon-circle: put this class on any icon (<i class="... icon-circle">) to
   get the white circle. Icons inside .input-wrapper get it automatically.
   ========================================================================== */
.icon-circle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    background-color: #FFFFFF;
    padding: 0;                     /* even padding so the glyph sits dead centre */
    border-radius: 30px 30px 30px 30px;
    box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
    color: var(--primary);
    line-height: 1;
}
.icon-circle::before { line-height: 1; display: block; }


/* ==========================================================================
   3. 2FA PAGE  (<body class="auth-page">)
   Used by: 2fa.php
   ========================================================================== */
:where(.auth-page) * { margin: 0; padding: 0; box-sizing: border-box; font-family: var(--font-body); }

.auth-page {
    background-color: var(--bg-base); color: var(--text-main);
    display: flex; align-items: center; justify-content: center;
    min-height: 100vh; overflow: hidden; padding: 20px;
}

.auth-page .auth-container { width: 100%; max-width: 420px; position: relative; }
.auth-page .auth-card {
    background-color: var(--bg-surface); border: 1px solid var(--border-color);
    border-radius: var(--radius-card); padding: 40px; box-shadow: var(--shadow-card);
    text-align: center;
}
.auth-page .auth-logo { margin-bottom: 32px; }
.auth-page .auth-logo img { max-height: 52px; }

.auth-page .auth-header h2 {
    font-family: var(--font-heading); font-weight: 100;
    font-size: 1.9rem; letter-spacing: 0.3px; margin-bottom: 8px; color: var(--text-main);
}
.auth-page .auth-header p { color: var(--text-muted); font-size: 0.95rem; line-height: 1.6; margin-bottom: 24px; }

.auth-page .alert-error {
    color: #c62828; background-color: #fdecec; padding: 10px 14px;
    border-radius: var(--radius-field); font-size: 0.875rem; margin-bottom: 20px;
    border: 1px solid #f5c2c2;
}

/* 2FA: QR code + manual key */
.auth-page .qr-wrapper {
    background: #ffffff; padding: 16px; border-radius: 12px;
    display: inline-block; margin-bottom: 16px;
    border: 1px solid var(--border-color); box-shadow: var(--shadow-icon);
}
.auth-page .qr-wrapper img { display: block; border-radius: 4px; }
.auth-page .qr-fallback { display: none; color: var(--text-muted); font-size: 0.85rem; margin-bottom: 12px; }

.auth-page .secret-key {
    font-family: monospace; letter-spacing: 2px; color: var(--primary);
    font-size: 1.1rem; margin-bottom: 24px; font-weight: 600;
}
.auth-page .app-link { margin: -12px 0 20px; }
.auth-page .app-link a { color: var(--primary); font-size: 0.875rem; font-weight: 600; }

.auth-page .form-group { margin-bottom: 24px; }

.auth-page .code-input {
    width: 100%; background-color: var(--bg-input); border: 1px solid var(--border-color);
    color: var(--text-main); padding: 16px; border-radius: var(--radius-field);
    font-size: 1.5rem; outline: none; transition: all 0.2s;
    text-align: center; letter-spacing: 8px; font-weight: 600;
}
.auth-page .code-input:focus { background-color: #ffffff; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.auth-page .code-input::placeholder { color: #c7ced8; letter-spacing: 8px; }

.auth-page .btn-primary {
    background-color: var(--primary); color: #ffffff; border: none;
    width: 100%; padding: 14px 24px; border-radius: var(--radius-pill); font-weight: 700;
    font-size: 0.95rem; cursor: pointer; transition: all 0.2s ease;
    display: flex; align-items: center; justify-content: center; gap: 8px;
}
.auth-page .btn-primary:hover { background-color: var(--primary-hover); }

@media (max-width: 480px) {
    .auth-page .auth-card { padding: 32px 24px; border: none; box-shadow: none; }
    .auth-page { padding: 10px; align-items: flex-start; padding-top: 10vh; }
}


/* ==========================================================================
   4. LOGIN PAGE  (<body class="login-page">)
   Used by: login.php (sign in + forgot password)
   ========================================================================== */
:where(.login-page) * { margin: 0; padding: 0; box-sizing: border-box; font-family: var(--font-body); }

.login-page {
    background-color: var(--bg-base);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    overflow: hidden;
    padding: 20px;
}

/* Container & card */
.login-page .auth-container { width: 100%; max-width: 420px; position: relative; }
.login-page .auth-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-card);
    padding: 40px;
    box-shadow: var(--shadow-card);
    position: relative;
    overflow: hidden;
}
.login-page .auth-logo { text-align: center; margin-bottom: 32px; }
.login-page .auth-logo img { max-height: 52px; }

/* View states (sign in <-> forgot password) */
.login-page .auth-view { display: none; opacity: 0; transform: translateX(20px); transition: all 0.3s ease; }
.login-page .auth-view.active { display: block; opacity: 1; transform: translateX(0); }
.login-page .auth-view.slide-left { transform: translateX(-20px); }

/* Typography */
.login-page .auth-header { text-align: center; margin-bottom: 32px; }
.login-page .auth-header h2 {
    font-family: var(--font-heading);
    font-weight: 100;
    font-size: 2rem;
    letter-spacing: 0.3px;
    margin-bottom: 8px;
    color: var(--text-main);
}
.login-page .auth-header p { color: var(--text-muted); font-size: 0.95rem; line-height: 1.6; }

.login-page .alert-error {
    background: #fdecec;
    color: #c62828;
    border: 1px solid #f5c2c2;
    padding: 12px;
    border-radius: var(--radius-field);
    margin-bottom: 20px;
    font-size: 0.9rem;
    text-align: center;
}
.login-page .alert-success {
    background: #e8f6ef;
    color: #1e7b4f;
    border: 1px solid #bfe5d1;
    padding: 12px;
    border-radius: var(--radius-field);
    margin-bottom: 20px;
    font-size: 0.9rem;
    text-align: center;
}

/* Form elements */
.login-page .form-group { margin-bottom: 20px; position: relative; }
.login-page .form-group label { display: block; font-size: 0.85rem; font-weight: 700; color: var(--text-main); margin-bottom: 8px; }
.login-page .input-wrapper { position: relative; }

/* Icon inside the field, on the white circle */
.login-page .input-wrapper i {
    position: absolute;
    left: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background-color: #FFFFFF;
    padding: 0;                     /* even padding so the glyph sits dead centre */
    border-radius: 30px 30px 30px 30px;
    box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.1);
    color: var(--text-muted);
    font-size: 0.9rem;
    line-height: 1;
    text-align: center;
    transition: color 0.2s;
    pointer-events: none;
}
.login-page .input-wrapper i::before { line-height: 1; display: block; }
.login-page .form-control {
    width: 100%;
    background-color: var(--bg-input);
    border: 1px solid var(--border-color);
    color: var(--text-main);
    padding: 13px 16px 13px 50px; /* extra left padding for the icon circle */
    border-radius: var(--radius-field);
    font-size: 16px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.2s;
}
.login-page .form-control::placeholder { color: #9aa3af; }
.login-page .form-control:focus { background-color: #ffffff; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-soft); }
.login-page .form-control:focus + i,
.login-page .input-wrapper:focus-within i { color: var(--primary); }

/* Links & buttons */
.login-page .auth-options { display: flex; justify-content: flex-end; margin-bottom: 24px; margin-top: -8px; }
.login-page .text-link { color: var(--primary); text-decoration: none; font-size: 0.875rem; font-weight: 600; transition: color 0.2s; cursor: pointer; }
.login-page .text-link:hover { color: var(--primary-hover); text-decoration: underline; }

.login-page .btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 13px 24px;
    border-radius: var(--radius-pill);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
}
.login-page .btn-primary { background-color: var(--primary); color: #ffffff; margin-bottom: 16px; }
.login-page .btn-primary:hover { background-color: var(--primary-hover); }
.login-page .btn-secondary { background-color: transparent; color: var(--primary); border: 1px solid var(--primary); }
.login-page .btn-secondary:hover { background-color: var(--bg-hover); color: var(--primary-hover); }

/* Phones */
@media (max-width: 480px) {
    .login-page .auth-card { padding: 32px 24px; border: none; box-shadow: none; }
    .login-page { padding: 10px; align-items: flex-start; padding-top: 10vh; }
}