/* ═══════════════════════════════════════════
   1MinuteHQ — Tenant Admin Panel
   Matches 1MinuteReel / 1MinuteFunnel design
   ═══════════════════════════════════════════ */

/* ── CSS Variables ── */
:root {
    /* Brand Colors */
    --hq-primary: #6366f1;
    --hq-primary-dark: #4f46e5;
    --hq-primary-light: #818cf8;
    --hq-primary-bg: #eef2ff;
    --hq-accent: #8b5cf6;

    /* Semantic Colors */
    --hq-success: #22c55e;
    --hq-success-bg: #f0fdf4;
    --hq-warning: #f59e0b;
    --hq-warning-bg: #fffbeb;
    --hq-danger: #ef4444;
    --hq-danger-bg: #fef2f2;

    /* Neutrals */
    --hq-bg: #f8fafc;
    --hq-surface: #ffffff;
    --hq-surface-hover: #f1f5f9;
    --hq-border: #e2e8f0;
    --hq-border-light: #f1f5f9;
    --hq-text: #0f172a;
    --hq-text-muted: #64748b;
    --hq-text-light: #94a3b8;

    /* Layout */
    --hq-radius: 12px;
    --hq-radius-sm: 8px;
    --hq-radius-xs: 6px;
    --sidebar-width: 240px;

    /* Shadows */
    --hq-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --hq-shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --hq-shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --hq-shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 1rem;
    color: var(--hq-text);
    background: var(--hq-bg);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--hq-primary); text-decoration: none; }
a:hover { color: var(--hq-primary-dark); }

/* ── Layout ── */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ── */
.admin-sidebar {
    width: var(--sidebar-width);
    background: var(--hq-surface);
    border-right: 1px solid var(--hq-border);
    padding: 20px 0;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
}

.admin-sidebar-header {
    padding: 0 20px 20px;
    border-bottom: 1px solid var(--hq-border);
    margin-bottom: 12px;
}

.admin-sidebar-header h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--hq-text);
}

.admin-sidebar-header .tenant-label {
    font-size: 12px;
    color: var(--hq-text-muted);
}

.admin-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    color: var(--hq-text-muted);
    font-size: 14px;
    transition: all 100ms ease;
    text-decoration: none;
}
.admin-nav a:hover {
    background: var(--hq-surface-hover);
    color: var(--hq-text);
}
.admin-nav a.active {
    background: var(--hq-primary-bg);
    color: var(--hq-primary);
    border-right: 2px solid var(--hq-primary);
    font-weight: 500;
}

.admin-nav-section {
    padding: 16px 20px 6px;
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--hq-text-light);
    font-weight: 600;
}

/* ── Main content ── */
.admin-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 32px 40px;
}

.admin-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
}

.admin-page-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--hq-text);
}

/* ── Stats cards ── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--hq-surface);
    border: 1px solid var(--hq-border);
    border-radius: var(--hq-radius);
    padding: 20px;
    box-shadow: var(--hq-shadow-sm);
}

.stat-card-label {
    font-size: 12px;
    color: var(--hq-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.stat-card-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--hq-text);
}

.stat-card-change {
    font-size: 12px;
    margin-top: 4px;
}
.stat-card-change.positive { color: var(--hq-success); }
.stat-card-change.negative { color: var(--hq-danger); }

/* ── Tables ── */
.admin-table-wrapper {
    background: var(--hq-surface);
    border: 1px solid var(--hq-border);
    border-radius: var(--hq-radius);
    overflow: hidden;
    box-shadow: var(--hq-shadow-sm);
}

.admin-table-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--hq-border);
}

.admin-table-toolbar input {
    padding: 8px 12px;
    background: var(--hq-surface);
    border: 1px solid var(--hq-border);
    border-radius: var(--hq-radius-sm);
    color: var(--hq-text);
    font-size: 13px;
    width: 260px;
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}
.admin-table-toolbar input:focus {
    border-color: var(--hq-primary);
    box-shadow: 0 0 0 3px var(--hq-primary-bg);
}
.admin-table-toolbar input::placeholder { color: var(--hq-text-light); }

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 12px 20px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--hq-text-muted);
    border-bottom: 1px solid var(--hq-border);
    font-weight: 600;
    background: var(--hq-surface-hover);
}

td {
    padding: 14px 20px;
    font-size: 14px;
    border-bottom: 1px solid var(--hq-border);
    color: var(--hq-text);
}

tr:hover td { background: var(--hq-surface-hover); }
tr:last-child td { border-bottom: none; }

/* ── Forms ── */
.admin-form {
    max-width: 560px;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--hq-text);
}

.form-hint {
    font-size: 12px;
    color: var(--hq-text-light);
    margin-top: 4px;
}

.form-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--hq-surface);
    border: 1px solid var(--hq-border);
    border-radius: var(--hq-radius-sm);
    color: var(--hq-text);
    font-size: 14px;
    outline: none;
    transition: border-color 150ms ease, box-shadow 150ms ease;
}
.form-input:focus {
    border-color: var(--hq-primary);
    box-shadow: 0 0 0 3px var(--hq-primary-bg);
}
.form-input::placeholder { color: var(--hq-text-light); }

select.form-input {
    appearance: none;
    cursor: pointer;
}

textarea.form-input {
    min-height: 80px;
    resize: vertical;
}

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--hq-radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 150ms ease;
    line-height: 1;
    white-space: nowrap;
}
.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--hq-shadow-sm);
}

.btn-primary { background: var(--hq-primary); color: white; }
.btn-primary:hover:not(:disabled) { background: var(--hq-primary-dark); }
.btn-secondary {
    background: var(--hq-surface);
    color: var(--hq-text);
    border: 1px solid var(--hq-border);
}
.btn-secondary:hover:not(:disabled) { background: var(--hq-surface-hover); }
.btn-danger { background: var(--hq-danger); color: white; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ── Badges ── */
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--hq-radius-xs);
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.3px;
}
.badge-active { background: var(--hq-success-bg); color: #16a34a; }
.badge-trialing { background: var(--hq-warning-bg); color: #d97706; }
.badge-cancelled { background: var(--hq-danger-bg); color: var(--hq-danger); }
.badge-expired { background: #f1f5f9; color: var(--hq-text-light); }

/* ── Color preview ── */
.color-preview {
    display: inline-block;
    width: 20px;
    height: 20px;
    border-radius: 4px;
    vertical-align: middle;
    margin-right: 6px;
    border: 1px solid var(--hq-border);
}

/* ── Loading ── */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--hq-border);
    border-top-color: var(--hq-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Modal ── */
.admin-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.admin-modal {
    background: var(--hq-surface);
    border: 1px solid var(--hq-border);
    border-radius: var(--hq-radius);
    padding: 32px;
    max-width: 480px;
    width: 100%;
    box-shadow: var(--hq-shadow-xl);
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .admin-sidebar { display: none; }
    .admin-main { margin-left: 0; padding: 20px 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}
