/* ===== Admin Panel Styles ===== */
:root {
    --green-dark: #0B3D2E;
    --green-primary: #01411C;
    --green-accent: #0d5c3f;
    --gold: #C9A227;
    --text-dark: #1a1a1a;
    --text-muted: #666666;
    --border: #e5e5e5;
    --bg: #f5f5f5;
    --white: #ffffff;
    --danger: #dc3545;
    --success: #28a745;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg);
    color: var(--text-dark);
    line-height: 1.6;
}

/* Login */
.login-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--green-dark);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: var(--white);
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
}

.login-logo {
    text-align: center;
    margin-bottom: 30px;
}

.login-logo img {
    width: 60px;
    height: 60px;
    margin: 0 auto 12px;
}

.login-logo h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--green-dark);
}

.login-logo p {
    font-size: 13px;
    color: var(--text-muted);
}

.login-btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 15px;
}

/* Admin Layout */
.admin-wrapper {
    display: flex;
    min-height: 100vh;
}

.admin-sidebar {
    width: 240px;
    background: var(--green-dark);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
}

.admin-logo {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-weight: 700;
    font-size: 16px;
}

.admin-logo img {
    width: 32px;
    height: 32px;
}

.admin-nav {
    flex: 1;
    padding: 16px 0;
}

.admin-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: rgba(255,255,255,0.7);
    font-size: 14px;
    transition: all 0.2s;
    text-decoration: none;
}

.admin-nav-link:hover,
.admin-nav-link.active {
    background: rgba(255,255,255,0.1);
    color: var(--white);
}

.admin-sidebar-footer {
    padding: 16px 0;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.admin-main {
    flex: 1;
    margin-left: 240px;
    display: flex;
    flex-direction: column;
    /* Without this a flex item refuses to shrink below its content's
       min-content width, which lets wide tables push the whole page sideways. */
    min-width: 0;
}

.admin-header {
    background: var(--white);
    padding: 16px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
}

.admin-header h1 {
    font-size: 20px;
    font-weight: 700;
}

.admin-view-site {
    font-size: 13px;
    color: var(--green-primary);
    font-weight: 600;
}

.admin-content {
    padding: 30px;
    flex: 1;
    min-width: 0;
}

/* Cards */
.admin-card {
    background: var(--white);
    border-radius: 8px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.admin-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.admin-card-header h3 {
    font-size: 16px;
    font-weight: 700;
}

.settings-tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    margin: 0 -4px 20px;
    border-bottom: 1px solid var(--border);
}

.settings-tab {
    flex: 0 0 auto;
    padding: 10px 14px;
    border: 0;
    border-bottom: 2px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.settings-tab:hover,
.settings-tab[aria-selected="true"] {
    color: var(--green-primary);
}

.settings-tab[aria-selected="true"] {
    border-bottom-color: var(--green-primary);
}

.settings-tab:focus-visible {
    outline: 2px solid var(--green-primary);
    outline-offset: -2px;
}

.settings-panel[hidden] {
    display: none;
}

.settings-panel {
    padding-bottom: 8px;
}

.settings-image-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.settings-image-preview {
    display: block;
    width: 180px;
    max-width: 100%;
    height: 90px;
    margin-bottom: 8px;
    object-fit: cover;
}

.settings-image-grid small {
    display: block;
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 11px;
}

.settings-section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 20px;
}

.settings-section-heading .form-section {
    margin-top: 0;
}

.hero-slide-editors {
    display: grid;
    gap: 16px;
}

.hero-slide-editor {
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 6px;
}

.hero-slide-editor legend {
    padding: 0 6px;
    color: var(--green-primary);
    font-size: 14px;
    font-weight: 700;
}

.hero-slide-editor .form-row {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

.hero-slide-active {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 14px;
    font-size: 13px;
}

.hero-slide-editor .btn-danger {
    background: var(--danger);
    color: var(--white);
}

@media (max-width: 860px) {
    .hero-slide-editor .form-row {
        grid-template-columns: 1fr;
        gap: 0;
    }
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--white);
    border-radius: 8px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: rgba(1, 65, 28, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--green-primary);
}

.stat-number {
    display: block;
    font-size: 28px;
    font-weight: 800;
    color: var(--text-dark);
}

.stat-label {
    font-size: 13px;
    color: var(--text-muted);
}

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Tables */
.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    text-align: left;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.admin-table th {
    font-weight: 600;
    color: var(--text-muted);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.admin-table tr:hover {
    background: #fafafa;
}

.admin-table .actions {
    display: flex;
    gap: 8px;
}

/* Forms */
.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text-dark);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--green-primary);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-checkboxes {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding-top: 24px;
}

.form-checkboxes label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
    font-size: 14px;
}

.form-section {
    font-size: 14px;
    font-weight: 700;
    color: var(--green-primary);
    margin: 24px 0 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: var(--green-primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--green-accent);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: #c82333;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 20px;
    font-size: 14px;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-error ul {
    margin: 6px 0 0 18px;
    font-weight: 400;
    font-size: 13px;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
    border-radius: 6px;
    padding: 12px 16px;
    margin-bottom: 18px;
    font-size: 13px;
}

.alert-info a { text-decoration: underline; font-weight: 600; }

/* Wide admin tables must never stretch the layout; scroll inside the card instead. */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (min-width: 641px) {
    .table-wrap .admin-table { min-width: 680px; }
}

/* ===== Table inputs / switches / reorder ===== */
.table-input {
    width: 100%;
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    background: var(--white);
}

.table-input:focus { outline: none; border-color: var(--green-primary); }
.table-input-sm { max-width: 80px; }

.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }

.switch-track {
    width: 38px;
    height: 21px;
    border-radius: 999px;
    background: #ccc;
    position: relative;
    transition: background 0.2s;
    flex-shrink: 0;
}

.switch-track::after {
    content: "";
    position: absolute;
    top: 2px;
    left: 2px;
    width: 17px;
    height: 17px;
    border-radius: 50%;
    background: var(--white);
    transition: transform 0.2s;
}

.switch input:checked + .switch-track { background: var(--green-primary); }
.switch input:checked + .switch-track::after { transform: translateX(17px); }
.switch input:focus-visible + .switch-track { outline: 2px solid var(--green-primary); outline-offset: 2px; }

.reorder-form { margin-top: 16px; }

.reorder-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 10px;
    margin-bottom: 14px;
}

.reorder-item { display: flex; align-items: center; gap: 8px; font-size: 13px; }

.reorder-item span {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.reorder-item input {
    width: 62px;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-family: inherit;
}

.muted-note { font-size: 12px; color: var(--text-muted); font-weight: 400; }
.form-row-3 { grid-template-columns: repeat(3, 1fr); }

.empty-state { text-align: center; color: var(--text-muted); padding: 32px 0; font-size: 14px; }

/* ===== Status pills ===== */
.status-pill {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.status-pending   { background: #fff3cd; color: #856404; }
.status-confirmed { background: #d1ecf1; color: #0c5460; }
.status-completed { background: #d4edda; color: #155724; }
.status-cancelled { background: #f8d7da; color: #721c24; }

.status-open { background: #fff3cd; color: #795b00; }
.status-in_progress { background: #dcecff; color: #15528a; }
.status-waiting_for_requester { background: #f0e8ff; color: #5b3985; }
.status-resolved { background: #d8f1df; color: #226137; }
.status-closed { background: #e8eaed; color: #4f5964; }

.priority-low { background: #e8eaed; color: #4f5964; }
.priority-normal { background: #dcecff; color: #15528a; }
.priority-high { background: #fff0d6; color: #80520a; }
.priority-urgent { background: #f8d7da; color: #721c24; }

.helpdesk-header,
.helpdesk-detail-header { gap: 16px; flex-wrap: wrap; }
.helpdesk-search { display: flex; gap: 8px; }
.helpdesk-search input { min-width: min(300px, 40vw); padding: 8px 10px; border: 1px solid var(--border); border-radius: 6px; font: inherit; font-size: 13px; }
.helpdesk-table small { display: block; color: var(--text-muted); font-size: 11px; margin-top: 3px; }
.helpdesk-ticket-link { display: block; color: var(--green-primary); text-decoration: none; }
.helpdesk-ticket-link:hover { text-decoration: underline; }
.helpdesk-pagination { margin-top: 16px; }
.helpdesk-detail-header h3 { margin: 8px 0 4px; }
.helpdesk-back-link { color: var(--green-primary); font-size: 12px; font-weight: 600; text-decoration: none; }
.helpdesk-back-link:hover { text-decoration: underline; }
.helpdesk-admin-reply-form { margin-top: 24px; padding-top: 8px; border-top: 1px solid var(--border); }
.helpdesk-admin-reply-form .form-row { max-width: 560px; }
.helpdesk-admin-reply-form textarea { min-height: 120px; }
.helpdesk-tools-nav { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 18px; border-bottom: 1px solid var(--border); }
.helpdesk-tools-nav a { padding: 9px 12px; border-bottom: 2px solid transparent; color: var(--text-muted); font-size: 13px; font-weight: 600; text-decoration: none; }
.helpdesk-tools-nav a:hover, .helpdesk-tools-nav a.active { color: var(--green-primary); }
.helpdesk-tools-nav a.active { border-bottom-color: var(--green-primary); }
.helpdesk-tool-form { max-width: 880px; }
.helpdesk-team-row, .automation-rule-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; padding: 16px 0; border-bottom: 1px solid var(--border); }
.helpdesk-team-row:last-child, .automation-rule-row:last-child { border-bottom: 0; }
.helpdesk-tool-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.helpdesk-active-toggle { display: flex; align-items: center; gap: 8px; padding-top: 12px; font-size: 13px; }
.ticket-sla-summary { display: flex; flex-wrap: wrap; gap: 8px 16px; margin-top: 10px; color: var(--text-muted); font-size: 12px; }
.sla-indicator { color: var(--green-primary); font-size: 12px; font-weight: 600; }
.sla-indicator.overdue { color: var(--danger); }
.helpdesk-report-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; margin-bottom: 18px; }
.helpdesk-report-stat { display: grid; gap: 5px; padding: 18px; background: var(--white); border: 1px solid var(--border); border-radius: 6px; }
.helpdesk-report-stat span, .helpdesk-report-stat small { color: var(--text-muted); font-size: 12px; }
.helpdesk-report-stat strong { color: var(--green-dark); font-size: 28px; line-height: 1.2; }
.helpdesk-daily-chart { display: grid; grid-template-columns: repeat(30, minmax(3px, 1fr)); align-items: end; gap: 4px; height: 150px; padding-top: 12px; }
.helpdesk-day-bar { display: flex; align-items: end; height: 100%; }
.helpdesk-day-bar span { width: 100%; min-height: 2px; background: var(--green-primary); border-radius: 3px 3px 0 0; }
.helpdesk-chart-labels { display: flex; justify-content: space-between; margin-top: 8px; color: var(--text-muted); font-size: 11px; }
.helpdesk-report-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-top: 16px; }
.helpdesk-report-row { display: flex; justify-content: space-between; gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.helpdesk-report-row:last-child { border-bottom: 0; }
.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; }

.ticket-thread { display: grid; gap: 14px; margin: 20px 0; }
.ticket-message { padding: 14px; border: 1px solid var(--border); border-left: 4px solid var(--green-primary); border-radius: 6px; background: #fff; }
.ticket-message.from-staff { border-left-color: var(--gold); }
.ticket-message-header { display: flex; align-items: baseline; flex-wrap: wrap; gap: 5px 12px; margin-bottom: 8px; font-size: 13px; }
.ticket-message-header span, .ticket-message-header time { color: var(--text-muted); font-size: 11px; }
.ticket-message-header time { margin-left: auto; }
.ticket-message p { margin: 0; overflow-wrap: anywhere; white-space: pre-wrap; }

@media (max-width: 640px) {
    .helpdesk-search { width: 100%; }
    .helpdesk-search input { min-width: 0; flex: 1; }
    .helpdesk-report-stats, .helpdesk-report-grid { grid-template-columns: 1fr; }
    .helpdesk-team-row, .automation-rule-row { flex-direction: column; }
    .helpdesk-table,
    .helpdesk-table tbody,
    .helpdesk-table tr,
    .helpdesk-table td { display: block; width: 100%; }
    .helpdesk-table thead { display: none; }
    .helpdesk-table tr { padding: 12px 0; border-bottom: 1px solid var(--border); }
    .helpdesk-table td { display: grid; grid-template-columns: 100px minmax(0, 1fr); gap: 10px; padding: 5px 0; border: 0; text-align: left; }
    .helpdesk-table td::before { content: attr(data-label); color: var(--text-muted); font-size: 11px; font-weight: 700; text-transform: uppercase; }
}

/* ===== Appointments ===== */
.stat-row { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px; }

.stat-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: 999px;
    background: var(--white);
    border: 1px solid var(--border);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-dark);
    transition: all 0.2s;
}

.stat-chip span { background: rgba(0,0,0,0.07); border-radius: 999px; padding: 1px 8px; font-size: 12px; }
.stat-chip:hover { border-color: var(--green-primary); }
.stat-chip.active { background: var(--green-primary); border-color: var(--green-primary); color: var(--white); }
.stat-chip.active span { background: rgba(255,255,255,0.2); }
.stat-chip.status-cancelled.active { background: var(--danger); border-color: var(--danger); }
.stat-chip.status-completed.active { background: var(--success); border-color: var(--success); }

.appointment-item {
    display: grid;
    grid-template-columns: 1fr auto auto;
    gap: 16px;
    align-items: start;
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}

.appointment-item:last-child { border-bottom: none; }
.appointment-top { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }

.appointment-ref {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
    color: var(--green-dark);
}

.appointment-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.appointment-meta a { color: var(--green-primary); }

.appointment-notes {
    font-size: 13px;
    color: var(--text-dark);
    background: var(--bg);
    padding: 8px 10px;
    border-radius: 6px;
    margin-top: 6px;
}

.appointment-form-row { display: flex; gap: 8px; align-items: center; }

.appointment-form-row select,
.appointment-form-row input {
    padding: 7px 9px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
}

.appointment-form-row input { min-width: 190px; }

.form-checkboxes-row {
    display: block;
    padding-top: 0;
}

.form-checkboxes-row label {
    display: inline-flex;
    white-space: nowrap;
}

/* ===== GrapesJS page builder ===== */
.admin-card--builder {
    padding: 0;
    overflow: hidden;
}

.page-builder__warning {
    margin: 0;
    border-radius: 0;
    font-size: 13px;
    line-height: 1.5;
}

/* Canvas on the left, panels in a fixed right column beside it. */
.page-builder__layout {
    display: flex;
    align-items: stretch;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: #f2f4f3;
}

.page-builder__canvas-col {
    flex: 1 1 auto;
    min-width: 0;
    background: #fff;
}

.page-builder__frame {
    height: 680px;
    background: #fff;
}

/*
 * Collapse GrapesJS's own side column. Every panel is mounted into our sidebar
 * instead, because in 0.23 the Style Manager renders at zero height inside it
 * and the Layers/Settings tabs come up empty.
 */
.page-builder__frame .gjs-editor {
    --gjs-left-width: 0px;
}

.page-builder__frame .gjs-pn-views,
.page-builder__frame .gjs-pn-views-container {
    display: none !important;
}

.page-builder__sidebar {
    flex: 0 0 320px;
    width: 320px;
    max-height: 680px;
    border-left: 1px solid var(--border);
    background: #fff;
    overflow-y: auto;
}

.page-builder__panel {
    border-bottom: 1px solid var(--border);
}

.page-builder__panel:last-child {
    border-bottom: none;
}

.page-builder__panel h4 {
    margin: 0;
    padding: 9px 12px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
    background: #fafafa;
    border-bottom: 1px solid var(--border);
}

.page-builder__panel-body {
    max-height: 300px;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px;
    background: #fff;
    color: var(--text-dark);
}

.page-builder__panel--blocks .page-builder__panel-body {
    max-height: 340px;
}

.page-builder__status {
    padding: 7px 12px;
    border-top: 1px solid var(--border);
    margin: 0;
}

.page-builder__error {
    margin: 0;
    border-radius: 0;
}

.page-builder__error[hidden] {
    display: none;
}

.admin-nav-submenu {
    margin-left: 24px;
    border-left: 1px solid rgba(255, 255, 255, .2);
}

.admin-nav-submenu .admin-nav-submenu-link {
    padding-left: 20px;
    font-size: 13px;
}

/* Media library panel (stands in for GrapesJS's unreachable Asset Manager). */
.page-builder__upload {
    display: block;
    width: 100%;
    margin-bottom: 8px;
    font-size: 12px;
}

.page-builder__upload-status {
    margin: 0 0 8px;
    font-size: 12px;
}

.page-builder__gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 6px;
}

.page-builder__tile {
    padding: 4px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    line-height: 0;
}

.page-builder__tile img {
    width: 100%;
    height: 52px;
    object-fit: cover;
    border-radius: 4px;
}

.page-builder__tile.is-active,
.page-builder__tile:hover {
    border-color: var(--green-primary);
}

/*
 * Re-skin GrapesJS's dark UI to match the light admin theme. Each rule targets a
 * class actually present in GrapesJS 0.23's markup; !important is needed because
 * grapes.min.css is bundled into the page after admin.css.
 */
.page-builder__frame .gjs-pn-commands,
.page-builder__frame .gjs-pn-devices-c,
.page-builder__frame .gjs-pn-options,
.page-builder__sidebar .gjs-blocks-cs,
.page-builder__sidebar .gjs-blocks-c,
.page-builder__sidebar .gjs-blocks-no-cat,
.page-builder__sidebar .gjs-blocks-categories,
.page-builder__sidebar .gjs-layers,
.page-builder__sidebar .gjs-sm-sectors,
.page-builder__sidebar .gjs-sm-sector,
.page-builder__sidebar .gjs-sm-properties,
.page-builder__sidebar .gjs-sm-property {
    background: #fff !important;
    color: var(--text-dark) !important;
    border-color: var(--border) !important;
}

.page-builder__frame .gjs-pn-button,
.page-builder__frame .gjs-pn-btn,
.page-builder__frame .gjs-sm-btn {
    background: #fafafa !important;
    border-color: var(--border) !important;
    color: var(--text-dark) !important;
}

/* Blocks Manager tiles. */
.page-builder__sidebar .gjs-blocks {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
    gap: 6px;
    padding: 0;
    margin: 0;
}

.page-builder__sidebar .gjs-block {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: center;
    justify-content: center;
    min-height: 58px;
    padding: 6px 4px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    color: var(--text-dark);
    font-size: 11px;
    font-weight: 500;
    line-height: 1.3;
    text-align: center;
    cursor: grab;
}

.page-builder__sidebar .gjs-block__media {
    width: 100%;
    margin: 0;
    color: var(--green-primary);
}

.page-builder__sidebar .gjs-block__media svg {
    display: block;
    width: 48px;
    height: 36px;
    margin: 0 auto;
}

.page-builder__sidebar .gjs-block:hover {
    border-color: var(--green-primary);
    color: var(--green-primary);
}

.page-builder__sidebar .gjs-title {
    background: #f4f6f5 !important;
    color: var(--text-muted) !important;
    border-bottom: 1px solid var(--border);
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.page-builder__sidebar .gjs-layer.gjs-selected,
.page-builder__sidebar .gjs-pn-item.gjs-active {
    background: #e8f1ec !important;
    color: var(--green-primary) !important;
}

.page-builder__sidebar .gjs-layer:hover,
.page-builder__sidebar .gjs-sm-title:hover {
    background: #f2f5f3 !important;
}

.page-builder__sidebar input,
.page-builder__sidebar select,
.page-builder__sidebar .gjs-field {
    background: #fff !important;
    color: var(--text-dark) !important;
    border: 1px solid var(--border) !important;
}

.page-builder__sidebar .gjs-sm-label {
    color: var(--text-muted);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.page-builder__sidebar .gjs-sm-property {
    border-bottom: 1px solid #eef1f0;
    padding-bottom: 8px;
    margin-bottom: 8px;
}

.page-builder__sidebar .gjs-sm-property:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

/* Single column: the padding/margin fields stack a value box + unit select, and
   forcing them into a grid clips the input ("auto" -> "at"). */
.page-builder__sidebar .gjs-field {
    min-width: 0;
    width: 100%;
}

.page-builder__sidebar .gjs-field select,
.page-builder__sidebar .gjs-field input {
    width: 100%;
    padding: 4px 6px;
    font-size: 12px;
}

.page-builder__sidebar .gjs-field-container {
    min-width: 0;
}

.page-builder__sidebar .gjs-sm-icon {
    color: inherit;
    font-size: inherit;
}

/* Narrow screens: stack the panels under the canvas. */
@media (max-width: 900px) {
    .page-builder__layout {
        flex-direction: column;
    }

    .page-builder__frame {
        height: 480px;
    }

    .page-builder__sidebar {
        flex: 1 1 auto;
        width: 100%;
        max-height: none;
        border-left: none;
        border-top: 1px solid var(--border);
    }

    .page-builder__panel-body {
        max-height: 260px;
    }
}
/* ===== CKEditor page editor (retained for reference) ===== */
.page-editor {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--white);
    overflow: hidden;
}

.page-editor:focus-within {
    border-color: var(--green-primary);
}

/* CKEditor removes its own frame; the wrapper above provides it. */
.page-editor .ck.ck-editor__editable_inline {
    min-height: 340px;
    max-height: 620px;
    overflow-y: auto;
    padding: 16px 18px;
    font-size: 15px;
    line-height: 1.7;
}

/*
 * CKEditor's bundled stylesheet is loaded after this file, so these overrides
 * need the extra `.ck.ck-editor` scope (and !important for the reset values it
 * applies) to win.
 */
.page-editor .ck.ck-editor .ck-editor__editable ul,
.page-editor .ck.ck-editor .ck-editor__editable ol {
    padding-left: 1.7em !important;
    margin: 0.8em 0;
}

.page-editor .ck.ck-editor .ck-editor__editable li + li {
    margin-top: 0.2em;
}

.page-editor .ck.ck-editor .ck-editor__editable blockquote {
    border-left: 4px solid var(--gold) !important;
    background: var(--bg) !important;
    padding: 8px 14px;
    margin: 1em 0;
    border-radius: 0 6px 6px 0;
}

.page-editor .ck.ck-editor .ck-editor__editable table {
    width: 100%;
    border-collapse: collapse;
    margin: 1em 0;
}

.page-editor .ck.ck-editor .ck-editor__editable td,
.page-editor .ck.ck-editor .ck-editor__editable th {
    border: 1px solid var(--border);
    padding: 7px 10px;
}

.page-editor .ck.ck-editor .ck-editor__editable img {
    max-width: 100%;
    height: auto;
}

.page-editor .ck.ck-editor .ck-editor__editable h2,
.page-editor .ck.ck-editor .ck-editor__editable h3,
.page-editor .ck.ck-editor .ck-editor__editable h4 {
    margin-top: 1.1em;
    margin-bottom: 0.4em;
    line-height: 1.3;
}

.page-editor .ck.ck-editor .ck-editor__editable > :first-child {
    margin-top: 0;
}

.page-editor .ck.ck-editor__top .ck-toolbar {
    background: #fafafa;
    border-bottom: 1px solid var(--border);
}

.page-editor .ck-content .ck-content__placeholder {
    color: var(--text-muted);
}

/* Show blocks only when the editor is not focused, so it never shows in output. */
.page-editor[data-page-editor-ready='true'] .ck-content__show-blocks::before {
    opacity: 0;
}

.page-editor__status {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 8px 8px;
    margin: 0;
}

.page-editor__note,
.page-editor__error {
    margin: 10px 0 0;
    font-size: 13px;
}

.form-actions {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

.btn-outline {
    background: var(--white);
    border: 1px solid var(--border);
    color: var(--text-dark);
}

.btn-outline:hover { background: var(--bg); }

.slug-code {
    background: var(--bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 12px;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.table-sub { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.badge-menu {
    display: inline-block;
    background: rgba(1, 65, 28, 0.1);
    color: var(--green-primary);
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
}

.status-draft   { background: #e9ecef; color: #495057; }
.status-published { background: #d4edda; color: #155724; }

/* ===== Responsive ===== */

/* Sidebar drawer toggle (hidden on desktop) */
.admin-nav-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border: 1px solid var(--border);
    background: var(--white);
    border-radius: 8px;
    cursor: pointer;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 0;
}

.admin-nav-toggle span {
    display: block;
    width: 18px;
    height: 2px;
    background: var(--green-dark);
    border-radius: 2px;
}

.admin-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 58;
}

/* Tablet: tighter spacing */
@media (max-width: 1024px) {
    .admin-sidebar { width: 210px; }
    .admin-main { margin-left: 210px; }
    .admin-content { padding: 22px; }
    .admin-header { padding: 14px 22px; }
}

/* Below this the sidebar becomes an off-canvas drawer */
@media (max-width: 860px) {
    .admin-sidebar {
        width: 250px;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        z-index: 59;
    }
    .admin-sidebar.open { transform: translateX(0); }
    .admin-main { margin-left: 0; }
    .admin-nav-toggle { display: flex; }
    .admin-header { padding: 12px 16px; gap: 12px; }
    .admin-header h1 { font-size: 17px; }
    .admin-content { padding: 16px; }
    .stats-grid { grid-template-columns: 1fr; gap: 14px; }
    .stat-card { padding: 18px; }
    .form-row { grid-template-columns: 1fr; gap: 0; }
    .form-checkboxes { padding-top: 0; }
    .admin-card { padding: 16px; }
    .admin-card-header { flex-wrap: wrap; gap: 10px; }
    .quick-actions { gap: 8px; }
    .quick-actions .btn { flex: 1 1 auto; justify-content: center; }

    .appointment-item { grid-template-columns: 1fr; gap: 10px; }
    .appointment-form-row { flex-wrap: wrap; }
    .appointment-form-row input { min-width: 0; flex: 1 1 100%; }
    .appointment-form-row select { flex: 1 1 auto; }
    .form-row-3 { grid-template-columns: 1fr; }
}

/* Phone: tables become stacked cards */
@media (max-width: 640px) {
    .admin-table.responsive-table,
    .admin-table.responsive-table tbody,
    .admin-table.responsive-table tr,
    .admin-table.responsive-table td {
        display: block;
        width: 100%;
    }

    .admin-table.responsive-table thead { display: none; }

    .admin-table.responsive-table tr {
        border: 1px solid var(--border);
        border-radius: 8px;
        margin-bottom: 12px;
        padding: 6px 0;
        background: var(--white);
    }

    .admin-table.responsive-table td {
        border-bottom: none;
        padding: 8px 14px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 12px;
        text-align: right;
    }

    .admin-table.responsive-table td::before {
        content: attr(data-label);
        font-size: 11px;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        color: var(--text-muted);
        text-align: left;
        flex-shrink: 0;
    }

    .admin-table.responsive-table td[data-label="Title"],
    .admin-table.responsive-table td[data-label="Description"] {
        font-weight: 600;
        white-space: normal;
    }

    .admin-table.responsive-table td.actions {
        justify-content: flex-end;
        padding-top: 12px;
    }
    .admin-table.responsive-table td.actions::before { margin-right: auto; }
    .admin-table.responsive-table tr:hover { background: var(--white); }
}

@media (max-width: 420px) {
    .admin-content { padding: 12px; }
    .login-box { padding: 26px 20px; }
    .admin-table.responsive-table td { flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; }
    .admin-table.responsive-table td.actions { flex-direction: row; align-items: center; }
    .quick-actions .btn { flex: 1 1 100%; }
    .stat-chip { padding: 7px 11px; font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}

/* ===== Settings hub (tabs, users, roles) ===== */
.settings-hub {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.settings-hub__tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px;
}

.settings-hub__tab {
    padding: 9px 16px;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
}

.settings-hub__tab:hover {
    background: #f2f5f3;
    color: var(--text-dark);
}

.settings-hub__tab.is-active {
    background: var(--green-primary);
    color: #fff;
}

/* Role permission matrix */
.role-perm-set {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px 14px;
    margin: 0 0 12px;
}

.role-perm-set legend {
    padding: 0 6px;
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.role-perm-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
    gap: 6px;
}

.role-perm-group {
    margin-bottom: 4px;
    line-height: 1.5;
}

.role-perm-group__name {
    display: inline-block;
    font-weight: 600;
    color: var(--text-dark);
}

.role-perm-group__name::after {
    content: ":";
}

.checkbox-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
}

.checkbox-row input[type="checkbox"] {
    width: 16px;
    height: 16px;
    flex: 0 0 auto;
}

.form-group--checkbox {
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    padding-bottom: 22px;
}

.badge-info {
    background: #e8f1ec;
    color: var(--green-primary);
}

.admin-table tr.is-inactive td {
    opacity: 0.62;
}

.table-actions form {
    display: inline;
}

@media (max-width: 700px) {
    .settings-hub__tabs {
        flex-direction: column;
    }

    .role-perm-grid {
        grid-template-columns: 1fr;
    }
}
/* ===== Configuration tab: backups ===== */
.backup-create-form {
    margin: 0 0 18px;
    padding: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: #f7faf8;
}

.form-group--submit {
    display: flex;
    align-items: flex-end;
    padding-bottom: 2px;
}

.backup-contents {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.backup-name {
    font-size: 12px;
    word-break: break-all;
}

.table-actions .d-inline {
    display: inline;
}

.config-list {
    display: grid;
    grid-template-columns: 160px 1fr;
    gap: 10px 16px;
    margin: 0;
}

.config-list dt {
    font-weight: 600;
    color: var(--text-dark);
}

.config-list dd {
    margin: 0;
    color: var(--text-muted);
}

.text-danger {
    color: #b42318;
}

@media (max-width: 700px) {
    .config-list {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .config-list dd {
        margin-bottom: 10px;
    }
}
/* ---- Variant classes used across the admin views ----
   These were referenced by the settings screens but never defined, so they
   rendered as unstyled text. */
.btn-secondary {
    background: #fff;
    color: var(--text-dark);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--bg);
    border-color: #c3ccc7;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.02em;
    background: #eef1ef;
    color: var(--text-muted);
}

.badge-warning {
    background: #fdf3e3;
    color: #93590a;
}

.badge-danger {
    background: #fdecea;
    color: #b42318;
}

.alert-warning {
    background: #fdf3e3;
    border-color: #f0d9a8;
    color: #7a4a08;
}

.alert-warning a { text-decoration: underline; font-weight: 600; }

/* ---- Modal ----
   A plain overlay, used by the backup restore confirmation. */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal[hidden] {
    display: none;
}

.modal-backdrop {
    /* Fixed rather than absolute: the backdrop is a flex child of .modal, so an
       absolute inset would size it to its content and leave it unclickable. */
    position: fixed;
    inset: 0;
    background: rgba(15, 26, 22, 0.55);
}

.modal-content {
    position: relative;
    z-index: 1;
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 10px;
    padding: 22px;
    box-shadow: 0 18px 48px rgba(15, 26, 22, 0.28);
}

.modal-content h3 {
    margin: 0 0 12px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 18px;
}
.note-inline {
    font-size: 13px;
    color: var(--text-muted);
    background: #fdf3e3;
    border: 1px solid #f0d9a8;
    border-radius: 7px;
    padding: 9px 12px;
    margin: 0 0 16px;
}
.btn.is-busy {
    position: relative;
    color: transparent;
}

.btn.is-busy::after {
    content: "";
    position: absolute;
    inset: 0;
    margin: auto;
    width: 15px;
    height: 15px;
    border: 2px solid rgba(255, 255, 255, 0.45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: btn-spin 0.7s linear infinite;
}

@keyframes btn-spin {
    to { transform: rotate(360deg); }
}
/* Slider trait switches */
.page-builder__sidebar .phc-trait-switch { display: inline-flex; align-items: center; gap: 10px; position: relative; cursor: pointer; padding: 6px 2px; margin: 0; }
.page-builder__sidebar .phc-trait-switch input { position: absolute; width: 1px; height: 1px; opacity: 0; padding: 0; margin: 0; }
.page-builder__sidebar .phc-trait-switch__track { display: block; width: 42px; height: 24px; border-radius: 999px; background: #8b949e; transition: background 180ms ease; flex-shrink: 0; }
.page-builder__sidebar .phc-trait-switch__track::before { content: ''; display: block; width: 18px; height: 18px; margin: 3px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px #0003; transition: transform 180ms ease; }
.page-builder__sidebar .phc-trait-switch input:checked + .phc-trait-switch__track { background: #087f5b; }
.page-builder__sidebar .phc-trait-switch input:checked + .phc-trait-switch__track::before { transform: translateX(18px); }
.page-builder__sidebar .phc-trait-switch input:focus-visible + .phc-trait-switch__track { outline: 2px solid #c8a24a; outline-offset: 3px; }
.page-builder__sidebar .phc-trait-switch__state { font-size: 12px; font-weight: 600; }
@media (prefers-reduced-motion: reduce) { .phc-trait-switch__track, .phc-trait-switch__track::before { transition: none !important; } }

/* Keep color swatches clickable alongside the full-width value inputs. */
.page-builder__sidebar .gjs-field-color { position: relative; }
.page-builder__sidebar .gjs-field-color .gjs-input-holder { width: calc(100% - 32px) !important; }
.page-builder__sidebar .gjs-field-colorp-c { position: absolute; right: 0; top: 0; width: 30px; height: 100%; z-index: 2; cursor: pointer; }
.page-builder__sidebar .gjs-field-color-picker { width: 100%; height: 100%; cursor: pointer; }
.sp-container.gjs-editor-sp { z-index: 10000000 !important; }
.page-builder__sidebar input[type="color"] { appearance: auto; display: block; min-height: 36px; padding: 2px !important; cursor: pointer; pointer-events: auto; }

.phc-color-button { width: 100%; min-height: 34px; border: 2px solid #ccc; border-radius: 4px; cursor: pointer; color: white; text-shadow: 0 1px 3px #000, 0 0 3px #000; }
.phc-color-dialog { position: fixed; z-index: 10000001; top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(340px, calc(100vw - 32px)); padding: 20px; background: white; color: #1a1a1a; border: 3px solid #01411c; border-radius: 10px; box-shadow: 0 0 0 100vmax #0005, 0 12px 40px #0005; display: grid; gap: 12px; }
.phc-color-dialog input { width: 100%; }
.phc-color-dialog button { cursor: pointer; padding: 8px; }
.phc-color-swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.phc-color-swatches button { height: 28px; border: 1px solid #999; border-radius: 4px; }

.internal-link-options { position: fixed; z-index: 10000002; max-height: 280px; overflow-y: auto; border: 1px solid #cbd5ce; border-radius: 6px; background: white; box-shadow: 0 8px 24px #0003; padding: 4px; color: #1a1a1a; }
.internal-link-options[hidden] { display: none; }
.internal-link-options [role="option"] { padding: 9px 12px; cursor: pointer; border-radius: 4px; }
.internal-link-options [role="option"]:hover, .internal-link-options [aria-selected="true"] { background: #e8f1ec; }
.internal-link-options strong, .internal-link-options span { display: block; font-size: 12px; }
.internal-link-options span { color: #666; margin-top: 3px; }

/* Saturation/value, hue and alpha picker shared by CMS editors. */
.phc-color-dialog { padding: 14px; width: min(390px, calc(100vw - 32px)); border: 1px solid #e5e7eb; gap: 9px; }
.phc-color-sv { position: relative; height: min(310px, 45vh); border-radius: 5px; overflow: hidden; touch-action: none; cursor: crosshair; background-image: linear-gradient(to top, #000, transparent), linear-gradient(to right, #fff, transparent); }
.phc-color-sv-marker { position: absolute; transform: translate(-50%, -50%); width: 22px; height: 22px; border: 2px solid white; border-radius: 5px; box-shadow: 0 0 2px #0008; pointer-events: none; }
.phc-color-dialog input[type="range"] { appearance: none; -webkit-appearance: none; height: 34px; padding: 0; margin: 0; border: 0; border-radius: 5px; cursor: pointer; background-size: 100% 100%, 12px 12px; }
.phc-color-hue { background: linear-gradient(to right, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00); }
.phc-color-dialog input[type="range"]::-webkit-slider-thumb { appearance: none; width: 14px; height: 42px; background: #ffffff30; border: 2px solid white; border-radius: 6px; box-shadow: 0 0 2px #0005; }
.phc-color-dialog input[type="range"]::-moz-range-thumb { width: 12px; height: 40px; background: #ffffff30; border: 2px solid white; border-radius: 6px; }
.phc-color-value { border: 1px solid #d1d5db; padding: 8px 10px; border-radius: 5px; }
.phc-color-sv:focus-visible, .phc-color-dialog input:focus-visible { outline: 2px solid #01411c; outline-offset: 2px; }

.searchable-content-link { position: relative; }
.searchable-content-link__options { position: absolute; left: 0; right: 0; top: 100%; z-index: 200; max-height: 320px; overflow-y: auto; background: white; border: 1px solid #cbd5ce; border-radius: 6px; box-shadow: 0 8px 24px #0002; margin-top: 4px; }
.searchable-content-link__options[hidden] { display: none; }
.searchable-content-link__options [role="option"] { padding: 10px 14px; cursor: pointer; }
.searchable-content-link__options [role="option"]:hover, .searchable-content-link__options [aria-selected="true"] { background: #e8f1ec; }
.searchable-content-link__group { padding: 8px 14px; font-size: 12px; font-weight: 700; background: #f5f7f6; color: #66756c; }

.phc-social-media[data-social-empty="1"]::before { content: "Add your social media URLs in Settings"; font-size: 14px; color: #66756c; padding: 16px; border: 1px dashed #9ca3af; }
