/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* Màu chính */
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-card: rgba(17, 24, 39, 0.7);
  --bg-glass: rgba(255, 255, 255, 0.05);
  --bg-glass-hover: rgba(255, 255, 255, 0.08);
  --border-glass: rgba(255, 255, 255, 0.1);
  --border-glass-hover: rgba(255, 255, 255, 0.2);

  /* Accent */
  --accent: #6366f1;
  --accent-light: #818cf8;
  --accent-glow: rgba(99, 102, 241, 0.3);
  --accent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6, #a78bfa);
  --gold: #f59e0b;
  --gold-light: #fbbf24;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;

  /* Text */
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;

  /* Spacing & Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Shadow */
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 20px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 40px rgba(0,0,0,0.5);
  --shadow-glow: 0 0 30px var(--accent-glow);
}

html { font-size: 16px; scroll-behavior: smooth; }

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

/* ===== BACKGROUND ANIMATION ===== */
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0;
  background:
    radial-gradient(ellipse 600px 600px at 20% 50%, rgba(99,102,241,0.08), transparent),
    radial-gradient(ellipse 500px 500px at 80% 20%, rgba(139,92,246,0.06), transparent),
    radial-gradient(ellipse 400px 400px at 50% 80%, rgba(245,158,11,0.04), transparent);
  pointer-events: none;
}

/* ===== TYPOGRAPHY ===== */
h1 { font-size: 2rem; font-weight: 700; letter-spacing: -0.02em; }
h2 { font-size: 1.5rem; font-weight: 600; letter-spacing: -0.01em; }
h3 { font-size: 1.125rem; font-weight: 600; }
a { color: var(--accent-light); text-decoration: none; transition: color 0.2s; }
a:hover { color: var(--accent); }

/* ===== GLASS CARD ===== */
.glass {
  background: var(--bg-glass);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  transition: all 0.3s ease;
}
.glass:hover {
  background: var(--bg-glass-hover);
  border-color: var(--border-glass-hover);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 20px;
  border: none; border-radius: var(--radius-sm);
  font-family: inherit; font-size: 0.875rem; font-weight: 600;
  cursor: pointer; transition: all 0.25s ease;
  position: relative; overflow: hidden;
}
.btn::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(rgba(255,255,255,0.1), transparent);
  opacity: 0; transition: opacity 0.25s;
}
.btn:hover::after { opacity: 1; }
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 4px 15px var(--accent-glow);
}
.btn-primary:hover { box-shadow: 0 6px 25px var(--accent-glow); transform: translateY(-1px); }

.btn-secondary {
  background: var(--bg-glass);
  color: var(--text-primary);
  border: 1px solid var(--border-glass);
}
.btn-secondary:hover { border-color: var(--border-glass-hover); background: var(--bg-glass-hover); }

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover { color: var(--text-primary); background: var(--bg-glass); }

.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-gold { background: linear-gradient(135deg, var(--gold), #d97706); color: #1a1a1a; font-weight: 700; }

.btn-lg { padding: 14px 28px; font-size: 1rem; border-radius: var(--radius-md); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-icon { width: 36px; height: 36px; padding: 0; border-radius: var(--radius-sm); }

/* ===== FORM ELEMENTS ===== */
.form-group { margin-bottom: 20px; }
.form-label {
  display: block; margin-bottom: 6px;
  font-size: 0.85rem; font-weight: 500;
  color: var(--text-secondary);
}
.form-input, .form-textarea, .form-select {
  width: 100%; padding: 12px 16px;
  background: rgba(0,0,0,0.3);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: inherit; font-size: 0.95rem;
  transition: all 0.25s ease;
  outline: none;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--text-muted); }
.form-textarea { resize: vertical; min-height: 100px; }

/* ===== LOGIN PAGE ===== */
.login-wrapper {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px;
  position: relative; z-index: 1;
}
.login-card {
  width: 100%; max-width: 420px; padding: 48px 40px;
}
.login-logo {
  text-align: center; margin-bottom: 32px;
}
.login-logo .icon {
  width: 64px; height: 64px;
  background: var(--accent-gradient);
  border-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 28px; margin-bottom: 16px;
  box-shadow: var(--shadow-glow);
}
.login-logo h1 { font-size: 1.5rem; margin-bottom: 4px; }
.login-logo p { color: var(--text-muted); font-size: 0.9rem; }
.login-card .btn-primary { width: 100%; padding: 14px; font-size: 1rem; margin-top: 8px; }
.login-error {
  background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5; padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 0.85rem; margin-bottom: 16px; display: none;
}

/* ===== APP LAYOUT ===== */
.app-layout {
  display: flex; min-height: 100vh;
  position: relative; z-index: 1;
}
.sidebar {
  width: 260px; padding: 20px;
  background: rgba(0,0,0,0.3);
  border-right: 1px solid var(--border-glass);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 100;
}
.sidebar-logo {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0; margin-bottom: 24px;
}
.sidebar-logo .icon {
  width: 40px; height: 40px;
  background: var(--accent-gradient);
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
  box-shadow: 0 0 15px var(--accent-glow);
}
.sidebar-logo span { font-weight: 700; font-size: 1rem; }

.sidebar-nav { flex: 1; display: flex; flex-direction: column; gap: 4px; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px; border-radius: var(--radius-sm);
  color: var(--text-secondary); font-size: 0.9rem; font-weight: 500;
  cursor: pointer; transition: all 0.2s;
  border: none; background: none; width: 100%; text-align: left;
  font-family: inherit;
}
.nav-item:hover { background: var(--bg-glass); color: var(--text-primary); }
.nav-item.active {
  background: var(--accent-glow);
  color: var(--accent-light);
  border: 1px solid rgba(99,102,241,0.2);
}
.nav-item .nav-icon { font-size: 1.1rem; width: 24px; text-align: center; }

.sidebar-footer {
  padding-top: 16px; border-top: 1px solid var(--border-glass);
  display: flex; flex-direction: column; gap: 8px;
}
.user-info {
  display: flex; align-items: center; gap: 10px; padding: 8px 0;
}
.user-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent-gradient);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.85rem;
}
.user-name { font-size: 0.85rem; font-weight: 600; }
.user-role { font-size: 0.75rem; color: var(--text-muted); }

.main-content {
  flex: 1; margin-left: 260px; padding: 32px;
}
.page-header {
  margin-bottom: 32px;
}
.page-header h1 { margin-bottom: 4px; }
.page-header p { color: var(--text-secondary); font-size: 0.95rem; }

/* ===== TABS ===== */
.tabs {
  display: flex; gap: 4px; padding: 4px;
  background: rgba(0,0,0,0.2);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
  overflow-x: auto;
}
.tab-btn {
  padding: 10px 18px;
  border: none; background: none;
  color: var(--text-muted);
  font-family: inherit; font-size: 0.85rem; font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer; transition: all 0.25s;
  white-space: nowrap;
  display: flex; align-items: center; gap: 6px;
}
.tab-btn:hover { color: var(--text-primary); background: var(--bg-glass); }
.tab-btn.active {
  background: var(--accent-gradient);
  color: white;
  box-shadow: 0 2px 10px var(--accent-glow);
}
.tab-panel { display: none; animation: fadeIn 0.3s ease; }
.tab-panel.active { display: block; }

/* ===== CONTENT RESULT CARD ===== */
.result-card {
  padding: 24px;
  margin-bottom: 16px;
}
.result-card .result-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px; padding-bottom: 12px;
  border-bottom: 1px solid var(--border-glass);
}
.result-card .result-header h3 { display: flex; align-items: center; gap: 8px; }
.result-actions { display: flex; gap: 8px; }

.result-content {
  background: rgba(0,0,0,0.2);
  border-radius: var(--radius-sm);
  padding: 20px;
  font-size: 0.925rem;
  line-height: 1.8;
  white-space: pre-wrap;
  color: var(--text-secondary);
  max-height: 500px;
  overflow-y: auto;
}
.result-content::-webkit-scrollbar { width: 6px; }
.result-content::-webkit-scrollbar-track { background: transparent; }
.result-content::-webkit-scrollbar-thumb { background: var(--border-glass); border-radius: 3px; }

/* ===== UPLOAD AREA ===== */
.upload-area {
  border: 2px dashed var(--border-glass);
  border-radius: var(--radius-md);
  padding: 32px; text-align: center;
  cursor: pointer; transition: all 0.3s;
}
.upload-area:hover, .upload-area.dragover {
  border-color: var(--accent);
  background: rgba(99,102,241,0.05);
}
.upload-area .upload-icon { font-size: 2.5rem; margin-bottom: 12px; }
.upload-area p { color: var(--text-muted); font-size: 0.9rem; }
.upload-preview {
  display: flex; gap: 12px; flex-wrap: wrap; margin-top: 16px;
}
.upload-preview img {
  width: 80px; height: 80px; object-fit: cover;
  border-radius: var(--radius-sm); border: 1px solid var(--border-glass);
}

/* ===== HISTORY LIST ===== */
.history-item {
  padding: 16px; margin-bottom: 8px;
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer;
}
.history-item:hover { border-color: var(--accent); }
.history-item .history-title { font-weight: 600; font-size: 0.95rem; }
.history-item .history-date { font-size: 0.8rem; color: var(--text-muted); }

/* ===== ADMIN TABLE ===== */
.data-table {
  width: 100%; border-collapse: collapse;
}
.data-table th, .data-table td {
  padding: 12px 16px; text-align: left;
  border-bottom: 1px solid var(--border-glass);
}
.data-table th {
  color: var(--text-muted); font-size: 0.8rem;
  font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em;
}
.data-table td { font-size: 0.9rem; }
.data-table tbody tr { transition: background 0.2s; }
.data-table tbody tr:hover { background: var(--bg-glass); }

/* ===== BADGE ===== */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 100px;
  font-size: 0.75rem; font-weight: 600;
}
.badge-success { background: rgba(16,185,129,0.15); color: #34d399; }
.badge-danger { background: rgba(239,68,68,0.15); color: #fca5a5; }
.badge-warning { background: rgba(245,158,11,0.15); color: #fbbf24; }
.badge-info { background: rgba(99,102,241,0.15); color: #a5b4fc; }

/* ===== STAT CARDS ===== */
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px; margin-bottom: 32px;
}
.stat-card {
  padding: 24px; text-align: center;
}
.stat-card .stat-icon { font-size: 2rem; margin-bottom: 8px; }
.stat-card .stat-value {
  font-size: 2rem; font-weight: 700;
  background: var(--accent-gradient);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.stat-card .stat-label { color: var(--text-muted); font-size: 0.85rem; margin-top: 4px; }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal {
  width: 100%; max-width: 560px; max-height: 90vh;
  padding: 32px; overflow-y: auto;
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 24px;
}
.modal-header h2 { font-size: 1.25rem; }

/* ===== TOAST ===== */
.toast-container {
  position: fixed; top: 20px; right: 20px;
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
}
.toast {
  padding: 14px 20px; border-radius: var(--radius-sm);
  font-size: 0.875rem; font-weight: 500;
  animation: slideIn 0.3s ease;
  display: flex; align-items: center; gap: 8px;
  min-width: 280px;
}
.toast-success { background: rgba(16,185,129,0.9); color: white; }
.toast-error { background: rgba(239,68,68,0.9); color: white; }

/* ===== SPINNER ===== */
.spinner {
  width: 20px; height: 20px;
  border: 2.5px solid rgba(255,255,255,0.2);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
.loading-overlay {
  position: absolute; inset: 0;
  background: rgba(10,14,26,0.8); backdrop-filter: blur(4px);
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 16px; border-radius: var(--radius-lg);
  z-index: 10;
}
.loading-overlay .spinner { width: 36px; height: 36px; }
.loading-text { color: var(--text-secondary); font-size: 0.9rem; }

/* ===== GENERATING ANIMATION ===== */
.generating-dots::after {
  content: '';
  animation: dots 1.5s steps(4,end) infinite;
}
@keyframes dots {
  0% { content: ''; }
  25% { content: '.'; }
  50% { content: '..'; }
  75% { content: '...'; }
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateX(40px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, var(--bg-glass) 25%, var(--bg-glass-hover) 50%, var(--bg-glass) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
  height: 16px; margin-bottom: 8px;
}

/* ===== MOBILE RESPONSIVE ===== */
.mobile-header {
  display: none;
  padding: 12px 20px;
  background: rgba(0,0,0,0.4);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-glass);
  justify-content: space-between; align-items: center;
  position: sticky; top: 0; z-index: 99;
}
.mobile-header .menu-toggle {
  background: none; border: none; color: var(--text-primary);
  font-size: 1.5rem; cursor: pointer;
}
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 99;
}

@media (max-width: 768px) {
  .mobile-header { display: flex; }
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.active { display: block; }
  .main-content { margin-left: 0; padding: 20px; }
  .tabs { flex-wrap: nowrap; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .page-header h1 { font-size: 1.5rem; }
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: var(--bg-primary); }
::-webkit-scrollbar-thumb { background: var(--border-glass); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ===== IMAGE GEN TAB ===== */
.image-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.image-card { border-radius: var(--radius-md); overflow: hidden; }
.image-card img {
  width: 100%; aspect-ratio: 1; object-fit: cover;
  display: block;
}
.image-card .image-info { padding: 12px; }
.image-card .image-info p { font-size: 0.85rem; color: var(--text-muted); }
