/* ================= DUAL THEME SYSTEM (DARK & LIGHT) ================= */
:root[data-theme="dark"] {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.25);
  --secondary: #ec4899;
  --accent: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --bg: #0f172a;
  --bg-elevated: #1e293b;
  --card-bg: rgba(30, 41, 59, 0.88);
  --card-border: rgba(148, 163, 184, 0.12);
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  --input-bg: rgba(15, 23, 42, 0.6);
  --header-bg: rgba(15, 23, 42, 0.88);
  --ad-bg: rgba(15, 23, 42, 0.35);
  --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.35);
}

:root[data-theme="light"] {
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-glow: rgba(79, 70, 229, 0.15);
  --secondary: #db2777;
  --accent: #059669;
  --warning: #d97706;
  --danger: #dc2626;
  --bg: #f8fafc;
  --bg-elevated: #ffffff;
  --card-bg: #ffffff;
  --card-border: #e2e8f0;
  --text: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;
  --input-bg: #ffffff;
  --header-bg: rgba(255, 255, 255, 0.92);
  --ad-bg: #f1f5f9;
  --shadow-card: 0 4px 20px rgba(0, 0, 0, 0.06);
}

:root {
  --gradient-1: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #ec4899 100%);
  --gradient-2: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
  --gradient-3: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);
  --shadow-glow: 0 0 35px rgba(99, 102, 241, 0.2);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
}

body {
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

/* Scrollbar */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--primary); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--primary-hover); }

/* Animations */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 20px rgba(99, 102, 241, 0.3); }
  50% { box-shadow: 0 0 40px rgba(99, 102, 241, 0.5); }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

/* Header */
header {
  background: var(--header-bg);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--card-border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.logo {
  font-size: 1.5rem;
  font-weight: 900;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 12px;
  letter-spacing: -0.5px;
}
.logo::before {
  content: '◆';
  font-size: 1.8rem;
  -webkit-text-fill-color: var(--primary);
  animation: pulse-glow 2s infinite;
}
.badge-vip {
  font-size: 0.7rem;
  background: var(--gradient-1);
  color: #fff;
  padding: 4px 14px;
  border-radius: 999px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.stats-bar {
  display: flex;
  gap: 24px;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.stats-bar span {
  display: flex;
  align-items: center;
  gap: 6px;
}
.stats-bar .live-dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
}

/* Layout */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

@media (min-width: 1024px) {
  .container {
    flex-direction: row;
    align-items: flex-start;
  }
  .sidebar {
    width: 300px;
    position: sticky;
    top: 90px;
    max-height: calc(100vh - 110px);
  }
  .main-content {
    flex: 1;
    min-width: 0;
  }
}

/* Sidebar */
.sidebar {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  padding: 16px;
  overflow-y: auto;
}
.sidebar-title {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  color: var(--text-dim);
  margin-bottom: 12px;
  padding-left: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.sidebar-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--card-border);
}
.tool-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.tool-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  text-decoration: none;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 500;
  border: none;
  background: transparent;
  width: 100%;
  text-align: left;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}
.tool-btn::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  width: 3px;
  height: 100%;
  background: var(--gradient-1);
  opacity: 0;
  transition: opacity 0.3s;
}
.tool-btn:hover {
  background: rgba(99, 102, 241, 0.08);
  color: var(--text);
}
.tool-btn:hover::before { opacity: 0.5; }
.tool-btn.active {
  background: rgba(99, 102, 241, 0.12);
  color: var(--text);
}
.tool-btn.active::before { opacity: 1; }
.tool-btn .tool-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(148, 163, 184, 0.08);
  font-size: 1.1rem;
}
.tool-btn.active .tool-icon {
  background: var(--gradient-1);
  color: #fff;
}
.tool-btn .tool-name {
  display: flex;
  flex-direction: column;
}
.tool-btn .tool-name small {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-weight: 400;
}

/* Tool Panels */
.tool-panel {
  display: none;
  animation: fadeInUp 0.5s ease;
}
.tool-panel.active { display: block; }

/* Hero Card */
.hero-card {
  background: var(--card-bg);
  backdrop-filter: blur(10px);
  border: 1px solid var(--card-border);
  border-radius: 20px;
  padding: 28px;
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}
.hero-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--gradient-1);
}
.hero-card .glow-orb {
  position: absolute;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.15;
  pointer-events: none;
}
.tool-header {
  margin-bottom: 24px;
  position: relative;
  z-index: 1;
}
.tool-title {
  font-size: 1.6rem;
  font-weight: 800;
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 8px;
}
.tool-desc {
  font-size: 0.95rem;
  color: var(--text-muted);
  line-height: 1.7;
}
.tool-badge-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  flex-wrap: wrap;
}
.mini-badge {
  font-size: 0.7rem;
  padding: 4px 12px;
  border-radius: 999px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.mini-badge.pro { background: rgba(99, 102, 241, 0.15); color: #a5b4fc; border: 1px solid rgba(99, 102, 241, 0.2); }
.mini-badge.ai { background: rgba(16, 185, 129, 0.15); color: #6ee7b7; border: 1px solid rgba(16, 185, 129, 0.2); }
.mini-badge.hot { background: rgba(236, 72, 153, 0.15); color: #f9a8d4; border: 1px solid rgba(236, 72, 153, 0.2); }

/* Form Components */
.form-grid { display: grid; gap: 16px; }
.form-grid.cols-2 { grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); }
.form-grid.cols-3 { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
.form-group { margin-bottom: 4px; }
.form-group.full-width { grid-column: 1 / -1; }
label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 6px;
}
label .label-hint { color: var(--text-dim); font-weight: 400; }
input[type="text"], input[type="number"], input[type="file"], input[type="range"], select, textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--card-border);
  border-radius: 12px;
  font-size: 0.92rem;
  background: var(--input-bg);
  color: var(--text);
  outline: none;
  transition: all 0.3s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}
input::placeholder, textarea::placeholder { color: var(--text-dim); }
textarea { resize: vertical; min-height: 100px; }
input[type="file"] { padding: 10px 16px; cursor: pointer; }
input[type="file"]::file-selector-button {
  background: var(--gradient-1);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  margin-right: 16px;
  cursor: pointer;
  font-weight: 600;
}
input[type="range"] {
  padding: 8px 0;
  -webkit-appearance: none;
  height: 6px;
  background: linear-gradient(to right, var(--primary), var(--secondary));
  border-radius: 3px;
  outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px; height: 20px;
  border-radius: 50%;
  background: #fff;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 14px 28px;
  border-radius: 12px;
  font-size: 0.95rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  background: var(--gradient-1);
  color: #fff;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}
.btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-glow);
}
.btn-secondary {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--card-border);
}
.btn-secondary:hover {
  background: rgba(99, 102, 241, 0.1);
  border-color: var(--primary);
}
.btn-danger {
  background: linear-gradient(135deg, var(--danger), #f97316);
}
.btn-group { display: flex; gap: 10px; flex-wrap: wrap; }

/* Result Boxes */
.result-box {
  margin-top: 20px;
  padding: 20px;
  background: var(--input-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  word-break: break-all;
  position: relative;
  overflow: hidden;
}
.result-box::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 4px; height: 100%;
  background: var(--gradient-1);
}
.result-box.success::before { background: var(--gradient-3); }
.result-box.error::before { background: linear-gradient(to bottom, var(--danger), #f97316); }

/* Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.info-card {
  background: var(--input-bg);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 20px;
  transition: all 0.3s;
}
.info-card:hover {
  border-color: rgba(99, 102, 241, 0.3);
  transform: translateY(-4px);
}
.info-card .card-icon {
  width: 48px; height: 48px;
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin-bottom: 14px;
}
.info-card h4 { font-size: 1rem; font-weight: 700; margin-bottom: 8px; }
.info-card p { font-size: 0.85rem; color: var(--text-muted); line-height: 1.6; }

/* Progress & Status */
.progress-bar {
  width: 100%; height: 8px;
  background: rgba(148, 163, 184, 0.1);
  border-radius: 4px;
  overflow: hidden;
  margin: 12px 0;
}
.progress-fill {
  height: 100%;
  background: var(--gradient-1);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* Tabs */
.tabs-nav {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--input-bg);
  border-radius: 12px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.tab-btn {
  padding: 10px 20px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
}
.tab-btn.active {
  background: var(--gradient-1);
  color: #fff;
}
.tab-panel { display: none; }
.tab-panel.active { display: block; animation: fadeInUp 0.4s ease; }

/* Comparison slider */
.compare-container {
  position: relative;
  border-radius: 16px;
  overflow: hidden;
  margin: 16px 0;
}
.compare-slider {
  position: absolute;
  top: 0; bottom: 0;
  width: 4px;
  background: #fff;
  cursor: ew-resize;
  z-index: 10;
  box-shadow: 0 0 20px rgba(0,0,0,0.3);
}
.compare-slider::after {
  content: '◀ ▶';
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  background: var(--gradient-1);
  color: #fff;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 800;
  white-space: nowrap;
}

/* Chart container */
.chart-container {
  position: relative;
  height: 300px;
  margin: 20px 0;
}

/* Toast notifications */
.toast-container {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.toast {
  padding: 16px 24px;
  border-radius: 14px;
  color: #fff;
  font-weight: 600;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 12px;
  animation: fadeInUp 0.4s ease;
  backdrop-filter: blur(10px);
}
.toast.success { background: rgba(16, 185, 129, 0.9); }
.toast.error { background: rgba(239, 68, 68, 0.9); }
.toast.info { background: rgba(99, 102, 241, 0.9); }

.spinner {
  width: 40px; height: 40px;
  border: 3px solid rgba(99, 102, 241, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* SEO Article */
.seo-article {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--card-border);
}
.seo-article h3 {
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.seo-article h3::before { content: '▸'; color: var(--primary); }
.seo-article p {
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.8;
  margin-bottom: 12px;
}

/* Utility */
.text-gradient {
  background: var(--gradient-1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.mono { font-family: 'SF Mono', 'Fira Code', monospace; font-size: 0.85rem; }
.highlight {
  background: rgba(99, 102, 241, 0.15);
  padding: 2px 8px;
  border-radius: 6px;
  color: #a5b4fc;
}

/* Responsive */
@media (max-width: 768px) {
  .header-inner { padding: 12px 16px; }
  .stats-bar { display: none; }
  .container { padding: 16px; }
  .tool-title { font-size: 1.3rem; }
  .form-grid.cols-2, .form-grid.cols-3 { grid-template-columns: 1fr; }
}

.ad-slot {
  margin: 20px 0;
  padding: 20px;
  background: var(--ad-bg);
  border: 1px dashed rgba(148, 163, 184, 0.15);
  border-radius: 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 0.8rem;
}

/* NÚT CHUYỂN THEME & MENU 3 GẠCH */
.theme-toggle-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--card-border);
  color: var(--text);
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.2rem;
  transition: all 0.2s ease;
}
.theme-toggle-btn:hover {
  border-color: var(--primary);
  transform: scale(1.05);
}

.menu-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--card-border);
  color: var(--text);
  cursor: pointer;
  font-size: 1.25rem;
  margin-right: 12px;
  transition: all 0.2s ease;
}
.menu-toggle-btn:hover {
  background: rgba(99, 102, 241, 0.15);
  color: #fff;
}

/* Sidebar Drawer Overlay */
.sidebar-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(5px);
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}
.sidebar-overlay.active { opacity: 1; visibility: visible; }

@media (max-width: 1023px) {
  .sidebar {
    position: fixed !important;
    top: 0 !important; left: 0 !important;
    height: 100vh !important;
    max-height: 100vh !important;
    width: 320px !important;
    max-width: 85vw !important;
    z-index: 1001 !important;
    transform: translateX(-100%) !important;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    border-radius: 0 20px 20px 0 !important;
    box-shadow: 10px 0 40px rgba(0, 0, 0, 0.6) !important;
  }
  .sidebar.open { transform: translateX(0) !important; }
  .sidebar-drawer-header {
    display: flex !important;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 12px;
    margin-bottom: 12px;
    border-bottom: 1px solid var(--card-border);
  }
}

.sidebar-drawer-header { display: none; }
.close-drawer-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.4rem;
  cursor: pointer;
}
.close-drawer-btn:hover { color: var(--text); }

/* Modal Chính Sách & Điều Khoản */
.modal-overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100vw; height: 100vh;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  z-index: 2000;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-overlay.active { display: flex; }
.modal-content {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  max-width: 650px;
  width: 100%;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  box-shadow: var(--shadow-card);
}
.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--card-border);
  padding-bottom: 12px;
  margin-bottom: 16px;
}
.modal-body { font-size: 0.92rem; color: var(--text); line-height: 1.75; }
.modal-body p { margin-bottom: 12px; }

footer {
  text-align: center;
  padding: 40px 24px;
  border-top: 1px solid var(--card-border);
  background: var(--card-bg);
  margin-top: 40px;
}
.footer-links {
  display: flex;
  justify-content: center;
  gap: 20px;
  font-size: 0.88rem;
  flex-wrap: wrap;
  margin: 16px 0;
}
.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
}
.footer-links a:hover {
  color: var(--primary);
  text-decoration: underline;
}
