/*
 * admin.css — CustHive Admin Panel Stylesheet
 * Completely standalone; does NOT depend on site.css, sidebar.css, or topbar.css
 */

/* ── Google Font Import ──────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700;800&display=swap');

/* ── Design Tokens ───────────────────────────────────────────────────────── */
:root {
    --adm-bg:           #0A0D14;
    --adm-surface:      #111827;
    --adm-surface-2:    #1A2333;
    --adm-surface-3:    #1F2D40;
    --adm-border:       rgba(255,255,255,0.07);
    --adm-border-soft:  rgba(255,255,255,0.04);

    --adm-primary:      #6366F1;
    --adm-primary-glow: rgba(99,102,241,0.25);
    --adm-accent:       #8B5CF6;
    --adm-danger:       #EF4444;
    --adm-success:      #10B981;
    --adm-warning:      #F59E0B;
    --adm-info:         #3B82F6;

    --adm-text:         #F1F5F9;
    --adm-text-muted:   #94A3B8;
    --adm-text-dim:     #64748B;

    --adm-sidebar-w:    240px;
    --adm-topbar-h:     64px;
    --adm-radius:       14px;
    --adm-radius-sm:    8px;
    --adm-transition:   0.2s ease;

    --adm-gradient:     linear-gradient(135deg, #6366F1 0%, #8B5CF6 100%);
}

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

#admin-root {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--adm-bg);
    color: var(--adm-text);
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.5;
}

/* ── Topbar ──────────────────────────────────────────────────────────────── */
#adm-topbar {
    height: var(--adm-topbar-h);
    background: var(--adm-surface);
    border-bottom: 1px solid var(--adm-border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 100;
    flex-shrink: 0;
}

.adm-topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    flex-shrink: 0;
}

.adm-topbar-logo {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    background: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.adm-topbar-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--adm-text);
}

.adm-topbar-badge {
    background: var(--adm-primary-glow);
    color: var(--adm-primary);
    border: 1px solid var(--adm-primary);
    font-size: 0.62rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 20px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-left: 4px;
}

#adm-topbar-sep {
    width: 1px;
    height: 24px;
    background: var(--adm-border);
    flex-shrink: 0;
}

#adm-topbar-spacer { flex: 1; }

.adm-topbar-btn {
    background: var(--adm-surface-2);
    border: 1px solid var(--adm-border);
    color: var(--adm-text-muted);
    padding: 8px 16px;
    border-radius: var(--adm-radius-sm);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--adm-transition);
    font-family: inherit;
}

.adm-topbar-btn:hover {
    background: var(--adm-surface-3);
    color: var(--adm-text);
    border-color: rgba(255,255,255,0.12);
}

.adm-topbar-btn.danger:hover {
    background: rgba(239,68,68,0.12);
    color: var(--adm-danger);
    border-color: rgba(239,68,68,0.3);
}

/* ── Shell (Sidebar + Content) ───────────────────────────────────────────── */
#adm-shell {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
#adm-sidebar {
    width: var(--adm-sidebar-w);
    background: var(--adm-surface);
    border-right: 1px solid var(--adm-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--adm-border) transparent;
}

.adm-nav-section-title {
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--adm-text-dim);
    padding: 20px 20px 8px;
}

.adm-nav {
    list-style: none;
    padding: 0 10px;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.adm-nav-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--adm-radius-sm);
    color: var(--adm-text-muted);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--adm-transition);
    cursor: pointer;
    border: none;
    background: transparent;
    width: 100%;
    font-family: inherit;
}

.adm-nav-link:hover {
    background: var(--adm-surface-2);
    color: var(--adm-text);
}

.adm-nav-link.active {
    background: var(--adm-primary-glow);
    color: var(--adm-primary);
    font-weight: 600;
}

.adm-nav-link i {
    font-size: 1rem;
    flex-shrink: 0;
    width: 18px;
    text-align: center;
}

/* ── Main Content ────────────────────────────────────────────────────────── */
#adm-content {
    flex: 1;
    overflow-y: auto;
    padding: 28px 32px;
    scrollbar-width: thin;
    scrollbar-color: var(--adm-border) transparent;
}

/* ── Page Header ─────────────────────────────────────────────────────────── */
.adm-page-header {
    margin-bottom: 28px;
}

.adm-page-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--adm-text);
    margin-bottom: 4px;
    letter-spacing: -0.02em;
}

.adm-page-subtitle {
    font-size: 0.875rem;
    color: var(--adm-text-muted);
}

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

.adm-stat-card {
    background: var(--adm-surface);
    border: 1px solid var(--adm-border);
    border-radius: var(--adm-radius);
    padding: 22px 24px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: var(--adm-transition);
    position: relative;
    overflow: hidden;
}

.adm-stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 2px;
    background: var(--adm-gradient);
    opacity: 0;
    transition: var(--adm-transition);
}

.adm-stat-card:hover {
    border-color: rgba(99,102,241,0.3);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.adm-stat-card:hover::before { opacity: 1; }

.adm-stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.adm-stat-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--adm-text-muted);
}

.adm-stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
}

.adm-stat-value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--adm-text);
    line-height: 1;
    letter-spacing: -0.03em;
}

.adm-stat-sub {
    font-size: 0.75rem;
    color: var(--adm-text-dim);
}

/* Stat Color Variants */
.adm-stat-icon.purple  { background: rgba(99,102,241,0.15); color: var(--adm-primary); }
.adm-stat-icon.violet  { background: rgba(139,92,246,0.15); color: var(--adm-accent); }
.adm-stat-icon.green   { background: rgba(16,185,129,0.15); color: var(--adm-success); }
.adm-stat-icon.blue    { background: rgba(59,130,246,0.15); color: var(--adm-info); }
.adm-stat-icon.orange  { background: rgba(245,158,11,0.15); color: var(--adm-warning); }
.adm-stat-icon.red     { background: rgba(239,68,68,0.15);  color: var(--adm-danger); }

/* ── Section Card ────────────────────────────────────────────────────────── */
.adm-card {
    background: var(--adm-surface);
    border: 1px solid var(--adm-border);
    border-radius: var(--adm-radius);
    overflow: hidden;
}

.adm-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--adm-border);
    gap: 12px;
}

.adm-card-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--adm-text);
}

.adm-card-body { padding: 24px; }

/* ── Toolbar (search + actions) ──────────────────────────────────────────── */
.adm-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.adm-search-wrap {
    display: flex;
    align-items: center;
    background: var(--adm-surface-2);
    border: 1px solid var(--adm-border);
    border-radius: var(--adm-radius-sm);
    padding: 0 12px;
    gap: 8px;
    flex: 1;
    min-width: 220px;
    max-width: 380px;
    transition: var(--adm-transition);
}

.adm-search-wrap:focus-within {
    border-color: var(--adm-primary);
    box-shadow: 0 0 0 3px var(--adm-primary-glow);
}

.adm-search-wrap i {
    color: var(--adm-text-dim);
    font-size: 0.9rem;
}

.adm-search-input {
    background: none;
    border: none;
    outline: none;
    color: var(--adm-text);
    font-size: 0.875rem;
    font-family: inherit;
    padding: 9px 0;
    width: 100%;
}

.adm-search-input::placeholder { color: var(--adm-text-dim); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.adm-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 16px;
    border-radius: var(--adm-radius-sm);
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--adm-transition);
    border: 1px solid transparent;
    font-family: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.adm-btn-primary {
    background: var(--adm-gradient);
    color: white;
    border-color: transparent;
    box-shadow: 0 2px 8px rgba(99,102,241,0.3);
}

.adm-btn-primary:hover {
    opacity: 0.88;
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(99,102,241,0.4);
}

.adm-btn-ghost {
    background: var(--adm-surface-2);
    color: var(--adm-text-muted);
    border-color: var(--adm-border);
}

.adm-btn-ghost:hover {
    background: var(--adm-surface-3);
    color: var(--adm-text);
}

.adm-btn-danger {
    background: rgba(239,68,68,0.12);
    color: var(--adm-danger);
    border-color: rgba(239,68,68,0.25);
}

.adm-btn-danger:hover {
    background: rgba(239,68,68,0.2);
    border-color: rgba(239,68,68,0.4);
}

.adm-btn-sm {
    padding: 5px 12px;
    font-size: 0.77rem;
}

/* ── Table ───────────────────────────────────────────────────────────────── */
.adm-table-wrap {
    overflow-x: auto;
}

.adm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.adm-table thead th {
    text-align: left;
    padding: 12px 16px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--adm-text-dim);
    border-bottom: 1px solid var(--adm-border);
    background: var(--adm-surface-2);
    white-space: nowrap;
}

.adm-table tbody tr {
    border-bottom: 1px solid var(--adm-border-soft);
    transition: var(--adm-transition);
}

.adm-table tbody tr:hover {
    background: var(--adm-surface-2);
}

.adm-table tbody tr:last-child {
    border-bottom: none;
}

.adm-table tbody td {
    padding: 14px 16px;
    color: var(--adm-text);
    vertical-align: middle;
}

.adm-table tbody td.muted {
    color: var(--adm-text-muted);
    font-size: 0.82rem;
}

/* ── Badges ──────────────────────────────────────────────────────────────── */
.adm-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 0.72rem;
    font-weight: 700;
}

.adm-badge-purple { background: rgba(99,102,241,0.15); color: var(--adm-primary); }
.adm-badge-green  { background: rgba(16,185,129,0.15); color: var(--adm-success); }
.adm-badge-blue   { background: rgba(59,130,246,0.15); color: var(--adm-info); }
.adm-badge-ghost  { background: var(--adm-surface-3); color: var(--adm-text-muted); }

/* ── Modal Overlay ───────────────────────────────────────────────────────── */
.adm-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.adm-modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.adm-modal {
    background: var(--adm-surface);
    border: 1px solid var(--adm-border);
    border-radius: var(--adm-radius);
    width: 560px;
    max-width: 95vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: translateY(16px) scale(0.97);
    transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1);
    box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}

.adm-modal-overlay.open .adm-modal {
    transform: translateY(0) scale(1);
}

.adm-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--adm-border);
    flex-shrink: 0;
}

.adm-modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--adm-text);
}

.adm-modal-close {
    background: none;
    border: none;
    color: var(--adm-text-dim);
    cursor: pointer;
    font-size: 1.2rem;
    padding: 4px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    transition: var(--adm-transition);
    line-height: 1;
}

.adm-modal-close:hover {
    background: var(--adm-surface-2);
    color: var(--adm-text);
}

.adm-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.adm-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    border-top: 1px solid var(--adm-border);
    flex-shrink: 0;
}

/* ── Form Elements ───────────────────────────────────────────────────────── */
.adm-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.adm-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 16px;
}

.adm-form-group:last-child { margin-bottom: 0; }

.adm-form-label {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--adm-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.adm-form-input {
    background: var(--adm-surface-2);
    border: 1px solid var(--adm-border);
    border-radius: var(--adm-radius-sm);
    padding: 10px 14px;
    color: var(--adm-text);
    font-size: 0.875rem;
    font-family: inherit;
    outline: none;
    transition: var(--adm-transition);
    width: 100%;
}

.adm-form-input:focus {
    border-color: var(--adm-primary);
    box-shadow: 0 0 0 3px var(--adm-primary-glow);
}

.adm-form-input::placeholder { color: var(--adm-text-dim); }

/* ── Confirm Delete Dialog ───────────────────────────────────────────────── */
.adm-confirm-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.adm-confirm-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.adm-confirm-box {
    background: var(--adm-surface);
    border: 1px solid var(--adm-border);
    border-radius: var(--adm-radius);
    padding: 32px;
    max-width: 400px;
    width: 95vw;
    text-align: center;
    transform: scale(0.94);
    transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1);
    box-shadow: 0 24px 64px rgba(0,0,0,0.5);
}

.adm-confirm-overlay.open .adm-confirm-box { transform: scale(1); }

.adm-confirm-icon {
    font-size: 2.5rem;
    color: var(--adm-danger);
    margin-bottom: 16px;
}

.adm-confirm-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--adm-text);
    margin-bottom: 8px;
}

.adm-confirm-message {
    font-size: 0.875rem;
    color: var(--adm-text-muted);
    line-height: 1.6;
    margin-bottom: 24px;
}

.adm-confirm-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* ── Toast ───────────────────────────────────────────────────────────────── */
#adm-toast-container {
    position: fixed;
    bottom: 28px;
    right: 28px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 9999;
    pointer-events: none;
}

.adm-toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 18px;
    border-radius: 12px;
    background: var(--adm-surface);
    border: 1px solid var(--adm-border);
    color: var(--adm-text);
    font-family: 'Inter', sans-serif;
    font-size: 0.875rem;
    font-weight: 500;
    min-width: 260px;
    max-width: 380px;
    pointer-events: all;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    animation: adm-toast-in 0.3s cubic-bezier(0.34,1.56,0.64,1) forwards;
    opacity: 0;
}

.adm-toast.adm-toast-out {
    animation: adm-toast-out 0.25s ease forwards;
}

.adm-toast-icon { font-size: 1.1rem; flex-shrink: 0; }
.adm-toast.success .adm-toast-icon { color: var(--adm-success); }
.adm-toast.error   .adm-toast-icon { color: var(--adm-danger); }
.adm-toast.info    .adm-toast-icon { color: var(--adm-info); }

@keyframes adm-toast-in  { from { opacity:0; transform:translateX(24px); } to { opacity:1; transform:translateX(0); } }
@keyframes adm-toast-out { from { opacity:1; transform:translateX(0); }  to { opacity:0; transform:translateX(16px); } }

/* ── Empty State ─────────────────────────────────────────────────────────── */
.adm-empty-state {
    padding: 60px 20px;
    text-align: center;
    color: var(--adm-text-dim);
}

.adm-empty-icon {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.35;
}

.adm-empty-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--adm-text-muted);
    margin-bottom: 6px;
}

.adm-empty-sub {
    font-size: 0.82rem;
    color: var(--adm-text-dim);
}

/* ── Loading Skeleton ────────────────────────────────────────────────────── */
.adm-skeleton {
    background: linear-gradient(90deg, var(--adm-surface-2) 25%, var(--adm-surface-3) 50%, var(--adm-surface-2) 75%);
    background-size: 200% 100%;
    animation: adm-skeleton-anim 1.4s infinite linear;
    border-radius: 4px;
}

@keyframes adm-skeleton-anim {
    0%   { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Scrollbar ───────────────────────────────────────────────────────────── */
#adm-content::-webkit-scrollbar,
#adm-sidebar::-webkit-scrollbar {
    width: 5px;
}

#adm-content::-webkit-scrollbar-track,
#adm-sidebar::-webkit-scrollbar-track { background: transparent; }

#adm-content::-webkit-scrollbar-thumb,
#adm-sidebar::-webkit-scrollbar-thumb {
    background: var(--adm-border);
    border-radius: 3px;
}

/* ── Org Avatar ──────────────────────────────────────────────────────────── */
.adm-org-avatar {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    background: var(--adm-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
    letter-spacing: 0.04em;
}

.adm-org-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.adm-org-name {
    font-weight: 600;
    color: var(--adm-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.adm-org-owner {
    font-size: 0.78rem;
    color: var(--adm-text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── Stats Actions Row ───────────────────────────────────────────────────── */
.adm-stat-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
    color: var(--adm-text-muted);
}

.adm-stat-row i { font-size: 0.9rem; }

/* ── Topbar dropdown item for admin ─────────────────────────────────────── */
.topbar-dropdown-item--admin {
    color: var(--ch-primary, #8B5CF6) !important;
}

.topbar-dropdown-item--admin:hover {
    background: rgba(139, 92, 246, 0.08) !important;
}

/* ── Hide admin-only elements by default ─────────────────────────────────── */
.ch-admin-only {
    display: none;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    #adm-sidebar { display: none; }
    #adm-content { padding: 16px; }
    .adm-stats-grid { grid-template-columns: 1fr 1fr; }
    .adm-form-row { grid-template-columns: 1fr; }
    .adm-topbar-title { display: none; }
}

@media (max-width: 480px) {
    .adm-stats-grid { grid-template-columns: 1fr; }
}
