/* Shared styles for login / register / home pages */
:root {
    --ink: #17201d;
    --muted: #68736f;
    --green: #126b53;
    --green-dark: #0c4e3e;
    --mint: #dff5e9;
    --lime: #c9ef73;
    --cream: #f8f8f3;
    --white: #ffffff;
    --line: #e8ebe6;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    color: var(--ink);
    background: var(--cream);
    font-family: "DM Sans", sans-serif;
    min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ---------- Auth pages (login / register) ---------- */
.auth-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 16px 40px;
}

/* Header bar bleeds to the page edges; the card stays centered below it */
.auth-page > header {
    align-self: stretch;
    margin: 0 -16px 40px;
}
.auth-page > .auth-card {
    margin-top: auto;
    margin-bottom: auto;
}

/* Footer bar bleeds to the page edges and sits at the bottom */
.auth-page > footer {
    align-self: stretch;
    margin: 40px -16px -40px;
}

.auth-card {
    width: 100%;
    max-width: 520px;
    padding: 40px;
    background: var(--white);
    border-radius: 18px;
    box-shadow: 0 20px 55px rgba(19, 43, 34, 0.12);
}

.auth-card--narrow { max-width: 420px; }

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    margin-bottom: 24px;
    font-family: "Plus Jakarta Sans", sans-serif;
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.8px;
}

.logo-mark {
    display: grid;
    width: 34px;
    margin-right: 9px;
    height: 34px;
    place-items: center;
    background: var(--green);
    border-radius: 10px;
}

.logo-mark svg {
    display: block;
    width: 20px;
    height: 20px;
}

.logo span { color: var(--green); }

h1 {
    margin-bottom: 8px;
    font-family: "Plus Jakarta Sans", sans-serif;
    font-size: 26px;
    text-align: center;
    letter-spacing: -1px;
}

.subtitle {
    margin-bottom: 24px;
    color: var(--muted);
    font-size: 14px;
    text-align: center;
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

label {
    display: block;
    margin-bottom: 6px;
    color: #555;
    font-size: 13px;
    font-weight: 600;
}

input,
.auth-card select {
    width: 100%;
    padding: 11px 13px;
    border: 1px solid var(--line);
    border-radius: 10px;
    font: inherit;
    font-size: 14px;
    transition: border-color 0.2s;
    background: var(--white);
}

input:focus,
.auth-card select:focus { outline: none; border-color: var(--green); }

.btn {
    width: 100%;
    padding: 13px;
    border: 0;
    color: var(--white);
    background: var(--green);
    border-radius: 11px;
    cursor: pointer;
    font: inherit;
    font-size: 15px;
    font-weight: 700;
    transition: 0.2s ease;
}

.btn:hover { background: var(--green-dark); transform: translateY(-2px); }

.btn-outline {
    width: auto;
    padding: 11px 18px;
    color: var(--green);
    background: transparent;
    border: 2px solid var(--green);
    font-size: 14px;
}

.btn-outline:hover { color: var(--white); background: var(--green); transform: none; }

.error {
    margin-top: 4px;
    color: #c0392b;
    font-size: 12px;
}

.alert {
    margin-bottom: 18px;
    padding: 11px 14px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
}

.alert-success { background: var(--mint); color: var(--green-dark); }
.alert-error { background: #fbe4e1; color: #a63a2e; }

.links {
    margin-top: 18px;
    color: var(--muted);
    font-size: 13px;
    text-align: center;
}

.links a { color: var(--green); font-weight: 600; }
.links a:hover { text-decoration: underline; }

/* ---------- App pages (home / authenticated layout) ---------- */
.app-page {
    display: flex;
    flex-direction: column;
}

.container { width: min(1160px, calc(100% - 40px)); margin: 0 auto; }

header { background: #103c32; border-bottom: 1px solid rgba(255,255,255,0.08); }

/* Header logo matches the footer treatment — white word, lime "Or" */
header .logo { color: var(--white); }
header .logo span { color: var(--lime); }

/* Text and actions readable on the dark header */
header .welcome { color: rgba(255,255,255,0.72); }
header .welcome:hover { color: var(--lime); }
header .btn-link { color: rgba(255,255,255,0.72); }
header .btn-outline { color: var(--lime); border-color: var(--lime); }
header .btn-outline:hover { color: var(--ink); background: var(--lime); }
header .btn { background: var(--lime); color: var(--ink); }
header .btn:hover { background: #d9fb95; }

.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 82px;
}

.app-page .logo { margin-bottom: 0; }

.nav-actions { display: flex; align-items: center; gap: 12px; }

.nav-actions .btn,
.nav-actions .btn-outline,
.nav-actions .btn-link {
    width: auto;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.welcome {
    display: inline-block;
    max-width: 220px;
    overflow: hidden;
    color: var(--muted);
    font-size: 14px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

main { flex: 1; padding: 60px 0; }

.app-alert {
    margin-bottom: 24px;
    padding: 14px 18px;
    background: var(--mint);
    color: var(--green-dark);
    border-radius: 12px;
    font-size: 14px;
    font-weight: 600;
}

.card {
    padding: 44px;
    background: var(--white);
    border-radius: 18px;
    box-shadow: 0 20px 55px rgba(19, 43, 34, 0.12);
    text-align: center;
}

.card h1 {
    margin-bottom: 12px;
    font-size: 32px;
    letter-spacing: -1.2px;
}

.card p { color: var(--muted); font-size: 15px; }

footer {
    padding: 24px 0;
    color: #7c8580;
    background: #103c32;
    font-size: 13px;
    text-align: center;
}

/* ---------- Side-rail ads (login / register) ----------
   Only shown when the viewport has room for 160px gutters. */
.ad-rail {
    display: none;
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 160px;
    z-index: 5;
}

@media (min-width: 1500px) {
    .ad-rail {
        display: block;
        /* Temporary placeholder so the rail footprint is visible
           until real AdSense slot IDs are configured */
        background: var(--white);
        border: 1px dashed var(--line);
        border-radius: 12px;
    }
    .ad-rail-left { left: calc((100vw - 1160px) / 4 - 80px); }
    .ad-rail-right { right: calc((100vw - 1160px) / 4 - 80px); }
}

@media (max-width: 640px) {
    /* Header: wrap nav actions, hide long email, compact buttons */
    .nav { flex-wrap: wrap; gap: 10px; min-height: 64px; padding: 10px 0; }
    /* Actions stay on one line under the logo; scroll only if still too wide */
    .nav-actions {
        flex-basis: 100%;
        flex-wrap: nowrap;
        gap: 6px;
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 4px;
        scrollbar-width: none;
    }
    .nav-actions::-webkit-scrollbar { display: none; }
    .nav-actions .btn,
    .nav-actions .btn-outline { width: auto; padding: 8px 11px; font-size: 12px; }
    .nav-actions .btn-link { font-size: 12px; }
    .nav-actions .msg-badge { font-size: 10px; }
    .welcome { display: none; }

    main { padding: 36px 0; }
    .card { padding: 28px 20px; }
    .card h1 { font-size: 26px; }

    /* Prevent iOS auto-zoom on input focus (needs >=16px) */
    input,
    .auth-card select { font-size: 16px; }
}

@media (max-width: 540px) {
    .auth-card { padding: 26px 20px; }
    .form-row { grid-template-columns: 1fr; gap: 0; }
}
