/* ==========================================================================
   Gridlock Studio CMS — Admin Panel Theme
   Clean minimal SaaS look: light surfaces, thin borders, restrained accent
   color, no gradients/glow. Single shared stylesheet for every admin page —
   keep class names stable, every admin view depends on these same selectors.
   ========================================================================== */

:root {
    --bs-primary: #ff5e00;
    --bs-primary-rgb: 255, 94, 0;
    --bs-link-color: #ff5e00;
    --bs-link-hover-color: #e05500;

    --brand: #ff5e00;
    --brand-dark: #e05500;
    --brand-soft: #fff1e8;
    --brand-soft-line: #ffd6b8;

    --ink: #111318;
    --ink-soft: #3f4552;
    --muted: #6b7280;
    --faint: #9aa0ac;

    --bg: #f6f7f9;
    --surface: #ffffff;
    --line: #e6e8ec;
    --line-soft: #f0f1f4;

    --sidebar-bg: #14161b;
    --sidebar-bg-hover: #1e2128;
    --sidebar-text: #9aa0ac;
    --sidebar-line: rgba(255, 255, 255, 0.07);

    --r: 0.6rem;
    --r-sm: 0.4rem;
    --r-pill: 999px;

    --shadow-xs: 0 1px 2px rgba(17, 19, 24, 0.04);
    --shadow-sm: 0 1px 3px rgba(17, 19, 24, 0.06), 0 1px 2px rgba(17, 19, 24, 0.04);

    --t: 150ms ease;
}

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

body.admin-body {
    background: var(--bg);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

* { scrollbar-width: thin; scrollbar-color: #d1d5db transparent; }
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 999px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-thumb:hover { background: #b0b6c0; background-clip: padding-box; }

.btn-primary {
    --bs-btn-bg: #ff5e00;
    --bs-btn-border-color: #ff5e00;
    --bs-btn-hover-bg: #e05500;
    --bs-btn-hover-border-color: #e05500;
    --bs-btn-active-bg: #cc4d00;
    --bs-btn-active-border-color: #cc4d00;
    box-shadow: none;
}

.btn-outline-primary,
.btn-outline-warning {
    --bs-btn-color: #c2410c;
    --bs-btn-border-color: #fdba74;
    --bs-btn-hover-bg: #fff7ed;
    --bs-btn-hover-color: #9a3412;
    --bs-btn-hover-border-color: #fb923c;
}

/* ==========================================================================
   Shell / Layout
   ========================================================================== */

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

.admin-sidebar {
    width: 264px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 1040;
    overflow-y: auto;
    transition: transform var(--t);
}

.admin-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem 1.4rem;
    border-bottom: 1px solid var(--sidebar-line);
}

.admin-sidebar-brand img { height: 1.6rem; filter: brightness(0) invert(1); flex-shrink: 0; }
.admin-sidebar-brand span { display: block; font-size: 0.7rem; letter-spacing: 0.02em; opacity: 0.55; }

.admin-nav-group { padding: 0.6rem 0.6rem; }
.admin-nav-group + .admin-nav-group { border-top: 1px solid var(--sidebar-line); }

.admin-nav-label {
    padding: 0.55rem 0.8rem 0.35rem;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #676d7a;
}

.admin-nav-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.55rem 0.8rem;
    margin: 0.05rem 0;
    color: var(--sidebar-text);
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--r-sm);
    border-left: 2px solid transparent;
    transition: background-color var(--t), color var(--t);
}

.admin-nav-link i { opacity: 0.85; font-size: 1rem; width: 1.2rem; text-align: center; }

.admin-nav-link:hover { background: var(--sidebar-bg-hover); color: #fff; }

.admin-nav-link.active {
    background: var(--sidebar-bg-hover);
    color: #fff;
    border-left-color: var(--brand);
}

.admin-main { margin-left: 264px; }

.admin-topbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    min-height: 64px;
    background: var(--surface);
    border-bottom: 1px solid var(--line) !important;
}

.admin-topbar h1 {
    position: relative;
    padding-left: 0.85rem;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
}

.admin-topbar h1::before {
    content: "";
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 1.15rem;
    border-radius: 999px;
    background: var(--brand);
}

.admin-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(17, 19, 24, 0.45);
    z-index: 1035;
}

body.admin-sidebar-open .admin-sidebar-overlay { display: block; }

/* ==========================================================================
   Cards & forms
   ========================================================================== */

.admin-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 1.5rem 1.6rem;
    margin-bottom: 1.25rem;
    box-shadow: var(--shadow-xs);
}

.admin-card h2,
.admin-card h3 {
    margin: 0 0 1.25rem;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--ink);
    padding-bottom: 0.9rem;
    border-bottom: 1px solid var(--line);
}

.admin-grid { display: grid; gap: 1.2rem; }
.admin-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.admin-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.admin-field { margin-bottom: 1.2rem; }

.admin-field label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
    color: var(--ink-soft);
}

.admin-field input[type="text"],
.admin-field input[type="email"],
.admin-field input[type="url"],
.admin-field input[type="number"],
.admin-field input[type="password"],
.admin-field select,
.admin-field textarea {
    display: block;
    width: 100%;
    padding: 0.6rem 0.8rem;
    font-size: 0.9rem;
    line-height: 1.5;
    color: var(--ink);
    background-color: var(--surface);
    border: 1px solid #d5d8de;
    border-radius: var(--r-sm);
    transition: border-color var(--t), box-shadow var(--t);
}

.admin-field input:hover,
.admin-field select:hover,
.admin-field textarea:hover { border-color: #b7bcc5; }

.admin-field input:focus,
.admin-field select:focus,
.admin-field textarea:focus {
    border-color: var(--brand);
    outline: 0;
    box-shadow: 0 0 0 3px var(--brand-soft);
}

.admin-field textarea { min-height: 110px; resize: vertical; }
.admin-field small { display: block; margin-top: 0.35rem; color: var(--muted); font-size: 0.78rem; }

.admin-check {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    min-height: 2.85rem;
    padding: 0.55rem 0.85rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    transition: border-color var(--t), background-color var(--t);
}

.admin-check:has(input:checked) { background: var(--brand-soft); border-color: var(--brand-soft-line); }

.admin-check input { width: 1.05rem; height: 1.05rem; accent-color: var(--brand); cursor: pointer; }

.admin-field.admin-check label { display: inline; margin: 0; cursor: pointer; font-weight: 500; }

/* ==========================================================================
   Tabs (long forms — Services, Portfolio)
   ========================================================================== */

.admin-tabs {
    display: flex;
    gap: 0.15rem;
    border-bottom: 1px solid var(--line);
    margin-bottom: 1.5rem;
    overflow-x: auto;
}

.admin-tab-btn {
    appearance: none;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    padding: 0.7rem 0.95rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--muted);
    white-space: nowrap;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: color var(--t), border-color var(--t);
}

.admin-tab-btn:hover { color: var(--ink); }
.admin-tab-btn.active { color: var(--brand); border-bottom-color: var(--brand); }

.admin-tab-error-dot {
    width: 6px;
    height: 6px;
    border-radius: 999px;
    background: #dc2626;
    display: inline-block;
}

.admin-tab-panel[hidden] { display: none; }

/* ==========================================================================
   Buttons
   ========================================================================== */

.admin-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.55rem 1.05rem;
    border-radius: var(--r-sm);
    border: 1px solid transparent;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.5;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color var(--t), border-color var(--t), color var(--t);
}

.admin-btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.admin-btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }

.admin-btn-secondary { background: var(--surface); border-color: #d5d8de; color: var(--ink); }
.admin-btn-secondary:hover { background: var(--bg); border-color: #b7bcc5; }

.admin-btn-danger { background: #dc2626; border-color: #dc2626; color: #fff; }
.admin-btn-danger:hover { background: #b91c1c; border-color: #b91c1c; }

.admin-btn-sm { padding: 0.4rem 0.75rem; font-size: 0.8rem; }

.admin-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-top: 1.25rem;
    padding-top: 1.25rem;
    border-top: 1px solid var(--line);
}

.admin-page-head { display: flex; justify-content: flex-end; margin-bottom: 1.1rem; }
.admin-delete-form { margin-top: 0.85rem; }

/* Lets a delete <form> live inside an .admin-actions flex row without an
   extra box — its button becomes a direct flex item, as if the form itself
   weren't there. Keeps delete's csrf/_method fields out of the save form. */
.admin-inline-form { display: contents; }

/* ==========================================================================
   Tables
   ========================================================================== */

.admin-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--r); }

.admin-table { width: 100%; margin-bottom: 0; border-collapse: separate; border-spacing: 0; }

.admin-table th {
    padding: 0.7rem 0.9rem;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    background: var(--bg);
    white-space: nowrap;
    border-bottom: 1px solid var(--line);
}

.admin-table td { padding: 0.75rem 0.9rem; vertical-align: middle; border-bottom: 1px solid var(--line-soft); }
.admin-table tbody tr { transition: background-color var(--t); }
.admin-table tbody tr:hover { background: var(--bg); }
.admin-table tbody tr:last-child td { border-bottom: none; }

.admin-table td:last-child,
.admin-table th:last-child { text-align: right; white-space: nowrap; }

.admin-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.6rem;
    border-radius: var(--r-pill);
    font-size: 0.72rem;
    font-weight: 700;
}

.admin-badge-green { background: #e6f6ec; color: #166534; }
.admin-badge-gray { background: #f1f2f5; color: #475569; }
.admin-badge-orange { background: var(--brand-soft); color: #9a3412; }

/* Bootstrap 5 pagination (Paginator::useBootstrapFive) */
.pagination { margin-top: 1.25rem; gap: 0.3rem; }

.page-link {
    border: 1px solid var(--line);
    color: var(--ink-soft);
    border-radius: var(--r-sm) !important;
    margin-left: 0 !important;
    font-weight: 600;
    font-size: 0.85rem;
    transition: background-color var(--t), color var(--t), border-color var(--t);
}

.page-link:hover { background: var(--brand-soft); border-color: var(--brand-soft-line); color: #c2410c; }

.page-item.active .page-link { background: var(--brand); border-color: var(--brand); color: #fff; }
.page-item.disabled .page-link { color: var(--faint); background: var(--bg); }

/* ==========================================================================
   Dashboard stats
   ========================================================================== */

.admin-section-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--muted);
    margin: 0 0 0.75rem;
}

.admin-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 1rem;
}

.admin-stat {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 1.1rem;
    box-shadow: var(--shadow-xs);
}

.admin-stat-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.15rem;
    height: 2.15rem;
    border-radius: var(--r-sm);
    background: var(--brand-soft);
    color: var(--brand);
    font-size: 1rem;
    margin-bottom: 0.65rem;
}

.admin-stat strong { display: block; font-size: 1.6rem; font-weight: 800; letter-spacing: -0.02em; color: var(--ink); }
.admin-stat span { font-size: 0.8rem; font-weight: 500; color: var(--muted); }

/* ==========================================================================
   Login
   ========================================================================== */

.admin-login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: var(--bg);
}

.admin-login-card {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r);
    padding: 2rem 1.85rem;
    box-shadow: var(--shadow-sm);
}

.admin-login-card h1 { margin: 0 0 0.25rem; font-size: 1.3rem; font-weight: 800; letter-spacing: -0.01em; }
.admin-login-card p { margin: 0 0 1.5rem; color: var(--muted); font-size: 0.9rem; }

/* ==========================================================================
   Color input
   ========================================================================== */

.admin-color-field { display: flex; align-items: center; gap: 0.6rem; }

.admin-color-field input[type="color"] {
    width: 2.6rem;
    height: 2.6rem;
    padding: 0.25rem;
    border: 1px solid #d5d8de;
    border-radius: var(--r-sm);
    background: var(--surface);
    cursor: pointer;
    flex-shrink: 0;
}

.admin-color-field input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
.admin-color-field input[type="color"]::-webkit-color-swatch { border: none; border-radius: 0.2rem; }

.admin-color-field input[type="text"] { flex: 1; }

/* ==========================================================================
   Image previews & upload control
   ========================================================================== */

.admin-preview-box {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    margin-bottom: 0.75rem;
}

.admin-preview-label { font-size: 0.8rem; color: var(--muted); font-weight: 500; }

.admin-thumb-preview,
.admin-table-thumb {
    border-radius: var(--r-sm);
    border: 1px solid var(--line);
    object-fit: contain;
    background: var(--surface);
}

.admin-thumb-preview { max-width: 120px; max-height: 80px; }
.admin-table-thumb { width: 48px; height: 48px; }
.admin-thumb-empty { color: var(--faint); font-size: 0.85rem; }
.is-hidden { display: none !important; }

/* Native <input type=file> shows a raw browser button + filename text with
   no way to restyle it directly. Visually hide it (still focusable/keyboard
   operable) and trigger it via its associated <label>, styled as a button —
   no filename text is shown at all, only the live thumbnail preview above. */
.admin-upload-input {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.admin-upload-trigger { cursor: pointer; }

.admin-upload-input:focus-visible + .admin-upload-trigger {
    outline: 2px solid var(--brand);
    outline-offset: 2px;
}

.admin-upload-path {
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px dashed var(--line);
}

.admin-upload-path summary {
    font-size: 0.78rem;
    color: var(--muted);
    cursor: pointer;
    user-select: none;
}

.admin-upload-path input { margin-top: 0.5rem; }

/* ==========================================================================
   Media library
   ========================================================================== */

.admin-media-toolbar {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.25rem;
    color: var(--muted);
    font-size: 0.85rem;
}

.admin-media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 1rem;
}

.admin-media-card {
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--surface);
    overflow: hidden;
    box-shadow: var(--shadow-xs);
}

.admin-media-thumb {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
    border-bottom: 1px solid var(--line);
    overflow: hidden;
}

.admin-media-thumb img { width: 100%; height: 100%; object-fit: cover; }
.admin-media-thumb i { font-size: 2rem; color: var(--faint); }

.admin-media-meta { padding: 0.75rem; }

.admin-media-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ink);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 0.25rem;
}

.admin-media-sub { font-size: 0.74rem; color: var(--muted); margin-bottom: 0.5rem; }

.admin-media-usage {
    font-size: 0.72rem;
    color: var(--ink-soft);
    line-height: 1.5;
}

.admin-media-usage-empty { color: var(--faint); font-style: italic; }

/* ==========================================================================
   Repeaters / tags
   ========================================================================== */

.admin-repeater { margin-bottom: 1.25rem; }

.admin-repeater-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin-bottom: 0.65rem;
}

.admin-repeater-head label { font-size: 0.85rem; font-weight: 700; margin: 0; color: var(--ink-soft); }

.admin-repeater-items { display: grid; gap: 0.55rem; }

/* Pills: tags, services, features, and every other plain text repeater share
   this partial, so restyling it here makes them all consistent at once. */
.admin-repeater--tags .admin-tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    max-width: none;
}

.admin-tag-row {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.25rem 0.25rem 0.25rem 0.9rem;
    background: var(--bg);
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    transition: border-color var(--t), background-color var(--t), box-shadow var(--t);
}

.admin-tag-row:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); background: var(--surface); }

.admin-tag-input {
    border: none;
    background: transparent;
    padding: 0.35rem 0;
    font-size: 0.85rem;
    width: 9rem;
    min-width: 3rem;
    max-width: 16rem;
    field-sizing: content;
}

.admin-tag-input:focus { outline: none; }

.admin-btn-add { background: var(--brand-soft); border: 1px solid var(--brand-soft-line); color: #c2410c; }
.admin-btn-add:hover { background: #ffe4cc; }

.admin-btn-icon { width: 1.75rem; height: 1.75rem; padding: 0; flex-shrink: 0; }
.admin-tag-row .admin-btn-icon { border-radius: 999px; }

.admin-btn-remove { background: var(--surface); border: 1px solid #fecaca; color: #b91c1c; }
.admin-btn-remove:hover { background: #fef2f2; }

.admin-btn-svg { width: 1rem; height: 1rem; }

.admin-repeater-item--inline {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem;
    align-items: center;
    max-width: 36rem;
}

.admin-repeater-item--media,
.admin-repeater-card {
    padding: 1rem;
    border: 1px solid var(--line);
    border-radius: var(--r);
    background: var(--bg);
}

.admin-repeater-media-input {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 0.5rem;
    align-items: center;
}

.admin-repeater-card-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.admin-sub-label { font-size: 0.8rem; color: var(--muted); }
.admin-sub-card { margin-top: 0.5rem; background: var(--surface); }

/* ==========================================================================
   Alerts
   ========================================================================== */

.alert { border-radius: var(--r); border: 1px solid transparent; box-shadow: none; }
.alert-success { background: #ecfdf3; border-color: #bbf7d0; color: #166534; }
.alert-danger { background: #fef2f2; border-color: #fecaca; color: #991b1b; }

.admin-menu-toggle { display: none; }

@media (max-width: 1023px) {
    .admin-sidebar { transform: translateX(-100%); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15); }
    body.admin-sidebar-open .admin-sidebar { transform: translateX(0); }
    .admin-main { margin-left: 0; }
    .admin-menu-toggle { display: inline-flex; }
    .admin-grid-2, .admin-grid-3 { grid-template-columns: 1fr; }
    .admin-repeater-item--inline,
    .admin-repeater-media-input { grid-template-columns: 1fr; }
    .admin-repeater-item--inline { max-width: none; }
}

@media (max-width: 639px) {
    .admin-actions { flex-direction: column; }
    .admin-actions .admin-btn,
    .admin-page-head .btn,
    .admin-page-head .admin-btn { width: 100%; }
}
