/* ============================================================
   TopID Inbox Tools Pro — Premium Dashboard CSS
   ============================================================ */

:root {
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --primary: #4f46e5;
  --primary-light: #818cf8;
  --primary-dark: #3730a3;
  --accent: #06b6d4;
  --success: #10b981;
  --danger: #ef4444;
  --warning: #f59e0b;
  --bg: #f1f5f9;
  --card: #ffffff;
  --sidebar-bg: linear-gradient(180deg, #1e1b4b 0%, #312e81 50%, #1e1b4b 100%);
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0,0,0,.06), 0 4px 12px rgba(0,0,0,.04);
  --shadow-lg: 0 8px 32px rgba(0,0,0,.08);
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w); height: 100vh;
  background: var(--sidebar-bg);
  color: #fff;
  display: flex; flex-direction: column;
  z-index: 1000;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
}
.sidebar-brand {
  padding: 24px 20px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.1);
}
.brand-icon {
  width: 42px; height: 42px;
  background: linear-gradient(135deg, var(--primary-light), var(--accent));
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; color: #fff;
  box-shadow: 0 4px 16px rgba(79,70,229,.3);
}
.brand-name { display: block; font-weight: 800; font-size: 17px; letter-spacing: -.5px; }
.brand-sub { display: block; font-size: 11px; color: rgba(255,255,255,.5); font-weight: 500; letter-spacing: 2px; text-transform: uppercase; }

.sidebar-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.sidebar-link {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border: none; background: transparent;
  color: rgba(255,255,255,.6);
  font-size: 14px; font-weight: 500;
  border-radius: 10px;
  cursor: pointer;
  transition: all .2s;
  text-align: left; width: 100%;
}
.sidebar-link i { font-size: 18px; width: 20px; text-align: center; }
.sidebar-link:hover { background: rgba(255,255,255,.08); color: #fff; }
.sidebar-link.active {
  background: rgba(255,255,255,.12);
  color: #fff;
  box-shadow: inset 3px 0 0 var(--primary-light);
}

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.1);
}
#sidebar-status { display: flex; align-items: center; gap: 8px; color: rgba(255,255,255,.5); }
.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-dot.on { background: var(--success); box-shadow: 0 0 8px var(--success); }
.status-dot.off { background: #ef4444; }
.status-dot.loading { background: var(--warning); animation: blink 1s infinite; }
@keyframes blink { 0%,100%{opacity:1} 50%{opacity:.3} }

/* ===== MAIN WRAPPER ===== */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
}
.topbar {
  height: var(--topbar-h);
  background: rgba(255,255,255,.8);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 32px; gap: 16px;
  position: sticky; top: 0; z-index: 100;
}
.topbar-title { font-weight: 700; font-size: 18px; flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.content-area { flex: 1; padding: 28px 32px; }

/* ===== CARDS ===== */
.noti-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  transition: all .2s;
}
.noti-card:hover { box-shadow: var(--shadow-lg); }
.noti-card .card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 20px 24px;
  font-weight: 700; font-size: 16px;
  display: flex; align-items: center; gap: 10px;
}
.noti-card .card-header .card-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px;
}
.noti-card .card-body { padding: 24px; }

/* Gradient icon backgrounds */
.icon-primary { background: linear-gradient(135deg, #eef2ff, #c7d2fe); color: var(--primary); }
.icon-success { background: linear-gradient(135deg, #ecfdf5, #a7f3d0); color: var(--success); }
.icon-danger { background: linear-gradient(135deg, #fef2f2, #fecaca); color: var(--danger); }
.icon-warning { background: linear-gradient(135deg, #fffbeb, #fde68a); color: var(--warning); }
.icon-accent { background: linear-gradient(135deg, #ecfeff, #a5f3fc); color: var(--accent); }

/* ===== STAT BOXES ===== */
.stat-box {
  border-radius: var(--radius);
  padding: 20px;
  text-align: center;
  position: relative;
  overflow: hidden;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.stat-box::before {
  content: ''; position: absolute; top: -30px; right: -30px;
  width: 80px; height: 80px; border-radius: 50%;
  background: rgba(255,255,255,.15);
}
.stat-box .stat-num {
  font-size: 2rem; font-weight: 800; line-height: 1;
  margin-bottom: 4px;
}
.stat-box .stat-label { font-size: 12px; opacity: .8; font-weight: 500; }
.stat-box-success { background: linear-gradient(135deg, #10b981, #059669); color: #fff; }
.stat-box-danger { background: linear-gradient(135deg, #ef4444, #dc2626); color: #fff; }
.stat-box-primary { background: linear-gradient(135deg, #4f46e5, #4338ca); color: #fff; }

/* ===== PAGE LIST ITEMS ===== */
.page-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all .25s;
  display: flex; align-items: center; gap: 14px;
  background: var(--card);
}
.page-card:hover { border-color: var(--primary); background: #f5f3ff; transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.page-avatar {
  width: 48px; height: 48px; border-radius: 14px; background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
  display: flex; align-items: center; justify-content: center;
  overflow: hidden; flex-shrink: 0; position: relative;
  font-weight: 700; color: var(--primary); font-size: 18px;
}
.page-avatar img { width: 100%; height: 100%; object-fit: cover; position: absolute; top: 0; left: 0; border-radius: 14px; }

/* ===== TABLES ===== */
.noti-table { font-size: 13px; }
.noti-table th {
  font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted); border-bottom: 2px solid var(--border);
  padding: 12px 16px;
}
.noti-table td { padding: 14px 16px; vertical-align: middle; border-bottom: 1px solid #f1f5f9; }
.noti-table tr:hover td { background: #fafbfc; }

/* ===== FORM STYLING ===== */
.form-control, .form-select {
  border-radius: 10px; border: 1.5px solid var(--border);
  padding: 10px 14px; font-size: 14px;
  transition: all .15s;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 4px rgba(79,70,229,.1);
}

/* ===== DROPZONE ===== */
.dropzone-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 12px;
  transition: all .25s;
  background: #fafbfc;
  cursor: pointer;
}
.dropzone-area:hover, .dropzone-active {
  border-color: var(--primary);
  background: #f0f0ff;
  box-shadow: 0 0 0 4px rgba(79,70,229,.06);
}
.img-preview-item {
  position: relative;
  width: 100px; height: 100px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid var(--border);
  display: flex; flex-direction: column;
  transition: all .2s;
}
.img-preview-item:hover { border-color: var(--primary); box-shadow: 0 4px 12px rgba(0,0,0,.1); }
.img-preview-thumb {
  flex: 1;
  background-size: cover;
  background-position: center;
  background-color: #f1f5f9;
}
.img-preview-info {
  padding: 4px 6px;
  background: #fff;
  border-top: 1px solid var(--border);
  line-height: 1.2;
}
.img-preview-remove {
  position: absolute; top: 4px; right: 4px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,.6);
  color: #fff;
  border: none;
  font-size: 10px;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
  z-index: 10;
}
.img-preview-item:hover .img-preview-remove { opacity: 1; }
.img-preview-remove:hover { background: var(--danger); }
.img-preview-add {
  width: 100px; height: 100px;
  border: 2px dashed var(--border);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  transition: all .2s;
}
.img-preview-add:hover { border-color: var(--primary); color: var(--primary); background: #f5f3ff;
}

/* ===== BUTTONS ===== */
.btn-noti {
  border-radius: 10px; font-weight: 600; font-size: 14px;
  padding: 10px 20px; transition: all .2s;
  display: inline-flex; align-items: center; gap: 8px;
}
.btn-noti-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff; border: none;
  box-shadow: 0 4px 14px rgba(79,70,229,.25);
}
.btn-noti-primary:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(79,70,229,.35); color: #fff; }
.btn-noti-success {
  background: linear-gradient(135deg, var(--success), #059669);
  color: #fff; border: none;
  box-shadow: 0 4px 14px rgba(16,185,129,.25);
}
.btn-noti-success:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(16,185,129,.35); color: #fff; }
.btn-noti-danger {
  background: linear-gradient(135deg, var(--danger), #dc2626);
  color: #fff; border: none;
}
.btn-noti-outline {
  background: var(--card); border: 1.5px solid var(--border);
  color: var(--text);
}
.btn-noti-outline:hover { border-color: var(--primary); color: var(--primary); background: #f5f3ff; }

/* ===== PROGRESS ===== */
.noti-progress {
  height: 10px; border-radius: 999px; background: #e2e8f0; overflow: hidden;
}
.noti-progress-bar {
  height: 100%; border-radius: 999px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width .4s ease;
}
.noti-progress-bar.animated {
  background-size: 200% 100%;
  animation: shimmer 2s linear infinite;
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ===== COUNTDOWN ===== */
.countdown-box {
  background: linear-gradient(135deg, #4f46e5, #7c3aed, #06b6d4);
  background-size: 200% 200%;
  animation: gradient-shift 4s ease infinite;
  color: #fff;
  border-radius: var(--radius);
  padding: 16px 24px;
  display: flex; align-items: center; justify-content: space-between;
  box-shadow: 0 8px 32px rgba(79,70,229,.2);
}
.countdown-time { font-size: 2rem; font-weight: 800; font-family: 'Inter', monospace; letter-spacing: 2px; }
@keyframes gradient-shift {
  0%,100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

/* ===== LOG BOX ===== */
.log-box {
  background: #0f172a;
  border-radius: var(--radius);
  padding: 16px;
  font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  color: #94a3b8;
  max-height: 420px;
  overflow-y: auto;
  border: 1px solid #1e293b;
}
.log-line { padding: 4px 0; border-bottom: 1px solid #1e293b; display: flex; gap: 8px; }
.log-success { color: #34d399; }
.log-error { color: #f87171; }
.log-info { color: #60a5fa; }
.log-time { color: #475569; min-width: 70px; flex-shrink: 0; }

/* ===== PRESET CARDS ===== */
.preset-card {
  cursor: pointer; border-radius: var(--radius);
  padding: 20px 16px; text-align: center;
  border: 2px solid var(--border);
  transition: all .25s;
  background: var(--card);
}
.preset-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.preset-card.selected { border-color: var(--primary); background: #f5f3ff; box-shadow: 0 0 0 4px rgba(79,70,229,.1); }
.preset-card .preset-icon { font-size: 32px; margin-bottom: 8px; }
.preset-card .preset-name { font-weight: 700; font-size: 14px; }
.preset-card .preset-desc { font-size: 11px; color: var(--text-muted); line-height: 1.5; margin-top: 4px; }
.preset-card.selected .preset-desc { color: var(--primary); }

/* ===== CONFIG SECTION ===== */
.config-group {
  padding: 16px;
  border: 1px solid #f1f5f9;
  border-radius: 10px;
  background: #fafbfc;
  transition: border-color .2s;
}
.config-group:hover { border-color: var(--primary-light); }
.config-group-title {
  font-weight: 600; font-size: 13px; color: var(--text-muted);
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 6px;
}

/* ===== BADGES ===== */
.badge-glass {
  backdrop-filter: blur(8px);
  border: 1px solid rgba(255,255,255,.2);
  font-weight: 600; font-size: 12px;
  padding: 6px 12px; border-radius: 999px;
}
.badge-status { padding: 5px 12px; border-radius: 999px; font-weight: 600; font-size: 11px; letter-spacing: .3px; }
.badge-draft { background: #f1f5f9; color: #64748b; }
.badge-running { background: #fef3c7; color: #92400e; }
.badge-completed { background: #d1fae5; color: #065f46; }

/* ===== ALERTS ===== */
.noti-alert {
  border-radius: var(--radius); padding: 14px 18px;
  display: flex; align-items: center; gap: 12px;
  font-size: 13px; font-weight: 500;
}
.noti-alert-success { background: #ecfdf5; color: #065f46; border: 1px solid #a7f3d0; }
.noti-alert-warning { background: #fffbeb; color: #92400e; border: 1px solid #fde68a; }
.noti-alert-danger { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }
.noti-alert-info { background: #eef2ff; color: #3730a3; border: 1px solid #c7d2fe; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center; padding: 48px 24px;
  color: var(--text-muted);
}
.empty-state i { font-size: 48px; opacity: .3; margin-bottom: 12px; }
.empty-state p { margin-top: 8px; }

/* ===== ANIMATIONS ===== */
.fade-in { animation: fadeIn .35s ease-out; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* ===== TOAST ===== */
.toast { border: none; border-radius: var(--radius); box-shadow: var(--shadow-lg); }

/* ===== RESPONSIVE ===== */
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .main-wrapper { margin-left: 0; }
  .content-area { padding: 20px 16px; }
  .topbar { padding: 0 16px; }
}
@media (min-width: 992px) {
  #toggle-sidebar { display: none !important; }
}

/* ===== Sidebar Download Button with pulse animation ===== */
.sidebar-download-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 9px 14px; margin: 6px 12px 4px;
  background: linear-gradient(135deg, #4f46e5, #06b6d4);
  color: #fff; border-radius: 10px;
  font-size: 12px; font-weight: 600;
  text-decoration: none;
  position: relative; overflow: hidden;
  transition: all .3s ease;
  box-shadow: 0 3px 10px rgba(79,70,229,.25);
}
.sidebar-download-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(79,70,229,.4);
  color: #fff;
}
.sidebar-download-btn i { font-size: 16px; }
.download-pulse {
  position: absolute; inset: 0;
  border-radius: 10px;
  box-shadow: 0 0 0 0 rgba(79,70,229,.5);
  animation: downloadPulse 2.5s infinite;
}
@keyframes downloadPulse {
  0% { box-shadow: 0 0 0 0 rgba(99,102,241,.5); }
  70% { box-shadow: 0 0 0 8px rgba(99,102,241,0); }
  100% { box-shadow: 0 0 0 0 rgba(99,102,241,0); }
}
/* Thu nhỏ khi đã kết nối (vẫn hiện để update) */
.sidebar-download-btn.compact {
  padding: 6px 12px; font-size: 11px;
  background: rgba(255,255,255,.08);
  box-shadow: none; margin-top: 4px;
}
.sidebar-download-btn.compact .download-pulse { animation: none; }
.sidebar-download-btn.compact:hover {
  background: rgba(255,255,255,.15);
  box-shadow: none; transform: none;
}
