/* ICKSP Admin — brand-aligned with public icksp.ie site */

:root {
    --burgundy:       #8c0e21;
    --burgundy-dark:  #6b0a19;
    --burgundy-light: #a8122a;
    --gold:           #c9a227;
    --gold-dark:      #a8871f;
    --gold-light:     #e0be48;
    --cream:          #fcf3e3;
    --cream-dark:     #f5e8d0;
    --blue:           #1D214D;
    --blue-deep:      #111430;
    --slate-dark:     #1a1410;
    --text:           #2d2218;
    --text-muted:     #6b5e52;
    --border:         #e8dcc8;
    --white:          #fff;

    --ff-heading: 'EB Garamond', Garamond, Georgia, serif;
    --ff-body:    'Source Sans 3', -apple-system, 'Segoe UI', Roboto, sans-serif;

    --radius:      8px;
    --radius-lg:   14px;
    --radius-full: 9999px;
    --shadow:      0 4px 20px rgba(45,34,24,.08);
    --shadow-lg:   0 12px 40px rgba(45,34,24,.15);
    --transition:  0.2s cubic-bezier(.22,1,.36,1);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
    font-family: var(--ff-body);
    color: var(--text);
    background: var(--cream);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Loading state */
#app.app-loading {
    display: grid;
    place-items: center;
    min-height: 100vh;
}
.loader { text-align: center; }
.loader img { opacity: .8; animation: pulse 1.4s ease-in-out infinite; }
.loader p { color: var(--text-muted); margin: .75rem 0 0; font-size: .9rem; }
@keyframes pulse { 0%,100% { opacity: .5; } 50% { opacity: 1; } }

/* Layout */
.app-layout {
    display: grid;
    grid-template-rows: auto 1fr;
    min-height: 100vh;
}
.topbar {
    background: var(--burgundy);
    color: var(--white);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    min-height: 64px;
    box-shadow: 0 2px 12px rgba(0,0,0,.08);
    position: sticky;
    top: 0;
    z-index: 100;
}
.topbar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    text-decoration: none;
    color: inherit;
    font-family: var(--ff-heading);
    font-size: 1.1rem;
    font-weight: 500;
}
.topbar-brand img { height: 40px; width: auto; }
.topbar-region {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: rgba(255,255,255,.12);
    padding: .4em 1em;
    border-radius: var(--radius-full);
    font-size: .88rem;
    font-weight: 500;
    border: 1px solid rgba(255,255,255,.15);
    cursor: pointer;
    color: inherit;
}
.topbar-region:hover { background: rgba(255,255,255,.2); }
.topbar-region .chevron { opacity: .7; transition: transform var(--transition); }
.topbar-region[aria-expanded="true"] .chevron { transform: rotate(180deg); }
.topbar-user {
    display: flex;
    align-items: center;
    gap: .6rem;
    font-size: .88rem;
    position: relative;
}
.topbar-user-btn {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    padding: .4em .8em;
    border-radius: var(--radius);
    font: inherit;
    transition: background var(--transition);
}
.topbar-user-btn:hover { background: rgba(255,255,255,.12); }
.topbar-dropdown {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    background: var(--white);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: .5rem;
    min-width: 240px;
    display: none;
}
.topbar-dropdown.open { display: block; }
.topbar-dropdown a, .topbar-dropdown button {
    display: block;
    width: 100%;
    padding: .55em .9em;
    border: none;
    background: transparent;
    text-align: left;
    color: var(--text);
    text-decoration: none;
    border-radius: var(--radius);
    font: inherit;
    font-size: .9rem;
    cursor: pointer;
}
.topbar-dropdown a:hover, .topbar-dropdown button:hover { background: var(--cream); }

/* Main content */
.main {
    padding: 2rem 1.5rem 3rem;
    max-width: 1100px;
    margin: 0 auto;
    width: 100%;
}
.page-header {
    margin-bottom: 2rem;
}
.page-header h1 {
    font-family: var(--ff-heading);
    font-weight: 500;
    margin: 0 0 .25rem;
    color: var(--burgundy);
    font-size: 2.4rem;
    line-height: 1.2;
}
.page-header p {
    margin: 0;
    color: var(--text-muted);
    font-size: 1.05rem;
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    border: 1px solid var(--border);
}
.card + .card { margin-top: 1rem; }
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    gap: 1rem;
}
.card-header h2 {
    font-family: var(--ff-heading);
    font-size: 1.4rem;
    margin: 0;
    color: var(--burgundy);
    font-weight: 500;
}

/* Grid */
.grid-2 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.grid-3 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* Region picker cards */
.region-grid {
    display: grid;
    gap: 1.5rem;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    margin-top: 2rem;
}
.region-card {
    background: var(--white);
    border: 2px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2rem 1.5rem;
    text-align: center;
    text-decoration: none;
    color: var(--text);
    transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition);
    box-shadow: var(--shadow);
    position: relative;
    min-height: 200px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: .5rem;
    cursor: pointer;
}
.region-card:hover:not(.region-card--locked) {
    transform: translateY(-2px);
    border-color: var(--burgundy);
    box-shadow: var(--shadow-lg);
}
.region-card h3 {
    font-family: var(--ff-heading);
    font-size: 1.8rem;
    margin: 0;
    color: var(--burgundy);
    font-weight: 500;
}
.region-card .domain {
    color: var(--text-muted);
    font-size: .85rem;
    letter-spacing: .05em;
}
.region-card .role-badge {
    display: inline-block;
    background: var(--gold);
    color: var(--slate-dark);
    padding: .25em .75em;
    border-radius: var(--radius-full);
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
    margin-top: .5rem;
}
.region-card--locked {
    opacity: .45;
    cursor: not-allowed;
    background: var(--cream-dark);
}
.region-card--locked .lock-icon {
    font-size: 2rem;
    color: var(--text-muted);
}

/* Forms / inputs */
label { display: block; font-weight: 500; font-size: .9rem; margin-bottom: .3rem; color: var(--text); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"],
textarea, select {
    width: 100%;
    padding: .7em 1em;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font: inherit;
    font-size: .95rem;
    background: var(--white);
    color: var(--text);
    transition: border-color var(--transition), box-shadow var(--transition);
}
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: var(--burgundy);
    box-shadow: 0 0 0 3px rgba(140,14,33,.1);
}
textarea { min-height: 160px; resize: vertical; font-family: var(--ff-body); }
.field { margin-bottom: 1.2rem; }
.field-hint { color: var(--text-muted); font-size: .82rem; margin-top: .3rem; }
.field-error { color: var(--burgundy); font-size: .85rem; margin-top: .3rem; }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4em;
    padding: .6em 1.3em;
    border-radius: var(--radius);
    border: 1px solid transparent;
    font: inherit;
    font-size: .95rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: transform var(--transition), background var(--transition), box-shadow var(--transition);
    background: var(--cream);
    color: var(--text);
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--burgundy); color: var(--white); }
.btn-primary:hover { background: var(--burgundy-dark); }
.btn-secondary { background: var(--white); color: var(--burgundy); border-color: var(--burgundy); }
.btn-secondary:hover { background: var(--burgundy); color: var(--white); }
.btn-ghost { background: transparent; color: var(--text-muted); padding: .4em .8em; }
.btn-ghost:hover { color: var(--burgundy); background: var(--cream); }
.btn-danger { background: #c0392b; color: var(--white); }
.btn-danger:hover { background: #992d21; }

/* Login page */
.login-page {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, var(--cream) 0%, var(--cream-dark) 100%);
}
.login-card {
    max-width: 440px;
    width: 100%;
    background: var(--white);
    padding: 3rem 2.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    border-top: 4px solid var(--burgundy);
}
.login-card .brand {
    text-align: center;
    margin-bottom: 2rem;
}
.login-card .brand img { width: 64px; height: auto; margin-bottom: .75rem; }
.login-card .brand h1 {
    font-family: var(--ff-heading);
    font-size: 1.7rem;
    font-weight: 500;
    margin: 0;
    color: var(--burgundy);
}
.login-card .brand p { margin: .25rem 0 0; color: var(--text-muted); font-size: .88rem; }
.login-card .submit-row { margin-top: 1.5rem; }
.login-card .btn-primary { width: 100%; justify-content: center; padding: .8em; font-size: 1rem; }
.login-card .link { text-align: center; margin-top: 1rem; font-size: .9rem; }
.login-card .link a { color: var(--burgundy); text-decoration: none; }
.login-card .link a:hover { text-decoration: underline; }
.captcha-row { display: flex; align-items: center; gap: 1rem; margin-top: 1rem; padding: 1rem; background: var(--cream); border-radius: var(--radius); }
.captcha-row .q { font-weight: 600; }
.captcha-row input { flex: 1; max-width: 90px; }

/* Message banner */
.msg { padding: .9rem 1.2rem; border-radius: var(--radius); margin: 1rem 0; font-size: .92rem; }
.msg-info  { background: #eef4f8; color: #1D214D; }
.msg-error { background: #fde8e8; color: #992d21; }
.msg-ok    { background: #ebf5ef; color: #1B3D26; }

/* Data table */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th, .data-table td { padding: .8rem 1rem; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.data-table th { background: var(--cream); font-weight: 600; font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-muted); }
.data-table tr:hover { background: var(--cream); }
.data-table .actions { text-align: right; white-space: nowrap; }

/* Tiles / stats */
.stat {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}
.stat-label { color: var(--text-muted); font-size: .85rem; text-transform: uppercase; letter-spacing: .05em; font-weight: 600; }
.stat-value { font-family: var(--ff-heading); font-size: 2.4rem; color: var(--burgundy); margin: .25rem 0 0; font-weight: 500; line-height: 1; }
.stat-sub { color: var(--text-muted); font-size: .85rem; margin-top: .25rem; }

/* Empty state */
.empty {
    padding: 3rem 1.5rem;
    text-align: center;
    color: var(--text-muted);
}
.empty h3 { font-family: var(--ff-heading); color: var(--burgundy); font-weight: 500; }

/* Misc */
a { color: var(--burgundy); }
a:hover { color: var(--burgundy-dark); }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.text-muted { color: var(--text-muted); }
.text-danger { color: #c0392b; }
.mt-2 { margin-top: 2rem; }
.flex { display: flex; gap: 1rem; align-items: center; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.tag { display: inline-block; padding: .2em .7em; border-radius: var(--radius-full); background: var(--cream-dark); font-size: .75rem; font-weight: 600; }
.tag-published { background: #d5ead8; color: #1B3D26; }
.tag-draft { background: var(--cream-dark); color: var(--text-muted); }

/* Mobile */
@media (max-width: 640px) {
    .topbar { padding: 0 1rem; min-height: 56px; }
    .topbar-brand img { height: 32px; }
    .topbar-brand { font-size: .95rem; }
    .main { padding: 1.25rem 1rem 2rem; }
    .page-header h1 { font-size: 1.8rem; }
    .login-card { padding: 2rem 1.5rem; }
}

/* ── Sidebar layout (when inside a region) ───────────────── */
.app-layout--with-sidebar {
    grid-template-columns: 220px 1fr;
    grid-template-rows: auto 1fr;
    grid-template-areas:
        "topbar topbar"
        "sidebar main";
}
.app-layout--with-sidebar .topbar { grid-area: topbar; }
.app-layout--with-sidebar .sidebar {
    grid-area: sidebar;
    background: var(--white);
    border-right: 1px solid var(--border);
    padding: 1.5rem 0.75rem;
    min-height: calc(100vh - 64px);
}
.app-layout--with-sidebar .main {
    grid-area: main;
    max-width: 100%;
    margin: 0;
    padding: 2rem;
}
.sidebar-nav { display: flex; flex-direction: column; gap: .2rem; }
.sidebar-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .7rem 1rem;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--text);
    font-weight: 500;
    font-size: .94rem;
    transition: background var(--transition), color var(--transition);
}
.sidebar-link:hover { background: var(--cream); color: var(--burgundy); }
.sidebar-link svg { opacity: .65; flex-shrink: 0; }
.sidebar-link--active {
    background: var(--burgundy);
    color: var(--white);
}
.sidebar-link--active:hover { background: var(--burgundy-dark); color: var(--white); }
.sidebar-link--active svg { opacity: 1; }

/* Mobile: sidebar collapses */
@media (max-width: 768px) {
    .app-layout--with-sidebar {
        grid-template-columns: 1fr;
        grid-template-areas:
            "topbar"
            "sidebar"
            "main";
    }
    .app-layout--with-sidebar .sidebar {
        min-height: auto;
        padding: .5rem;
        border-right: none;
        border-bottom: 1px solid var(--border);
        overflow-x: auto;
    }
    .sidebar-nav { flex-direction: row; min-width: max-content; }
    .sidebar-link { white-space: nowrap; padding: .5rem .8rem; font-size: .85rem; }
    .sidebar-link svg { display: none; }
    .app-layout--with-sidebar .main { padding: 1rem; }
}

/* Upload form tweaks */
input[type="file"] {
    padding: .5em;
    background: var(--cream);
    border: 2px dashed var(--border);
    cursor: pointer;
}
input[type="file"]:hover { border-color: var(--burgundy); }
