/* ==========================================================================
   RFT Email Manager - interface styles
   Refined, professional utility aesthetic. Self-contained (CSP default-src
   'self'): system font stack, no external fonts/assets, no inline styles.
   ========================================================================== */

:root {
    /* Ink + text */
    --ink: #15212e;          /* headings */
    --text: #2b3a48;         /* body copy */
    --muted: #5e6e7e;        /* secondary text */
    --faint: #8c99a6;        /* tertiary / placeholders */

    /* Surfaces + lines */
    --bg: #eef2f7;
    --bg-tint: #e7edf4;
    --card: #ffffff;
    --line: #e3e9f0;
    --line-strong: #cfd9e4;

    /* Brand + states */
    --accent: #0e5ea8;
    --accent-strong: #0a4c89;
    --accent-soft: #e9f1fa;
    --ok: #1c7a45;
    --ok-soft: #e7f4ec;
    --warn: #8a6300;
    --warn-soft: #fbf1d8;
    --err: #bb352c;
    --err-soft: #fbeae8;

    /* Effects */
    --ring: 0 0 0 3px rgba(14, 94, 168, 0.28);
    --shadow-sm: 0 1px 2px rgba(21, 33, 46, 0.06), 0 1px 3px rgba(21, 33, 46, 0.05);
    --shadow-md: 0 4px 14px rgba(21, 33, 46, 0.08), 0 1px 3px rgba(21, 33, 46, 0.06);
    --radius: 12px;
    --radius-sm: 8px;
    --maxw: 880px;

    --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
    --mono: "SFMono-Regular", "Cascadia Code", Consolas, "Liberation Mono", Menlo, monospace;
}

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

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

body {
    margin: 0;
    font-family: var(--sans);
    font-size: 16px;
    line-height: 1.6;
    color: var(--text);
    background-color: var(--bg);
    background-image: linear-gradient(180deg, #f3f6fa 0%, var(--bg) 240px);
    background-repeat: no-repeat;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

::selection { background: var(--accent-soft); color: var(--accent-strong); }

:focus-visible { outline: none; box-shadow: var(--ring); border-radius: 4px; }

.wrap { width: 100%; max-width: var(--maxw); margin-inline: auto; padding-inline: 20px; }

/* --- Header ------------------------------------------------------------- */

.site-header {
    background: linear-gradient(180deg, #1b2a39 0%, #15212e 100%);
    color: #fff;
    border-bottom: 3px solid var(--accent);
    box-shadow: var(--shadow-sm);
}
.header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px 22px;
    padding-block: 14px;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    font-weight: 700;
    font-size: 1.02rem;
    letter-spacing: 0.01em;
    color: #fff;
}
.brand::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 0 4px rgba(14, 94, 168, 0.25);
}
.site-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 6px;
}
.site-nav a {
    color: #c7d6e4;
    text-decoration: none;
    font-size: 0.93rem;
    padding: 6px 10px;
    border-radius: 7px;
    transition: color 0.15s ease, background-color 0.15s ease;
}
.site-nav a:hover { color: #fff; background: rgba(255, 255, 255, 0.09); }
.site-nav .inline-form { margin-left: 6px; }
.linklike {
    font: inherit;
    font-size: 0.9rem;
    color: #cfe0ee;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.18);
    padding: 6px 12px;
    border-radius: 7px;
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.linklike:hover { background: rgba(255, 255, 255, 0.14); color: #fff; border-color: rgba(255, 255, 255, 0.32); }

/* --- Main + page rhythm ------------------------------------------------- */

main { display: block; padding-block: 36px 72px; }
main > h1:first-child { margin-top: 0; }

h1 { font-size: 1.55rem; line-height: 1.25; letter-spacing: -0.01em; font-weight: 700; color: var(--ink); margin: 0 0 8px; }
h2 { font-size: 1.12rem; line-height: 1.3; font-weight: 650; color: var(--ink); margin: 0 0 14px; }
p { margin: 0 0 12px; }
main > p.muted:first-of-type { margin-top: -2px; margin-bottom: 22px; }
a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-strong); text-decoration: underline; text-underline-offset: 2px; }
.muted { color: var(--muted); }
strong { color: var(--ink); }

/* --- Cards -------------------------------------------------------------- */

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 26px 28px;
    margin-bottom: 22px;
    box-shadow: var(--shadow-sm);
}
.card > *:last-child { margin-bottom: 0; }
.card h1 { margin-bottom: 14px; }

/* Narrow, centred cards (sign-in, single forms) */
.form-narrow {
    max-width: 460px;
    margin-inline: auto;
}

/* --- Forms -------------------------------------------------------------- */

label {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--ink);
    margin: 18px 0 6px;
}
label:first-of-type { margin-top: 4px; }

input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="date"], textarea, select {
    display: block;
    width: 100%;
    max-width: 440px;
    padding: 10px 12px;
    font: inherit;
    color: var(--text);
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
input::placeholder { color: var(--faint); }
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: var(--ring);
}
textarea { max-width: 100%; min-height: 140px; resize: vertical; line-height: 1.5; }
select { max-width: 240px; cursor: pointer; }

.field-row { display: flex; gap: 10px; align-items: flex-end; flex-wrap: wrap; }
.field-row input { margin-bottom: 0; }

/* --- Buttons ------------------------------------------------------------ */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
    padding: 10px 18px;
    font: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    line-height: 1.1;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line-strong);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease, transform 0.05s ease;
}
.btn:hover { background: var(--bg-tint); border-color: var(--line-strong); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:focus-visible { box-shadow: var(--ring); }

.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; box-shadow: 0 1px 2px rgba(10, 76, 137, 0.25); }
.btn-primary:hover { background: var(--accent-strong); border-color: var(--accent-strong); color: #fff; }

.btn-danger { background: var(--err); border-color: var(--err); color: #fff; }
.btn-danger:hover { background: #a52c24; border-color: #a52c24; color: #fff; }

/* Compact buttons inside table rows */
.row-actions .btn, td .btn { margin-top: 0; padding: 6px 13px; font-size: 0.88rem; }

.inline-form { display: inline; margin: 0; }

/* --- Tables ------------------------------------------------------------- */

table { width: 100%; border-collapse: collapse; margin: 4px 0 2px; }
thead th {
    text-align: left;
    font-size: 0.74rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: var(--muted);
    padding: 0 14px 10px;
    border-bottom: 1px solid var(--line-strong);
}
tbody td {
    padding: 14px;
    border-bottom: 1px solid var(--line);
    vertical-align: middle;
    color: var(--text);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr { transition: background-color 0.12s ease; }
tbody tr:hover td { background: #f7fafd; }
td:first-child, th:first-child { padding-left: 4px; }
td:last-child, th:last-child { padding-right: 4px; }

/* Row action clusters: keep links/buttons from crashing together */
.row-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 14px;
    white-space: nowrap;
}

/* --- Flash + inline errors --------------------------------------------- */

.flash {
    display: flex;
    gap: 10px;
    padding: 13px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 22px;
    border: 1px solid transparent;
    border-left-width: 4px;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}
.flash-success { background: var(--ok-soft); border-color: var(--ok); color: #145e34; }
.flash-warn { background: var(--warn-soft); border-color: var(--warn); color: #74540a; }
.flash-error { background: var(--err-soft); border-color: var(--err); color: #93271f; }
.error-text { color: var(--err); font-weight: 600; margin-bottom: 12px; }

/* --- Badges ------------------------------------------------------------- */

.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 11px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
    line-height: 1.5;
}
.badge::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-suspended { background: var(--err-soft); color: var(--err); }

/* --- Progress (storage bars) ------------------------------------------- */

progress {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 100%;
    max-width: 320px;
    height: 10px;
    border: none;
    border-radius: 999px;
    background: var(--bg-tint);
    overflow: hidden;
    vertical-align: middle;
}
progress::-webkit-progress-bar { background: var(--bg-tint); border-radius: 999px; }
progress::-webkit-progress-value { background: linear-gradient(90deg, var(--accent), #2f7ec2); border-radius: 999px; }
progress::-moz-progress-bar { background: var(--accent); border-radius: 999px; }

/* --- Callouts ----------------------------------------------------------- */

.callout {
    border: 1px solid var(--warn);
    border-left-width: 4px;
    background: var(--warn-soft);
    color: #5f4607;
    padding: 14px 16px;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    margin: 16px 0;
}
.callout > *:last-child { margin-bottom: 0; }
.callout-info { border-color: var(--accent); background: var(--accent-soft); color: #0a4576; }

/* --- Code + show-once secrets ------------------------------------------ */

code, .mono {
    font-family: var(--mono);
    font-size: 0.92em;
    background: var(--bg-tint);
    color: var(--ink);
    padding: 2px 6px;
    border-radius: 5px;
}
.show-once {
    display: block;
    font-size: 1.15rem;
    letter-spacing: 0.02em;
    padding: 14px 16px;
    background: var(--ink);
    color: #eaf2fb;
    border-radius: var(--radius-sm);
    user-select: all;
    word-break: break-all;
}

/* --- Footer ------------------------------------------------------------- */

.site-footer {
    border-top: 1px solid var(--line);
    color: var(--faint);
    font-size: 0.82rem;
}
.site-footer .wrap { padding-block: 22px; }

/* --- Responsive --------------------------------------------------------- */

@media (max-width: 640px) {
    body { font-size: 15.5px; }
    .header-row { flex-direction: column; align-items: flex-start; gap: 12px; }
    .site-nav { gap: 2px 4px; }
    .card { padding: 20px 18px; }
    main { padding-block: 26px 56px; }
    h1 { font-size: 1.38rem; }
    thead { display: none; }
    tbody, tbody tr, tbody td { display: block; width: 100%; }
    tbody tr { border: 1px solid var(--line); border-radius: var(--radius-sm); margin-bottom: 14px; padding: 6px 12px; box-shadow: var(--shadow-sm); }
    tbody td { border-bottom: 1px solid var(--line); padding: 10px 4px; }
    tbody tr td:last-child { border-bottom: none; }
}
