/* Call Back Clinic — Admin Panel Design System
   Placeholder brand palette until the real logo is provided — swap the --brand-* variables
   below once you have exact colors from your logo file. */

:root {
    --brand-primary: #081b4c;      /* navy - primary actions, links */
    --brand-primary-dark: #050f2e;
    --brand-gold: #e6991c;         /* gold - accents, highlights */
    --brand-green: #20773f;
    --brand-navy: #081b4c;         /* headers, wordmark */
    --brand-bg: #f4f1ea;
    --surface: #ffffff;
    --border: #e2e8f0;
    --text: #1e293b;
    --text-muted: #64748b;
    --success-bg: #e7f5ec; --success-text: #20773f;
    --warning-bg: #fdf0dc; --warning-text: #b3720f;
    --danger-bg: #fee2e2;  --danger-text: #991b1b;
    --neutral-bg: #e2e8f0; --neutral-text: #475569;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(8,27,76,0.06), 0 10px 24px rgba(8,27,76,0.07);
    --font-display: 'Space Grotesk', sans-serif;
    --font-body: 'Manrope', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
}

* { box-sizing: border-box; }

body {
    font-family: var(--font-body);
    background: var(--brand-bg);
    color: var(--text);
    margin: 0;
    padding: 0;
}

h1, h2, h3, h4 { font-family: var(--font-display); color: var(--brand-navy); letter-spacing: -0.01em; }

.admin-shell { max-width: 1160px; margin: 0 auto; padding: 22px 24px 40px; }

/* --- Top bar / brand --- */
.admin-topbar {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 26px; margin-bottom: 20px;
    background: var(--surface); color: var(--brand-navy); border-radius: var(--radius);
    box-shadow: var(--shadow); border: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 20px; font-family: var(--font-display); color: var(--brand-navy); }
.brand-mark { height: 34px; }
.admin-topbar a.logout-link {
    color: var(--brand-navy); text-decoration: none; font-size: 14px; font-weight: 600;
    padding: 8px 16px; border-radius: 999px; border: 1px solid rgba(8,27,76,0.18);
    transition: all 0.15s;
}
.admin-topbar a.logout-link:hover { background: rgba(8,27,76,0.06); border-color: var(--brand-navy); }

/* --- Section headings with icon accent --- */
.section-title {
    display: flex; align-items: center; gap: 10px;
    font-family: var(--font-display); font-size: 19px; font-weight: 700; color: var(--brand-navy);
    margin-bottom: 4px;
}
.section-title .icon-badge {
    width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center;
    background: var(--brand-bg); font-size: 15px; flex-shrink: 0;
}

/* --- Auth pages (login / setup) --- */
.auth-wrap { max-width: 400px; margin: 80px auto; padding: 0 20px; }
.auth-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 32px; box-shadow: var(--shadow); }
.auth-brand { text-align: center; margin-bottom: 24px; }
.auth-brand .brand-mark { margin: 0 auto 12px; height: 48px; width: auto; }
.auth-brand h2 { margin: 0; color: var(--brand-navy); }

/* --- Cards --- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; margin-bottom: 20px; box-shadow: var(--shadow); }
.card h3 { margin-top: 0; }

/* --- Collapsible sections (native <details>/<summary> - no JS needed, so nothing to break) --- */
details.collapsible summary { cursor: pointer; list-style: none; }
details.collapsible summary::-webkit-details-marker { display: none; }
details.collapsible summary::after {
    content: '+'; margin-left: auto; font-size: 20px; color: var(--text-muted); font-weight: 400;
}
details.collapsible[open] summary::after { content: '−'; }
details.collapsible summary { display: flex; align-items: center; }
details.collapsible form { margin-top: 18px; }

.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }
.two-col .card { margin-bottom: 0; }
@media (max-width: 900px) {
    .two-col { grid-template-columns: 1fr; }
}

/* --- Stat summary strip --- */
.stat-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 10px; margin-bottom: 18px; }
.stat-card {
    background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 14px 16px; text-align: left; text-decoration: none; color: inherit; box-shadow: var(--shadow);
    transition: border-color 0.15s;
}
.stat-card:hover { border-color: var(--brand-primary); }
.stat-card.active-filter { border-color: var(--brand-primary); border-width: 2px; }
.stat-value { font-size: 24px; font-weight: 700; color: var(--brand-navy); font-family: var(--font-display); }
.stat-label { font-size: 12.5px; color: var(--text-muted); margin-top: 1px; }

/* --- Forms --- */
label { display: block; font-size: 13px; color: var(--text-muted); margin-top: 12px; font-weight: 500; }
input, select, textarea {
    width: 100%; padding: 9px 10px; border: 1px solid var(--border); border-radius: 6px;
    margin-top: 4px; font-family: inherit; font-size: 14px; background: white;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--brand-primary); }
button, .btn {
    padding: 9px 16px; background: var(--brand-primary); color: white; border: none;
    border-radius: 6px; cursor: pointer; font-size: 14px; font-weight: 500; margin-top: 4px;
    display: inline-block; text-decoration: none;
}
button:hover, .btn:hover { background: var(--brand-primary-dark); }
button.secondary, .btn.secondary { background: var(--neutral-bg); color: var(--text); }
button.secondary:hover { background: #cbd5e1; }
.btn-block { width: 100%; justify-content: center; text-align: center; }
button.danger { background: var(--danger-text); }
button.danger:hover { background: #7a1515; }

/* --- Search / filter bar --- */
.search-bar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.search-bar input[type="text"] { flex: 1; min-width: 220px; margin-top: 0; }
.filter-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 20px; }
.filter-tab {
    padding: 6px 14px; border-radius: 20px; font-size: 13px; text-decoration: none;
    color: var(--text-muted); background: var(--surface); border: 1px solid var(--border);
}
.filter-tab.active { background: var(--brand-navy); color: white; border-color: var(--brand-navy); }

/* --- Table --- */
table { width: 100%; border-collapse: collapse; background: var(--surface); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }
th { background: #f1f5f9; font-weight: 600; color: var(--text-muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.03em; }
tr:last-child td { border-bottom: none; }

.badge { padding: 3px 10px; border-radius: 12px; font-size: 12px; font-weight: 600; display: inline-block; }
.badge-trial { background: var(--warning-bg); color: var(--warning-text); }
.badge-active { background: var(--success-bg); color: var(--success-text); }
.badge-expired { background: var(--danger-bg); color: var(--danger-text); }
.badge-cancelled { background: var(--neutral-bg); color: var(--neutral-text); }
.badge-expiring { background: #fff2df; color: #b3720f; }

.msg { background: var(--success-bg); color: var(--success-text); padding: 12px 16px; border-radius: var(--radius); margin-bottom: 20px; }
.error { background: var(--danger-bg); color: var(--danger-text); padding: 12px 16px; border-radius: var(--radius); }

.key { font-family: var(--font-mono); font-size: 13px; }
.actions form { display: inline-block; margin-right: 4px; margin-bottom: 4px; }
.actions a { text-decoration: none; }
.muted { color: var(--text-muted); font-size: 13px; }
.readonly-box { background: #f1f5f9; padding: 12px 16px; border-radius: var(--radius); font-size: 14px; margin-top: 14px; }

/* ============================================
   Table horizontal scroll (for wide tables like the clinics list -
   simpler and more reliable on a data table than reflowing into cards)
   ============================================ */
.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; border-radius: var(--radius); }
.table-scroll table { min-width: 700px; }
.table-scroll table.billing-table { min-width: 0; } /* only 3 narrow columns - never needs horizontal scroll */
/* Reverted the sticky-header + max-height scroll trick tried here before - it broke on
   mobile (combined with the horizontal scroll the table already needs, it produced a large
   blank gap instead of the intended compact scrolling box). Simple horizontal scroll only,
   which is proven to work, rather than a fancier pattern I can't actually verify. */

/* ============================================
   Responsive breakpoints - admin panel + customer portal
   ============================================ */
@media (max-width: 780px) {
    /* Clinics table -> stacked cards. A horizontally-scrolling 8-column table is a
       compromise, not genuinely mobile-friendly - this removes the sideways scroll
       entirely by turning each row into its own labeled card instead. */
    .table-scroll { overflow-x: visible; }
    table.clinics-table { min-width: 0; box-shadow: none; background: transparent; border-radius: 0; }
    table.clinics-table tr:first-child { display: none; } /* the <th> header row - labels now show per-field instead */
    table.clinics-table, table.clinics-table tbody, table.clinics-table tr, table.clinics-table td {
        display: block; width: 100%;
    }
    table.clinics-table tr {
        background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
        box-shadow: var(--shadow); padding: 4px 14px; margin-bottom: 12px;
    }
    table.clinics-table td {
        border-bottom: 1px solid var(--border); padding: 10px 0;
        display: flex; flex-direction: column; gap: 3px;
    }
    table.clinics-table td:last-child { border-bottom: none; }
    table.clinics-table td::before {
        content: attr(data-label); font-size: 11px; font-weight: 700; text-transform: uppercase;
        letter-spacing: 0.03em; color: var(--text-muted);
    }

    th, td { padding: 8px 10px; font-size: 13px; }
    .admin-shell { padding: 0 14px 32px; }

    .admin-topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
        padding: 16px;
    }

    .stat-grid { grid-template-columns: repeat(3, 1fr); gap: 6px; }
    .stat-card { padding: 8px 9px; }
    .stat-value { font-size: 17px; }
    .stat-label { font-size: 9.5px; line-height: 1.2; }

    .search-bar { flex-direction: column; align-items: stretch; }
    .search-bar input[type="text"] { width: 100%; }

    .actions { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; }
    .actions form { margin-right: 0; width: 100%; }
    .actions form button { width: 100%; }

    button, .btn { padding: 12px 16px; }

    .card { padding: 16px; }

    .auth-wrap { margin: 40px auto; padding: 0 16px; }
    .auth-card { padding: 24px; }
}

@media (max-width: 480px) {
    .brand { font-size: 17px; }
    .filter-tabs { gap: 6px; }
    .filter-tab { font-size: 12px; padding: 5px 10px; }
}
