/* =========================================================
   Common style for all pages of the password change interface
   (index.php, profile.php, success.php, error.php)
   ========================================================= */

/* ---------- Colours (change them here only) ---------- */
:root {
    --bg: #eef2f7;
    --card: #ffffff;
    --text: #1f2937;
    --muted: #64748b;
    --border: #d5dbe3;
    --input-bg: #ffffff;

    --primary: #1d4e89;
    --primary-hover: #163d6c;
    --ring: rgba(29, 78, 137, 0.25);
    --link: #1d4e89;

    --danger: #c0352b;
    --danger-hover: #9e2a22;

    --info-bg: #eef5ff;      --info-border: #c7dbfb;    --info-text: #1e3a8a;
    --error-bg: #fdf0ef;     --error-border: #f6c9c4;   --error-text: #9e2a22;
    --success-bg: #edf9f1;   --success-border: #b7e5c6; --success-text: #17663a;

    --radius: 14px;
    --shadow: 0 12px 32px rgba(15, 23, 42, 0.08), 0 2px 6px rgba(15, 23, 42, 0.05);
}

/* Dark colours when the computer is in dark mode */
@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0f172a;
        --card: #182235;
        --text: #e5e9f0;
        --muted: #94a3b8;
        --border: #334155;
        --input-bg: #0f172a;

        --primary: #3b78c4;
        --primary-hover: #4f8ad3;
        --ring: rgba(96, 150, 220, 0.35);
        --link: #8fb8ea;

        --info-bg: #172a4a;      --info-border: #27467a;    --info-text: #c7dbfb;
        --error-bg: #3a1d1d;     --error-border: #6b2b27;   --error-text: #f6c9c4;
        --success-bg: #15321f;   --success-border: #22603a; --success-text: #b7e5c6;
    }
}

/* ---------- Colour themes ----------
   session.php picks one of these at random on every page load and puts it on
   the <html> tag, e.g. <html data-theme="teal">. "blue" is the default above.
   To add a theme: copy one block below, change the colours, and add its
   name to the $themes list in session.php. */
html[data-theme="teal"] {
    --primary: #0f766e;   --primary-hover: #0b5d56;
    --ring: rgba(15, 118, 110, 0.25);
    --link: #0f766e;      --bg: #ecf5f3;
}
html[data-theme="indigo"] {
    --primary: #4338ca;   --primary-hover: #3730a3;
    --ring: rgba(67, 56, 202, 0.25);
    --link: #4338ca;      --bg: #f0f0fa;
}
html[data-theme="plum"] {
    --primary: #86198f;   --primary-hover: #6b1373;
    --ring: rgba(134, 25, 143, 0.25);
    --link: #86198f;      --bg: #f7eff7;
}
html[data-theme="saffron"] {
    /* real saffron (#FF9933) is too light for white text, this is the closest readable shade */
    --primary: #c05600;   --primary-hover: #a34900;
    --ring: rgba(192, 86, 0, 0.25);
    --link: #a34900;      --bg: #fbf3ea;
}
html[data-theme="crimson"] {
    --primary: #b32332;   --primary-hover: #921c29;
    --ring: rgba(179, 35, 50, 0.25);
    --link: #b32332;      --bg: #f9eff0;
    /* the red Logout button would look like the main button, so use grey here */
    --danger: #475569;    --danger-hover: #334155;
}

/* the same themes in dark mode */
@media (prefers-color-scheme: dark) {
    html[data-theme="teal"] {
        --primary: #0f7c73;   --primary-hover: #0e857c;
        --ring: rgba(45, 190, 175, 0.35);
        --link: #5fd3c7;      --bg: #0d1a1a;
    }
    html[data-theme="indigo"] {
        --primary: #4f46e5;   --primary-hover: #6058ec;
        --ring: rgba(140, 130, 255, 0.35);
        --link: #a5a1ff;      --bg: #13132a;
    }
    html[data-theme="plum"] {
        --primary: #9d2aa6;   --primary-hover: #b03bb9;
        --ring: rgba(220, 130, 230, 0.35);
        --link: #e39be9;      --bg: #1c1020;
    }
    html[data-theme="saffron"] {
        --primary: #b35000;   --primary-hover: #c05600;
        --ring: rgba(255, 170, 90, 0.35);
        --link: #ffb066;      --bg: #1c140c;
    }
    html[data-theme="crimson"] {
        --primary: #c02a3a;   --primary-hover: #cc3344;
        --ring: rgba(255, 130, 145, 0.35);
        --link: #ff8f9b;      --bg: #1e1012;
        --danger: #475569;    --danger-hover: #536379;
    }
}

/* ---------- Basic page ---------- */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
}

h2 {
    font-size: 1.05rem;
    margin: 0 0 10px;
}

a {
    color: var(--link);
}

.center { text-align: center; }
.hidden { display: none !important; }

/* Centre the card on the screen */
.page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

/* ---------- Card ---------- */
.card {
    width: 100%;
    max-width: 440px;
    background: var(--card);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-wide {
    max-width: 860px;
}

.card-header {
    background: var(--primary);
    color: #ffffff;
    padding: 20px 24px;
}

.card-header h1 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 650;
}

.card-header p {
    margin: 4px 0 0;
    font-size: 0.9rem;
    opacity: 0.85;
}

/* header with a button on the right (profile page) */
.card-header.with-action {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.card-body {
    padding: 24px;
}

.card-footer {
    padding: 14px 24px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 0.875rem;
    color: var(--muted);
}

/* ---------- Form ---------- */
.field {
    margin-bottom: 18px;
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.92rem;
}

input[type="text"],
input[type="password"] {
    width: 100%;
    padding: 11px 12px;
    font-size: 1rem;
    color: var(--text);
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    transition: border-color 0.15s, box-shadow 0.15s;
}

input[type="text"]:focus,
input[type="password"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--ring);
}

/* "Show password" checkbox line */
label.check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 8px 0 0;
    font-weight: 400;
    font-size: 0.88rem;
    color: var(--muted);
    cursor: pointer;
}

label.check input {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: var(--primary);
}

.hint {
    margin: 6px 0 0;
    min-height: 1.2em;
    font-size: 0.85rem;
}

.hint.ok  { color: var(--success-text); }
.hint.bad { color: var(--error-text); }

/* ---------- Captcha ---------- */
.captcha {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 10px;
}

.captcha img {
    display: block;
    max-width: 100%;
    height: auto;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
}

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 10px 20px;
    font: inherit;
    font-weight: 600;
    color: #ffffff;
    text-decoration: none;
    background: var(--primary);
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
}

.btn:hover  { background: var(--primary-hover); }
.btn:active { transform: scale(0.98); }
.btn:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px var(--ring);
}

.btn-block { width: 100%; }

.btn-small {
    min-height: 36px;
    padding: 6px 14px;
    font-size: 0.88rem;
}

.btn-secondary {
    color: var(--text);
    background: transparent;
    border-color: var(--border);
}
.btn-secondary:hover { background: var(--bg); }

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

/* white outline button, used on the blue header */
.btn-light {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.45);
    white-space: nowrap;
}
.btn-light:hover { background: rgba(255, 255, 255, 0.25); }

.actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 20px;
}

.actions .btn {
    flex: 1 1 140px;
}

/* ---------- Messages ---------- */
.alert {
    margin-bottom: 20px;
    padding: 12px 14px;
    font-size: 0.95rem;
    border: 1px solid;
    border-radius: 8px;
}

.alert-info    { background: var(--info-bg);    border-color: var(--info-border);    color: var(--info-text); }
.alert-error   { background: var(--error-bg);   border-color: var(--error-border);   color: var(--error-text); }
.alert-success { background: var(--success-bg); border-color: var(--success-border); color: var(--success-text); }

/* round icon on the success / error pages */
.status-icon {
    width: 56px;
    height: 56px;
    margin: 4px auto 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: 700;
    border-radius: 50%;
}

.status-error   { background: var(--error-bg);   color: var(--error-text); }
.status-success { background: var(--success-bg); color: var(--success-text); }

/* ---------- Profile page: notes on the left, form on the right ---------- */
.columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
}

.notes h2 + ul {
    margin-bottom: 22px;
}

.notes ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.notes li {
    position: relative;
    padding: 3px 0 3px 26px;
    font-size: 0.92rem;
}

.notes-list li {
    color: var(--muted);
}

.notes-list li::before {
    content: "\2022";               /* bullet */
    position: absolute;
    left: 8px;
}

/* password rules: grey circle, becomes a green tick when the rule is met */
.rules li::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 7px;
    width: 14px;
    height: 14px;
    border: 2px solid var(--border);
    border-radius: 50%;
}

.rules li.ok {
    color: var(--success-text);
}

.rules li.ok::before {
    content: "\2713";               /* tick */
    top: 4px;
    width: auto;
    height: auto;
    border: none;
    font-weight: 700;
}

/* ---------- Small screens (phones) ---------- */
@media (max-width: 720px) {
    .columns {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    /* show the form first, the notes after it */
    .columns form  { order: 1; }
    .columns .notes { order: 2; padding-top: 16px; border-top: 1px solid var(--border); }
}

@media (max-width: 480px) {
    .page {
        padding: 16px 12px;
        align-items: flex-start;
    }

    .card-header,
    .card-body {
        padding: 18px 16px;
    }

    .card-header.with-action {
        align-items: flex-start;
    }
}
