/* =====================================================================
   Admin dashboard — Company Restoration UK
   ===================================================================== */
:root {
    --a-bg: #f2f5f7;
    --a-surface: #ffffff;
    --a-border: #e3e9ed;
    --a-navy: #023a51;
    --a-navy-deep: #012838;
    --a-navy-soft: #0b4a63;
    --a-red: #ec302a;
    --a-gold: #f5b716;
    --a-text: #24313b;
    --a-muted: #64748b;
    --a-green: #16a34a;
    --a-blue: #2563eb;
    --a-amber: #d97706;
    --a-radius: 12px;
    --a-shadow: 0 1px 3px rgba(2, 58, 81, .07), 0 4px 16px rgba(2, 58, 81, .05);
    --a-font: 'Plus Jakarta Sans', system-ui, sans-serif;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { font-size: 15px; }
body { font-family: var(--a-font); background: var(--a-bg); color: var(--a-text); min-height: 100vh; }
a { color: var(--a-navy-soft); text-decoration: none; }
a:hover { color: var(--a-red); }
img { max-width: 100%; }

.admin-shell { display: flex; min-height: 100vh; }

/* ---------------- Sidebar ---------------- */
.admin-sidebar {
    width: 252px; flex-shrink: 0; background: linear-gradient(180deg, var(--a-navy) 0%, var(--a-navy-deep) 100%);
    color: #cfe0e8; display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; overflow-y: auto;
    scrollbar-width: thin; scrollbar-color: rgba(255,255,255,.2) transparent;
}
.sidebar-brand { padding: 22px 22px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-brand img { height: 40px; width: auto; }
.sidebar-nav { flex: 1; padding: 14px 12px 20px; }
.nav-section-label {
    font-size: .66rem; letter-spacing: .14em; text-transform: uppercase; color: #6f93a3;
    padding: 18px 12px 7px; font-weight: 700;
}
.nav-item {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 9px;
    color: #cfe0e8; font-size: .92rem; font-weight: 500; margin-bottom: 2px; transition: all .18s ease;
}
.nav-item i { width: 18px; text-align: center; font-size: .9rem; color: #7fa4b4; transition: color .18s; }
.nav-item:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item:hover i { color: var(--a-gold); }
.nav-item.is-active { background: var(--a-red); color: #fff; box-shadow: 0 6px 16px rgba(236,48,42,.35); }
.nav-item.is-active i { color: #fff; }
.nav-count {
    margin-left: auto; background: var(--a-gold); color: #23282d; border-radius: 999px;
    font-size: .68rem; font-weight: 800; padding: 2px 8px; line-height: 1.4;
}
.nav-item.is-active .nav-count { background: #fff; }
.sidebar-footer { padding: 16px 22px; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar-footer a { color: #9fc0cf; font-size: .85rem; }
.sidebar-footer a:hover { color: #fff; }

/* ---------------- Main column ---------------- */
.admin-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.admin-topbar {
    background: var(--a-surface); border-bottom: 1px solid var(--a-border);
    display: flex; align-items: center; gap: 18px; padding: 0 26px; height: 64px; position: sticky; top: 0; z-index: 60;
}
.topbar-menu-btn { display: none; background: none; border: none; font-size: 1.15rem; color: var(--a-navy); cursor: pointer; }
.topbar-title { font-size: 1.14rem; font-weight: 800; color: var(--a-navy); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.topbar-link { color: var(--a-muted); font-size: 1.02rem; }
.topbar-user { position: relative; }
.user-chip { display: flex; align-items: center; gap: 10px; background: none; border: none; cursor: pointer; font-family: inherit; }
.user-avatar {
    width: 36px; height: 36px; border-radius: 50%; background: var(--a-navy); color: #fff;
    display: inline-flex; align-items: center; justify-content: center; font-weight: 700;
}
.user-meta { text-align: left; line-height: 1.15; }
.user-meta strong { display: block; font-size: .85rem; color: var(--a-text); }
.user-meta small { color: var(--a-muted); font-size: .72rem; }
.user-chip > i { font-size: .7rem; color: var(--a-muted); }
.user-menu {
    position: absolute; right: 0; top: calc(100% + 10px); background: #fff; border: 1px solid var(--a-border);
    border-radius: 10px; box-shadow: var(--a-shadow); min-width: 175px; padding: 6px; display: none; z-index: 80;
}
.topbar-user.is-open .user-menu { display: block; }
.user-menu a { display: flex; gap: 10px; align-items: center; padding: 9px 12px; border-radius: 7px; font-size: .88rem; color: var(--a-text); }
.user-menu a:hover { background: var(--a-bg); color: var(--a-red); }

.admin-content { padding: 26px; flex: 1; }
.admin-footer {
    padding: 14px 26px; border-top: 1px solid var(--a-border); color: var(--a-muted);
    font-size: .78rem; display: flex; justify-content: space-between; background: var(--a-surface);
}

/* ---------------- Flash ---------------- */
.flash {
    display: flex; align-items: center; gap: 12px; padding: 13px 16px; border-radius: 10px; margin-bottom: 20px;
    font-size: .92rem; font-weight: 500; border: 1px solid transparent; animation: flashIn .25s ease;
}
@keyframes flashIn { from { opacity: 0; transform: translateY(-6px); } }
.flash button { margin-left: auto; background: none; border: none; font-size: 1.2rem; cursor: pointer; color: inherit; opacity: .6; }
.flash-success { background: #ecfdf3; border-color: #b5e5c8; color: #106b39; }
.flash-error   { background: #fef1f1; border-color: #f5c6c4; color: #a02622; }
.flash-info    { background: #eff6ff; border-color: #c3d9fb; color: #1c4ed8; }

/* ---------------- Cards / panels ---------------- */
.card { background: var(--a-surface); border: 1px solid var(--a-border); border-radius: var(--a-radius); box-shadow: var(--a-shadow); }
.card + .card { margin-top: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 17px 20px; border-bottom: 1px solid var(--a-border); flex-wrap: wrap; }
.card-head h2 { font-size: 1rem; font-weight: 800; color: var(--a-navy); }
.card-head .muted { font-size: .82rem; }
.card-body { padding: 20px; }
.card-body.p-0 { padding: 0; }

/* ---------------- Stat tiles ---------------- */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 18px; margin-bottom: 22px; }
.stat-tile { background: var(--a-surface); border: 1px solid var(--a-border); border-radius: var(--a-radius); box-shadow: var(--a-shadow); padding: 20px; display: flex; gap: 16px; align-items: center; }
.stat-icon {
    width: 48px; height: 48px; border-radius: 12px; display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.15rem; color: #fff; flex-shrink: 0;
}
.stat-icon.tone-navy { background: var(--a-navy); }
.stat-icon.tone-red { background: var(--a-red); }
.stat-icon.tone-gold { background: var(--a-gold); color: #23282d; }
.stat-icon.tone-green { background: var(--a-green); }
.stat-icon.tone-blue { background: var(--a-blue); }
.stat-info small { display: block; color: var(--a-muted); font-size: .76rem; font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.stat-info strong { font-size: 1.45rem; font-weight: 800; color: var(--a-navy); line-height: 1.25; }
.stat-info span.sub { font-size: .76rem; color: var(--a-muted); }

/* ---------------- Tables ---------------- */
.table-wrap { overflow-x: auto; }
table.admin-table { width: 100%; border-collapse: collapse; font-size: .89rem; }
.admin-table th {
    text-align: left; padding: 12px 16px; background: #f8fafb; color: var(--a-muted); font-size: .72rem;
    text-transform: uppercase; letter-spacing: .07em; border-bottom: 1px solid var(--a-border); white-space: nowrap;
}
.admin-table td { padding: 13px 16px; border-bottom: 1px solid #eef2f5; vertical-align: middle; }
.admin-table tr:last-child td { border-bottom: none; }
.admin-table tr:hover td { background: #fbfdfe; }
.admin-table .row-title { font-weight: 700; color: var(--a-navy); }
.admin-table .row-sub { display: block; color: var(--a-muted); font-size: .78rem; font-weight: 400; margin-top: 2px; }
.admin-table .actions { white-space: nowrap; text-align: right; }
.admin-table .actions a, .admin-table .actions button {
    display: inline-flex; align-items: center; justify-content: center; width: 30px; height: 30px; border-radius: 8px;
    color: var(--a-muted); background: none; border: none; cursor: pointer; font-size: .85rem; margin-left: 2px;
}
.admin-table .actions a:hover, .admin-table .actions button:hover { background: var(--a-bg); color: var(--a-navy); }
.admin-table .actions .danger:hover { background: #fef1f1; color: var(--a-red); }
.thumb-sq { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; background: var(--a-bg); border: 1px solid var(--a-border); }

/* ---------------- Badges ---------------- */
.badge {
    display: inline-block; padding: 4px 11px; border-radius: 999px; font-size: .72rem; font-weight: 700;
    text-transform: capitalize; letter-spacing: .02em; white-space: nowrap;
}
.badge-green { background: #e7f7ee; color: #0f7a3d; }
.badge-amber { background: #fdf3e2; color: #a3610a; }
.badge-blue  { background: #e9f0fe; color: #1d51c9; }
.badge-red   { background: #fdeceb; color: #b3271f; }
.badge-grey  { background: #eef1f4; color: #5b6b7b; }
.badge-navy  { background: #e3eef4; color: var(--a-navy); }

/* ---------------- Buttons ---------------- */
.btn {
    display: inline-flex; align-items: center; gap: 8px; padding: 10px 18px; border-radius: 9px;
    font-family: inherit; font-size: .88rem; font-weight: 700; cursor: pointer; border: 1px solid transparent;
    transition: all .18s ease; line-height: 1.3;
}
.btn-primary { background: var(--a-red); color: #fff; box-shadow: 0 4px 12px rgba(236,48,42,.25); }
.btn-primary:hover { background: #d42722; color: #fff; }
.btn-navy { background: var(--a-navy); color: #fff; }
.btn-navy:hover { background: var(--a-navy-soft); color: #fff; }
.btn-secondary { background: #fff; border-color: var(--a-border); color: var(--a-text); }
.btn-secondary:hover { border-color: var(--a-navy); color: var(--a-navy); }
.btn-danger { background: #fff; border-color: #f3c1bf; color: var(--a-red); }
.btn-danger:hover { background: var(--a-red); border-color: var(--a-red); color: #fff; }
.btn-ghost { background: none; color: var(--a-muted); }
.btn-ghost:hover { color: var(--a-navy); }
.btn-sm { padding: 7px 13px; font-size: .8rem; border-radius: 8px; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------------- Forms ---------------- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px 18px; }
.form-grid .span-2 { grid-column: span 2; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: .8rem; font-weight: 700; color: var(--a-navy); }
.field label small { color: var(--a-muted); font-weight: 500; }
.field input[type="text"], .field input[type="email"], .field input[type="password"], .field input[type="number"],
.field input[type="url"], .field input[type="datetime-local"], .field input[type="date"], .field select, .field textarea {
    font-family: inherit; font-size: .9rem; padding: 10px 13px; border: 1px solid var(--a-border);
    border-radius: 9px; background: #fff; color: var(--a-text); transition: border .15s, box-shadow .15s; width: 100%;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--a-navy-soft); box-shadow: 0 0 0 3px rgba(11,74,99,.12);
}
.field textarea { min-height: 92px; resize: vertical; }
.field .hint { font-size: .74rem; color: var(--a-muted); }
.field.has-error input { border-color: var(--a-red); }
.check-row { display: flex; align-items: center; gap: 10px; font-size: .88rem; font-weight: 600; color: var(--a-text); cursor: pointer; }
.check-row input { width: 17px; height: 17px; accent-color: var(--a-red); }

/* toggle switch */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch .slider {
    position: absolute; inset: 0; background: #cbd5e1; border-radius: 999px; transition: .2s; cursor: pointer;
}
.switch .slider:before {
    content: ""; position: absolute; height: 18px; width: 18px; left: 3px; top: 3px; background: #fff;
    border-radius: 50%; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.switch input:checked + .slider { background: var(--a-green); }
.switch input:checked + .slider:before { transform: translateX(20px); }
.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 13px 0; border-bottom: 1px solid #eef2f5; }
.switch-row:last-child { border-bottom: none; }
.switch-row .sw-label strong { display: block; font-size: .9rem; color: var(--a-navy); }
.switch-row .sw-label small { color: var(--a-muted); font-size: .78rem; }

/* ---------------- Toolbar row on list pages ---------------- */
.list-toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.list-toolbar form.search { display: flex; gap: 8px; }
.list-toolbar .search input {
    font-family: inherit; padding: 9px 14px; border: 1px solid var(--a-border); border-radius: 9px; min-width: 230px; font-size: .88rem;
}
.list-toolbar .spacer { flex: 1; }
.filter-pills { display: flex; gap: 6px; flex-wrap: wrap; }
.filter-pills a {
    padding: 7px 14px; border-radius: 999px; font-size: .8rem; font-weight: 600; color: var(--a-muted);
    background: #fff; border: 1px solid var(--a-border);
}
.filter-pills a.is-active { background: var(--a-navy); border-color: var(--a-navy); color: #fff; }

/* ---------------- Pagination ---------------- */
.pagination { display: flex; gap: 6px; padding: 16px 20px; align-items: center; }
.page-link {
    min-width: 34px; height: 34px; display: inline-flex; align-items: center; justify-content: center;
    border-radius: 8px; border: 1px solid var(--a-border); background: #fff; color: var(--a-text); font-size: .84rem; font-weight: 600;
}
.page-link:hover { border-color: var(--a-navy); }
.page-link.is-current { background: var(--a-navy); border-color: var(--a-navy); color: #fff; }
.page-gap { color: var(--a-muted); }

/* ---------------- Editor ---------------- */
.editor-wrap { border: 1px solid var(--a-border); border-radius: 10px; overflow: hidden; background: #fff; }
.editor-toolbar { display: flex; flex-wrap: wrap; gap: 2px; padding: 8px; border-bottom: 1px solid var(--a-border); background: #f8fafb; }
.editor-toolbar button {
    min-width: 34px; height: 32px; padding: 0 8px; border: none; background: none; border-radius: 7px; cursor: pointer;
    color: var(--a-text); font-size: .85rem; font-weight: 700;
}
.editor-toolbar button:hover { background: #e8eef2; color: var(--a-navy); }
.editor-toolbar .sep { width: 1px; background: var(--a-border); margin: 4px 6px; }
.editor-area { min-height: 340px; padding: 18px 20px; outline: none; font-size: .95rem; line-height: 1.75; overflow-y: auto; max-height: 640px; }
.editor-area h2 { margin: 18px 0 10px; } .editor-area h3 { margin: 15px 0 8px; }
.editor-area p { margin-bottom: 12px; }
.editor-area ul, .editor-area ol { margin: 0 0 12px 22px; }
.editor-area img { max-width: 100%; border-radius: 8px; }
.editor-area blockquote { border-left: 3px solid var(--a-red); padding: 8px 14px; background: #f8fafb; margin: 12px 0; }
.editor-area a { color: var(--a-blue); text-decoration: underline; }
.editor-source { display: none; width: 100%; min-height: 340px; border: none; padding: 16px; font-family: Consolas, monospace; font-size: .84rem; outline: none; resize: vertical; }
.editor-wrap.source-mode .editor-area { display: none; }
.editor-wrap.source-mode .editor-source { display: block; }

/* ---------------- Two-column edit layout ---------------- */
.edit-layout { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 20px; align-items: start; }
.edit-side .card + .card { margin-top: 20px; }
.side-list { display: flex; flex-direction: column; gap: 8px; max-height: 220px; overflow-y: auto; }

/* ---------------- Media library ---------------- */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.media-item { border: 1px solid var(--a-border); border-radius: 10px; overflow: hidden; background: #fff; position: relative; }
.media-item img { width: 100%; height: 110px; object-fit: cover; display: block; background: var(--a-bg); }
.media-item .file-ico { width: 100%; height: 110px; display: flex; align-items: center; justify-content: center; font-size: 2rem; color: var(--a-muted); background: var(--a-bg); }
.media-item figcaption { padding: 8px 10px; font-size: .72rem; color: var(--a-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.media-item .media-actions { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.media-item:hover .media-actions { opacity: 1; }
.media-item .media-actions button {
    width: 28px; height: 28px; border-radius: 7px; border: none; cursor: pointer; background: rgba(2,58,81,.85); color: #fff; font-size: .74rem;
}
.media-item .media-actions button.danger { background: rgba(236,48,42,.9); }

/* media picker modal */
.media-modal { position: fixed; inset: 0; background: rgba(2,30,43,.55); z-index: 200; display: flex; align-items: center; justify-content: center; padding: 30px; }
.media-modal[hidden] { display: none; }
.media-modal-panel { background: #fff; border-radius: 14px; width: min(980px, 100%); max-height: 84vh; display: flex; flex-direction: column; overflow: hidden; }
.media-modal-head { display: flex; justify-content: space-between; align-items: center; padding: 16px 20px; border-bottom: 1px solid var(--a-border); }
.media-modal-head h3 { font-size: 1rem; color: var(--a-navy); }
.media-modal-grid { padding: 20px; overflow-y: auto; display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 12px; }
.media-modal-grid .pick { border: 2px solid transparent; border-radius: 10px; overflow: hidden; cursor: pointer; background: var(--a-bg); }
.media-modal-grid .pick img { width: 100%; height: 100px; object-fit: cover; display: block; }
.media-modal-grid .pick:hover { border-color: var(--a-gold); }
.media-modal-grid .pick figcaption { font-size: .68rem; padding: 6px 8px; color: var(--a-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* image field with preview */
.img-field-preview { display: flex; align-items: center; gap: 12px; }
.img-field-preview img { width: 74px; height: 74px; object-fit: cover; border-radius: 10px; border: 1px solid var(--a-border); background: var(--a-bg); }

/* ---------------- Tabs (settings) ---------------- */
.tabs-bar { display: flex; gap: 4px; flex-wrap: wrap; border-bottom: 2px solid var(--a-border); margin-bottom: 22px; }
.tabs-bar a {
    padding: 11px 18px; font-size: .88rem; font-weight: 700; color: var(--a-muted);
    border-bottom: 2px solid transparent; margin-bottom: -2px;
}
.tabs-bar a.is-active { color: var(--a-red); border-bottom-color: var(--a-red); }
.tabs-bar a:hover { color: var(--a-navy); }

/* ---------------- Dashboard chart ---------------- */
.chart-box { padding: 10px 20px 18px; }
.chart-box svg { width: 100%; height: 190px; display: block; }
.chart-legend { display: flex; gap: 18px; padding: 0 20px 16px; font-size: .78rem; color: var(--a-muted); }
.chart-legend i { font-size: .6rem; margin-right: 5px; }

/* dashboard split */
.dash-split { display: grid; grid-template-columns: 1.6fr 1fr; gap: 20px; align-items: start; }
.mini-list { display: flex; flex-direction: column; }
.mini-item { display: flex; gap: 12px; align-items: center; padding: 12px 20px; border-bottom: 1px solid #eef2f5; font-size: .87rem; }
.mini-item:last-child { border-bottom: none; }
.mini-item .grow { flex: 1; min-width: 0; }
.mini-item .grow strong { display: block; color: var(--a-navy); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mini-item .grow small { color: var(--a-muted); }
.mini-item .when { color: var(--a-muted); font-size: .74rem; white-space: nowrap; }

/* ---------------- Detail views ---------------- */
.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 14px 20px; }
.detail-grid dt { font-size: .7rem; text-transform: uppercase; letter-spacing: .07em; color: var(--a-muted); font-weight: 700; margin-bottom: 3px; }
.detail-grid dd { font-size: .92rem; font-weight: 600; color: var(--a-text); }
.muted { color: var(--a-muted); }
.mt-0 { margin-top: 0 !important; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }
.text-right { text-align: right; }
.w-100 { width: 100%; }
.inline-form { display: inline; }

/* login page */
.login-body { display: flex; align-items: center; justify-content: center; min-height: 100vh; background: linear-gradient(135deg, var(--a-navy-deep) 0%, var(--a-navy) 55%, var(--a-navy-soft) 100%); padding: 20px; }
.login-card { background: #fff; border-radius: 16px; box-shadow: 0 24px 70px rgba(0,0,0,.35); width: 100%; max-width: 410px; overflow: hidden; }
.login-head { background: var(--a-navy); padding: 30px; text-align: center; }
.login-head img { height: 46px; }
.login-form { padding: 30px; display: flex; flex-direction: column; gap: 16px; }
.login-form h1 { font-size: 1.15rem; color: var(--a-navy); text-align: center; }
.login-form .sub { text-align: center; color: var(--a-muted); font-size: .84rem; margin-top: -10px; }
.login-error { background: #fef1f1; color: #a02622; border: 1px solid #f5c6c4; padding: 11px 14px; border-radius: 9px; font-size: .85rem; }
.login-footer { text-align: center; padding-bottom: 26px; color: var(--a-muted); font-size: .78rem; }

/* ---------------- Responsive ---------------- */
@media (max-width: 1100px) {
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
    .dash-split, .edit-layout { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
    .admin-sidebar { position: fixed; left: -260px; z-index: 300; transition: left .25s ease; height: 100vh; }
    .admin-sidebar.is-open { left: 0; box-shadow: 0 0 60px rgba(0,0,0,.4); }
    .topbar-menu-btn { display: block; }
    .form-grid { grid-template-columns: 1fr; }
    .form-grid .span-2 { grid-column: span 1; }
    .user-meta { display: none; }
    .admin-content { padding: 18px 14px; }
    .stat-grid { grid-template-columns: 1fr; }
}
