/* ================================================================
   GLOBALLINK BPO — Admin Panel Styles
   Design: Dark sidebar + light content (enterprise SaaS pattern)
   ================================================================ */

/* ── Reset & Variables ─────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --sidebar-w:      240px;
    --topbar-h:       60px;
    --sidebar-bg:     #0f172a;
    --sidebar-hover:  #1e293b;
    --sidebar-active: #1d4ed8;
    --sidebar-text:   #94a3b8;
    --sidebar-text-a: #f1f5f9;
    --content-bg:     #f1f5f9;
    --card-bg:        #ffffff;
    --border:         #e2e8f0;
    --primary:        #1d4ed8;
    --primary-hover:  #1e40af;
    --success:        #10b981;
    --warning:        #f59e0b;
    --danger:         #ef4444;
    --danger-hover:   #dc2626;
    --text-1:         #0f172a;
    --text-2:         #475569;
    --text-3:         #94a3b8;
    --shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:      0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -1px rgba(0,0,0,.06);
    --radius:         8px;
    --radius-lg:      12px;
    --font:           'Inter', system-ui, -apple-system, sans-serif;
}

html { font-size: 15px; }
body { font-family: var(--font); background: var(--content-bg); color: var(--text-1); line-height: 1.5; }
a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
button { font-family: var(--font); cursor: pointer; }
input, select, textarea { font-family: var(--font); }

/* ── App Shell ─────────────────────────────────────────────── */
.app-shell {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
    transition: transform .2s ease;
}

.sidebar-logo {
    padding: 20px 20px 16px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.sidebar-logo .logo-mark {
    display: flex;
    align-items: center;
    gap: 10px;
}
.logo-icon {
    width: 36px; height: 36px;
    background: var(--primary);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; color: white; font-size: 16px; flex-shrink: 0;
}
.logo-text { color: var(--sidebar-text-a); font-weight: 700; font-size: .95rem; line-height: 1.2; }
.logo-sub  { color: var(--sidebar-text); font-size: .72rem; font-weight: 400; }

.sidebar-nav { flex: 1; padding: 12px 10px; overflow-y: auto; }

.nav-group-label {
    color: var(--text-3);
    font-size: .68rem;
    font-weight: 600;
    letter-spacing: .08em;
    text-transform: uppercase;
    padding: 16px 10px 6px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 12px;
    border-radius: var(--radius);
    color: var(--sidebar-text);
    font-size: .875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background .15s, color .15s;
    margin-bottom: 2px;
    border: none; background: none; width: 100%; text-align: left;
}
.nav-item:hover  { background: var(--sidebar-hover); color: var(--sidebar-text-a); }
.nav-item.active { background: var(--sidebar-active); color: #fff; }
.nav-item .nav-icon { font-size: 1.1rem; flex-shrink: 0; width: 20px; text-align: center; }
.nav-badge {
    margin-left: auto;
    background: var(--primary);
    color: white;
    font-size: .68rem;
    padding: 2px 7px;
    border-radius: 20px;
}

.sidebar-footer {
    padding: 12px 10px 16px;
    border-top: 1px solid rgba(255,255,255,.06);
}
.sidebar-user {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border-radius: var(--radius);
}
.user-avatar {
    width: 32px; height: 32px;
    background: var(--primary);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: white; font-size: .8rem; font-weight: 700; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-name  { color: var(--sidebar-text-a); font-size: .82rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role  { color: var(--sidebar-text); font-size: .72rem; }
.btn-logout { background: none; border: none; color: var(--sidebar-text); font-size: 1rem; padding: 4px; border-radius: 4px; cursor: pointer; }
.btn-logout:hover { color: var(--danger); }

/* ── Main Content ──────────────────────────────────────────── */
.main-content {
    margin-left: var(--sidebar-w);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    height: var(--topbar-h);
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 16px;
}
.topbar-title { font-size: 1.05rem; font-weight: 600; color: var(--text-1); flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 10px; }

.page-content { padding: 28px; flex: 1; }

/* ── Cards ─────────────────────────────────────────────────── */
.card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}
.card-header {
    padding: 18px 22px 0;
    display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: 1rem; font-weight: 600; color: var(--text-1); }
.card-body  { padding: 18px 22px; }

/* ── Stat Cards ────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    box-shadow: var(--shadow-sm);
}
.stat-icon {
    width: 44px; height: 44px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
    margin-bottom: 12px;
}
.stat-icon.blue   { background: #dbeafe; }
.stat-icon.green  { background: #d1fae5; }
.stat-icon.purple { background: #ede9fe; }
.stat-icon.orange { background: #ffedd5; }
.stat-value { font-size: 1.8rem; font-weight: 700; color: var(--text-1); line-height: 1; }
.stat-label { font-size: .8rem; color: var(--text-2); margin-top: 4px; }

/* ── Buttons ───────────────────────────────────────────────── */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius);
    font-size: .875rem; font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: background .15s, opacity .15s;
    white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover:not(:disabled) { background: var(--primary-hover); }
.btn-secondary { background: #fff; color: var(--text-1); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--content-bg); }
.btn-danger   { background: var(--danger); color: #fff; border-color: var(--danger); }
.btn-danger:hover:not(:disabled) { background: var(--danger-hover); }
.btn-success  { background: var(--success); color: #fff; border-color: var(--success); }
.btn-ghost    { background: transparent; color: var(--text-2); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { background: var(--content-bg); }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.btn-lg { padding: 11px 22px; font-size: 1rem; }
.btn-icon { padding: 7px; }
.btn-loading::after {
    content: '';
    width: 14px; height: 14px;
    border: 2px solid rgba(255,255,255,.4);
    border-top-color: white;
    border-radius: 50%;
    animation: spin .6s linear infinite;
    display: inline-block;
}

/* ── Forms ─────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: .84rem; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.form-input, .form-select, .form-textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: .9rem;
    color: var(--text-1);
    background: white;
    transition: border-color .15s, box-shadow .15s;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(29,78,216,.1);
}
.form-hint { font-size: .78rem; color: var(--text-3); margin-top: 5px; }
.form-error { font-size: .78rem; color: var(--danger); margin-top: 5px; }

/* ── Table ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead th {
    padding: 12px 16px;
    text-align: left;
    font-size: .78rem;
    font-weight: 600;
    color: var(--text-2);
    text-transform: uppercase;
    letter-spacing: .05em;
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
}
tbody td {
    padding: 13px 16px;
    border-bottom: 1px solid var(--border);
    font-size: .875rem;
    color: var(--text-1);
    vertical-align: middle;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }

/* ── Badges ────────────────────────────────────────────────── */
.badge {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: .75rem;
    font-weight: 600;
    white-space: nowrap;
}
.badge::before { content: '●'; font-size: .65em; }
.badge-active       { background: #d1fae5; color: #065f46; }
.badge-provisioning { background: #fef3c7; color: #92400e; }
.badge-suspended    { background: #f1f5f9; color: #475569; }
.badge-error        { background: #fee2e2; color: #991b1b; }
.badge-deleting     { background: #fce7f3; color: #9d174d; }
.badge-openai       { background: #dbeafe; color: #1e40af; }
.badge-claude       { background: #fae8ff; color: #7e22ce; }

/* ── Login Page ────────────────────────────────────────────── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
}
.login-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    width: 100%;
    max-width: 400px;
    padding: 40px;
}
.login-logo { text-align: center; margin-bottom: 28px; }
.login-logo .logo-icon { width: 52px; height: 52px; font-size: 20px; margin: 0 auto 12px; }
.login-logo h1 { font-size: 1.25rem; font-weight: 700; color: var(--text-1); }
.login-logo p  { font-size: .84rem; color: var(--text-2); margin-top: 4px; }

/* ── Modal ─────────────────────────────────────────────────── */
.modal-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    display: flex; align-items: center; justify-content: center;
    z-index: 200;
    animation: fadeIn .15s ease;
}
.modal {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0,0,0,.3);
    width: 100%; max-width: 520px;
    max-height: 90vh; overflow-y: auto;
    margin: 20px;
    animation: slideUp .2s ease;
}
.modal-header {
    padding: 22px 24px 0;
    display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 1.1rem; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 1.3rem; color: var(--text-3); cursor: pointer; padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { background: var(--content-bg); color: var(--text-1); }
.modal-body    { padding: 20px 24px; }
.modal-footer  { padding: 0 24px 22px; display: flex; justify-content: flex-end; gap: 10px; }

/* ── Alert / Toast ─────────────────────────────────────────── */
.toast-container {
    position: fixed; top: 20px; right: 20px;
    z-index: 9999; display: flex; flex-direction: column; gap: 10px;
    pointer-events: none;
}
.toast {
    background: white;
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: 14px 18px;
    display: flex; align-items: flex-start; gap: 12px;
    min-width: 280px; max-width: 380px;
    pointer-events: all;
    animation: slideInRight .2s ease;
    border-left: 4px solid var(--primary);
}
.toast.toast-success { border-color: var(--success); }
.toast.toast-error   { border-color: var(--danger);  }
.toast.toast-warning { border-color: var(--warning); }
.toast-icon { font-size: 1.1rem; flex-shrink: 0; margin-top: 1px; }
.toast-text { flex: 1; }
.toast-title { font-weight: 600; font-size: .875rem; color: var(--text-1); }
.toast-msg   { font-size: .8rem; color: var(--text-2); margin-top: 2px; }

/* ── Code block ────────────────────────────────────────────── */
.code-block {
    background: #0f172a;
    color: #e2e8f0;
    border-radius: var(--radius);
    padding: 14px 16px;
    font-family: 'Courier New', monospace;
    font-size: .82rem;
    line-height: 1.6;
    overflow-x: auto;
    position: relative;
}
.code-copy-btn {
    position: absolute; top: 10px; right: 10px;
    background: rgba(255,255,255,.1);
    border: none; color: #94a3b8;
    font-size: .75rem; padding: 4px 10px;
    border-radius: 4px; cursor: pointer;
}
.code-copy-btn:hover { background: rgba(255,255,255,.2); color: white; }

/* ── Tabs ──────────────────────────────────────────────────── */
.tabs { display: flex; gap: 0; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab-btn {
    padding: 10px 20px;
    background: none; border: none;
    font-size: .875rem; font-weight: 500;
    color: var(--text-2);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: color .15s, border-color .15s;
}
.tab-btn:hover  { color: var(--primary); }
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

/* ── Empty state ───────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-2);
}
.empty-icon { font-size: 3rem; margin-bottom: 14px; }
.empty-title { font-size: 1.1rem; font-weight: 600; color: var(--text-1); margin-bottom: 8px; }
.empty-text  { font-size: .875rem; color: var(--text-2); max-width: 360px; margin: 0 auto 20px; }

/* ── Spinners ──────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 20px; height: 20px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
.page-loading {
    display: flex; align-items: center; justify-content: center;
    min-height: 200px; flex-direction: column; gap: 12px;
    color: var(--text-2);
}

/* ── Progress Bar ──────────────────────────────────────────── */
.progress-bar { height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: var(--primary); border-radius: 3px; transition: width .3s ease; }

/* ── Danger Zone ───────────────────────────────────────────── */
.danger-zone {
    border: 1px solid #fecaca;
    background: #fff5f5;
    border-radius: var(--radius-lg);
    padding: 18px 22px;
    margin-top: 24px;
}
.danger-zone-title { font-weight: 600; color: var(--danger); margin-bottom: 8px; }
.danger-zone p     { font-size: .875rem; color: var(--text-2); margin-bottom: 14px; }

/* ── Info Banner ───────────────────────────────────────────── */
.info-banner {
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: var(--radius);
    padding: 14px 18px;
    font-size: .875rem;
    color: #1e40af;
    display: flex; align-items: flex-start; gap: 10px;
    margin-bottom: 20px;
}
.info-banner.warning { background: #fffbeb; border-color: #fde68a; color: #92400e; }
.info-banner.success { background: #f0fdf4; border-color: #bbf7d0; color: #065f46; }

/* ── Animations ────────────────────────────────────────────── */
@keyframes spin        { to { transform: rotate(360deg); } }
@keyframes fadeIn      { from { opacity: 0; }             to { opacity: 1; } }
@keyframes slideUp     { from { transform: translateY(20px); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes slideInRight { from { transform: translateX(20px); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Utility ───────────────────────────────────────────────── */
.flex         { display: flex; }
.items-center { align-items: center; }
.gap-2        { gap: 8px; }
.gap-3        { gap: 12px; }
.ml-auto      { margin-left: auto; }
.mt-4         { margin-top: 16px; }
.mt-6         { margin-top: 24px; }
.text-sm      { font-size: .875rem; }
.text-xs      { font-size: .78rem; }
.text-muted   { color: var(--text-2); }
.font-bold    { font-weight: 700; }
.font-mono    { font-family: 'Courier New', monospace; }
.truncate     { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-full       { width: 100%; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: none; }
    .main-content { margin-left: 0; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .page-content { padding: 16px; }
}
