/* ============================================
   AI Prompt Hub — Design System
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-card: #16213e;
    --bg-glass: rgba(22, 33, 62, 0.7);
    --bg-hover: rgba(255,255,255,0.05);
    --text-primary: #e8e8f0;
    --text-secondary: #a0a0b8;
    --text-muted: #6b6b80;
    --accent: #6c63ff;
    --accent-hover: #7f78ff;
    --accent-glow: rgba(108,99,255,0.3);
    --success: #2ecc71;
    --warning: #f39c12;
    --danger: #e74c3c;
    --border: rgba(255,255,255,0.08);
    --border-hover: rgba(255,255,255,0.15);
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 8px 32px rgba(0,0,0,0.3);
    --transition: 0.2s ease;
    --sidebar-w: 220px;
    --prompt-sidebar-w: 300px;
    --header-h: 60px;
}

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

body {
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

a { color: var(--accent); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-hover); }

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex; align-items: center; gap: 8px;
    padding: 10px 20px; border: none; border-radius: var(--radius-sm);
    font-family: inherit; font-size: 14px; font-weight: 500;
    cursor: pointer; transition: all var(--transition);
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); box-shadow: 0 0 20px var(--accent-glow); transform: translateY(-1px); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #27ae60; }
.btn-ghost { background: transparent; color: var(--text-secondary); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-icon { padding: 8px; border-radius: var(--radius-sm); background: transparent; border: none; color: var(--text-secondary); cursor: pointer; transition: all var(--transition); }
.btn-icon:hover { color: var(--accent); background: var(--bg-hover); }

/* ============ INPUTS ============ */
input, select, textarea {
    background: var(--bg-primary); border: 1px solid var(--border); color: var(--text-primary);
    padding: 10px 14px; border-radius: var(--radius-sm); font-family: inherit; font-size: 14px;
    transition: border-color var(--transition); width: 100%;
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-glow); }
textarea { resize: vertical; min-height: 100px; }
label { font-size: 13px; font-weight: 500; color: var(--text-secondary); margin-bottom: 4px; display: block; }

/* ============ HEADER ============ */
.header {
    height: var(--header-h); background: var(--bg-secondary); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between; padding: 0 24px;
    position: sticky; top: 0; z-index: 100; backdrop-filter: blur(12px);
}
.header-brand { display: flex; align-items: center; gap: 10px; font-size: 18px; font-weight: 700; }
.header-brand span { background: linear-gradient(135deg, var(--accent), #a855f7); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.header-user { display: flex; align-items: center; gap: 12px; }
.header-user img { width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--border); }
.header-user .user-name { font-size: 14px; font-weight: 500; }
.header-user .logout-link { font-size: 13px; color: var(--text-muted); cursor: pointer; }
.header-user .logout-link:hover { color: var(--danger); }

/* ============ LOGIN PAGE ============ */
.login-page { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; padding: 20px; background: radial-gradient(ellipse at top, #1a1a3e 0%, var(--bg-primary) 70%); }
.login-card {
    background: var(--bg-glass); backdrop-filter: blur(20px); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 40px; width: 100%; max-width: 420px;
    box-shadow: var(--shadow); text-align: center;
}
.login-card h1 { font-size: 28px; margin-bottom: 8px; }
.login-card p { color: var(--text-secondary); margin-bottom: 24px; font-size: 14px; }
.google-btn {
    display: inline-flex; align-items: center; gap: 12px;
    padding: 12px 28px; background: #fff; color: #333; border: none; border-radius: var(--radius-sm);
    font-size: 15px; font-weight: 500; cursor: pointer; transition: all var(--transition);
    font-family: inherit; width: 100%; justify-content: center;
}
.google-btn:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.3); transform: translateY(-1px); }
.google-btn img { width: 20px; height: 20px; }

.payment-section {
    margin-top: 32px; text-align: left; width: 100%; max-width: 480px;
    background: var(--bg-glass); backdrop-filter: blur(20px); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 28px; box-shadow: var(--shadow);
}
.payment-section h2 { font-size: 18px; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }
.payment-section .price-tag { display: inline-block; background: var(--accent); color: #fff; padding: 4px 12px; border-radius: 20px; font-size: 13px; font-weight: 600; margin: 4px 4px 4px 0; }
.payment-section .syntax-box { background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 12px 16px; font-family: monospace; font-size: 14px; color: var(--accent); margin: 12px 0; user-select: all; }
.payment-section .qr-container { text-align: center; margin-top: 16px; }
.payment-section .qr-container img { max-width: 200px; border-radius: var(--radius-sm); border: 1px solid var(--border); }
.payment-section ol { padding-left: 20px; color: var(--text-secondary); font-size: 14px; }
.payment-section ol li { margin-bottom: 8px; }

/* ============ APP LAYOUT (3-col) ============ */
.app-layout { display: flex; height: calc(100vh - var(--header-h)); }

.sidebar-left {
    width: var(--sidebar-w); background: var(--bg-secondary); border-right: 1px solid var(--border);
    display: flex; flex-direction: column; overflow: hidden; flex-shrink: 0;
}
.sidebar-left .search-box { padding: 12px; border-bottom: 1px solid var(--border); }
.sidebar-left .search-box input { font-size: 13px; padding: 8px 12px; }
.sidebar-left .ai-list { flex: 1; overflow-y: auto; padding: 8px; }
.ai-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 12px;
    border-radius: var(--radius-sm); cursor: pointer; transition: all var(--transition);
    font-size: 14px; color: var(--text-secondary); margin-bottom: 2px;
}
.ai-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.ai-item.active { background: var(--accent); color: #fff; }
.ai-item .ai-icon { font-size: 20px; flex-shrink: 0; }

.content-main {
    flex: 1; overflow-y: auto; padding: 24px 32px;
    scrollbar-width: thin; scrollbar-color: var(--border) transparent;
}
.content-main h2 { font-size: 22px; margin-bottom: 16px; }
.content-main .guide-content { line-height: 1.8; color: var(--text-secondary); }
.content-main .guide-content h2, .content-main .guide-content h3 { color: var(--text-primary); margin-top: 20px; }
.content-main .guide-content a { color: var(--accent); }
.content-main .guide-content p { margin-bottom: 12px; }

.prompt-detail {
    margin-top: 32px; padding: 24px; background: var(--bg-card); border: 1px solid var(--border);
    border-radius: var(--radius); animation: slideUp 0.3s ease;
}
.prompt-detail h3 { font-size: 16px; margin-bottom: 12px; color: var(--accent); display: flex; align-items: center; gap: 8px; }
.prompt-detail pre {
    background: var(--bg-primary); border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 16px; white-space: pre-wrap; word-break: break-word; font-size: 13px; line-height: 1.7;
    color: var(--text-secondary); max-height: 400px; overflow-y: auto;
}
.prompt-detail .copy-btn { margin-top: 12px; }

.sidebar-right {
    width: var(--prompt-sidebar-w); background: var(--bg-secondary); border-left: 1px solid var(--border);
    display: flex; flex-direction: column; overflow: hidden; flex-shrink: 0;
}
.sidebar-right h3 { padding: 16px; font-size: 14px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 1px; border-bottom: 1px solid var(--border); }
.prompt-list { flex: 1; overflow-y: auto; padding: 8px; }
.category-group { margin-bottom: 8px; }
.category-label { padding: 8px 12px; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; cursor: pointer; display: flex; align-items: center; justify-content: space-between; }
.category-label:hover { color: var(--text-secondary); }
.category-label .arrow { transition: transform var(--transition); font-size: 10px; }
.category-label .arrow.open { transform: rotate(90deg); }
.prompt-item {
    display: flex; align-items: center; gap: 8px; padding: 8px 12px 8px 20px;
    border-radius: var(--radius-sm); cursor: pointer; transition: all var(--transition);
    font-size: 13px; color: var(--text-secondary);
}
.prompt-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.prompt-item.active { color: var(--accent); background: rgba(108,99,255,0.1); }

/* ============ ADMIN LAYOUT ============ */
.admin-sidebar {
    width: var(--sidebar-w); background: var(--bg-secondary); border-right: 1px solid var(--border);
    padding: 16px 8px; flex-shrink: 0;
}
.admin-nav-item {
    display: flex; align-items: center; gap: 10px; padding: 10px 14px;
    border-radius: var(--radius-sm); cursor: pointer; transition: all var(--transition);
    font-size: 14px; color: var(--text-secondary); margin-bottom: 4px;
}
.admin-nav-item:hover { background: var(--bg-hover); color: var(--text-primary); }
.admin-nav-item.active { background: var(--accent); color: #fff; }

.admin-content { flex: 1; overflow-y: auto; padding: 24px; }
.admin-content h2 { font-size: 20px; margin-bottom: 20px; }

.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; flex-wrap: wrap; }
.toolbar input { max-width: 280px; }

/* ============ TABLE ============ */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th { text-align: left; padding: 12px 14px; font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.5px; border-bottom: 1px solid var(--border); }
.data-table td { padding: 12px 14px; font-size: 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.data-table tr:hover td { background: var(--bg-hover); }
.status-badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 20px; font-size: 12px; font-weight: 500; }
.status-active { background: rgba(46,204,113,0.15); color: var(--success); }
.status-inactive { background: rgba(243,156,18,0.15); color: var(--warning); }
.status-blocked { background: rgba(231,76,60,0.15); color: var(--danger); }
.status-expired { background: rgba(107,107,128,0.15); color: var(--text-muted); }

/* ============ MODAL ============ */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.6); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; animation: fadeIn 0.2s ease; }
.modal {
    background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 28px; width: 90%; max-width: 600px; max-height: 85vh; overflow-y: auto;
    box-shadow: 0 16px 48px rgba(0,0,0,0.4); animation: slideUp 0.3s ease;
}
.modal h3 { font-size: 18px; margin-bottom: 20px; }
.modal .form-group { margin-bottom: 16px; }
.modal .form-actions { display: flex; gap: 12px; justify-content: flex-end; margin-top: 24px; }
.modal-lg { max-width: 900px; }

/* ============ TOAST ============ */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast { padding: 12px 20px; border-radius: var(--radius-sm); font-size: 14px; color: #fff; animation: slideIn 0.3s ease; box-shadow: var(--shadow); }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--accent); }

/* ============ EMPTY STATE ============ */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 48px; margin-bottom: 16px; }
.empty-state p { font-size: 15px; }

/* ============ LOADING ============ */
.spinner { width: 32px; height: 32px; border: 3px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 0.8s linear infinite; margin: 40px auto; }

/* ============ ANIMATIONS ============ */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideIn { from { opacity: 0; transform: translateX(100px); } to { opacity: 1; transform: translateX(0); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ============ RESPONSIVE ============ */
@media (max-width: 1024px) {
    :root { --sidebar-w: 180px; --prompt-sidebar-w: 240px; }
}
@media (max-width: 768px) {
    .sidebar-left, .sidebar-right { display: none; }
    .sidebar-left.open, .sidebar-right.open { display: flex; position: fixed; top: var(--header-h); bottom: 0; z-index: 50; width: 280px; }
    .sidebar-left.open { left: 0; }
    .sidebar-right.open { right: 0; }
    .content-main { padding: 16px; }
    .mobile-toggle { display: inline-flex !important; }
    .admin-sidebar { display: none; }
    .admin-sidebar.open { display: block; position: fixed; top: var(--header-h); bottom: 0; left: 0; z-index: 50; width: 240px; }
}
.mobile-toggle { display: none; }

/* ============ LIGHT BLUE THEME (client pages) ============ */
body.light-theme {
    --bg-primary: #f0f5ff;
    --bg-secondary: #ffffff;
    --bg-card: #e8f0fe;
    --bg-glass: rgba(255, 255, 255, 0.85);
    --bg-hover: rgba(59, 130, 246, 0.06);
    --text-primary: #1e293b;
    --text-secondary: #475569;
    --text-muted: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.25);
    --success: #22c55e;
    --warning: #f59e0b;
    --danger: #ef4444;
    --border: rgba(59, 130, 246, 0.12);
    --border-hover: rgba(59, 130, 246, 0.25);
    --shadow: 0 4px 24px rgba(59, 130, 246, 0.08);
}

/* Header override for light theme */
body.light-theme .header {
    background: linear-gradient(135deg, #1e40af, #3b82f6);
    border-bottom: none;
    box-shadow: 0 2px 12px rgba(30, 64, 175, 0.2);
}
body.light-theme .header-brand span {
    background: none;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: #fff;
    color: #fff;
}
body.light-theme .header-user .user-name { color: #e0e7ff; }
body.light-theme .header-user .logout-link { color: #bfdbfe; }
body.light-theme .header-user .logout-link:hover { color: #fca5a5; }
body.light-theme .header-user img { border-color: rgba(255,255,255,0.3); }

/* Login page light */
body.light-theme .login-page {
    background: linear-gradient(160deg, #dbeafe 0%, #f0f5ff 40%, #ede9fe 100%);
}
body.light-theme .login-card {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(59, 130, 246, 0.15);
    box-shadow: 0 8px 40px rgba(59, 130, 246, 0.1);
}
body.light-theme .login-card h1 { color: #1e3a5f; }
body.light-theme .payment-section {
    background: rgba(255, 255, 255, 0.9);
    border-color: rgba(59, 130, 246, 0.15);
    box-shadow: 0 8px 40px rgba(59, 130, 246, 0.1);
}

/* Sidebar light */
body.light-theme .sidebar-left,
body.light-theme .sidebar-right {
    background: #ffffff;
    border-color: rgba(59, 130, 246, 0.1);
}
body.light-theme .sidebar-right h3 {
    color: #3b82f6;
    border-color: rgba(59, 130, 246, 0.1);
}
body.light-theme .ai-item { color: #475569; }
body.light-theme .ai-item:hover { background: rgba(59, 130, 246, 0.06); color: #1e293b; }
body.light-theme .ai-item.active { background: #3b82f6; color: #fff; }
body.light-theme .prompt-item.active { color: #2563eb; background: rgba(59, 130, 246, 0.08); }

/* Content main light */
body.light-theme .content-main { background: #f0f5ff; }
body.light-theme .guide-content { color: #334155; }
body.light-theme .guide-content h2,
body.light-theme .guide-content h3 { color: #1e293b; }
body.light-theme .prompt-detail { background: #fff; border-color: rgba(59, 130, 246, 0.12); box-shadow: 0 2px 12px rgba(59, 130, 246, 0.06); }
body.light-theme .prompt-detail pre { background: #f1f5f9; border-color: rgba(59, 130, 246, 0.1); color: #334155; }
body.light-theme .prompt-detail h3 { color: #2563eb; }

/* Inputs light */
body.light-theme input,
body.light-theme select,
body.light-theme textarea {
    background: #fff;
    border-color: #cbd5e1;
    color: #1e293b;
}
body.light-theme input:focus,
body.light-theme select:focus,
body.light-theme textarea:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* Scrollbar light */
body.light-theme ::-webkit-scrollbar-thumb { background: #cbd5e1; }
body.light-theme ::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Table light */
body.light-theme .data-table th { color: #64748b; border-color: #e2e8f0; }
body.light-theme .data-table td { border-color: #e2e8f0; }
body.light-theme .data-table tr:hover td { background: rgba(59, 130, 246, 0.04); }

/* Modal light */
body.light-theme .modal-overlay { background: rgba(0, 0, 0, 0.3); }
body.light-theme .modal {
    background: #fff;
    border-color: #e2e8f0;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

/* Empty state light */
body.light-theme .empty-state { color: #94a3b8; }

/* Spinner light */
body.light-theme .spinner { border-color: #e2e8f0; border-top-color: #3b82f6; }

