/* ============================================
   Dev - WP MIS – Custom Styles
   ============================================ */

:root {
  color-scheme: light;
  --sidebar-width: 260px;
  --sidebar-bg: #ffffff;
  --sidebar-text: #5b6b7c;
  --sidebar-title: #122033;
  --sidebar-active: #128c7e;
  --sidebar-hover-bg: #f0f7f4;
  --sidebar-hover-text: #122033;
  --sidebar-border: #e2e8f0;
  --topbar-height: 60px;
  --primary: #25d366;
  --primary-dark: #128c7e;
  --secondary: #34b7f1;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #06b6d4;
  --body-bg: #f0f4f8;
  --card-bg: #ffffff;
  --card-muted-bg: #f8fafc;
  --text-dark: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
  --input-bg: #ffffff;
  --input-text: #1e293b;
  --dropdown-bg: #ffffff;
  --dropdown-hover-bg: #f8fafc;
  --dropdown-text: #1e293b;
  --table-hover-bg: #f8fafc;
  --role-super-bg: #fef3c7;
  --role-super-text: #b45309;
  --role-reseller-bg: #ede9fe;
  --role-reseller-text: #7c3aed;
  --role-company-bg: #f0fdf4;
  --role-company-text: #15803d;
  --radius: 12px;
  --shadow: 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);
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --sidebar-bg: #081018;
  --sidebar-text: #9bb0bf;
  --sidebar-title: #f8fafc;
  --sidebar-active: #4ade80;
  --sidebar-hover-bg: #12202d;
  --sidebar-hover-text: #ffffff;
  --sidebar-border: rgba(255,255,255,.07);
  --primary: #4ade80;
  --primary-dark: #22c55e;
  --secondary: #38bdf8;
  --success: #22c55e;
  --warning: #fbbf24;
  --danger: #f87171;
  --info: #22d3ee;
  --body-bg: #0b1220;
  --card-bg: #111827;
  --card-muted-bg: #162033;
  --text-dark: #e5edf5;
  --text-muted: #94a3b8;
  --border-color: #243041;
  --input-bg: #0f172a;
  --input-text: #e5edf5;
  --dropdown-bg: #111827;
  --dropdown-hover-bg: #162033;
  --dropdown-text: #e5edf5;
  --table-hover-bg: #162033;
  --role-super-bg: rgba(251, 191, 36, .14);
  --role-super-text: #fbbf24;
  --role-reseller-bg: rgba(168, 85, 247, .14);
  --role-reseller-text: #c084fc;
  --role-company-bg: rgba(34, 197, 94, .14);
  --role-company-text: #4ade80;
  --shadow: 0 1px 3px rgba(0,0,0,.32), 0 1px 2px rgba(0,0,0,.24);
  --shadow-md: 0 12px 24px rgba(0,0,0,.3);
}

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

body {
  font-family: 'Inter', sans-serif;
  background-color: var(--body-bg);
  color: var(--text-dark);
  font-size: 14px;
  transition: background-color .25s ease, color .25s ease;
}

a {
  color: inherit;
}

/* ── Wrapper ─────────────────────────────────── */
.wrapper { display: flex; min-height: 100vh; }

/* ── Sidebar ─────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  transition: all .3s ease;
  overflow-y: auto;
}

.sidebar.collapsed { width: 70px; }
.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .sidebar-footer { display: none; }
.sidebar.collapsed .sidebar-header { justify-content: center; padding: 20px 10px; }
.sidebar.collapsed .nav-link { justify-content: center; padding: 12px 10px; }
.sidebar.collapsed .nav-link i { margin-right: 0; font-size: 18px; }

.sidebar-header {
  padding: 18px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}

.logo-icon {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, #25d366, #128c7e);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 18px;
  flex-shrink: 0;
}

.logo-text {
  font-size: 15px;
  font-weight: 700;
  color: var(--sidebar-title);
  line-height: 1.2;
}

.sidebar-nav { flex: 1; padding: 12px 0; }
.sidebar-nav ul { list-style: none; margin: 0; padding: 0; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all .2s ease;
  border-radius: 0;
}

.nav-link i { width: 18px; text-align: center; font-size: 14px; }

.nav-link:hover {
  background: var(--sidebar-hover-bg);
  color: var(--sidebar-hover-text);
  border-left-color: rgba(37,211,102,.4);
}

.nav-link.active {
  background: rgba(37,211,102,.12);
  color: var(--sidebar-active);
  border-left-color: var(--sidebar-active);
  font-weight: 600;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--sidebar-border);
  flex-shrink: 0;
}
.sidebar-footer small { color: var(--sidebar-text); font-size: 11px; }

/* ── Main content ─────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left .3s ease;
}

.sidebar.collapsed ~ .main-content { margin-left: 70px; }

/* ── Topbar ──────────────────────────────────── */
.top-navbar {
  height: var(--topbar-height);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 900;
  box-shadow: var(--shadow);
}

.page-title { font-size: 16px; font-weight: 600; color: var(--text-dark); }
.sidebar-toggle { color: var(--text-muted); border: none; background: none; cursor: pointer; }
.sidebar-toggle:hover { color: var(--primary-dark); }

.theme-toggle {
  min-width: 114px;
}

.role-chip {
  background: var(--card-muted-bg);
  color: var(--text-dark);
  border: 1px solid var(--border-color);
}

.role-chip-super {
  background: var(--role-super-bg);
  color: var(--role-super-text);
  border-color: transparent;
}

.role-chip-reseller {
  background: var(--role-reseller-bg);
  color: var(--role-reseller-text);
  border-color: transparent;
}

.role-chip-company {
  background: var(--role-company-bg);
  color: var(--role-company-text);
  border-color: transparent;
}

/* ── Cards ───────────────────────────────────── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  padding: 14px 18px;
  font-weight: 600;
  font-size: 14px;
}

/* ── Stat cards ──────────────────────────────── */
.stat-card {
  border-radius: var(--radius);
  padding: 20px;
  color: #fff;
  position: relative;
  overflow: hidden;
}

.stat-card .stat-icon {
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 42px;
  opacity: .2;
}

.stat-card h3 { font-size: 28px; font-weight: 700; margin: 4px 0; }
.stat-card p  { font-size: 13px; margin: 0; opacity: .85; }

.stat-green   { background: linear-gradient(135deg, #25d366, #128c7e); }
.stat-blue    { background: linear-gradient(135deg, #34b7f1, #1a73e8); }
.stat-orange  { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-red     { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.stat-purple  { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.stat-teal    { background: linear-gradient(135deg, #14b8a6, #0d9488); }

/* ── Tables ──────────────────────────────────── */
.table-card { border-radius: var(--radius); overflow: hidden; }
.table > :not(caption) > * > * { padding: .65rem .8rem; vertical-align: middle; }
.table { color: var(--text-dark); }
.table thead th {
  background: var(--card-muted-bg);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-muted);
  border-bottom: 2px solid var(--border-color);
}

.table tbody tr:hover { background: var(--table-hover-bg); }

/* ── Buttons ─────────────────────────────────── */
.btn-wa {
  background: linear-gradient(135deg, #25d366, #128c7e);
  color: #fff;
  border: none;
  border-radius: 8px;
}
.btn-wa:hover { background: #128c7e; color: #fff; }

.btn { border-radius: 8px; font-size: 13px; font-weight: 500; }
.btn-sm { font-size: 12px; padding: .25rem .6rem; border-radius: 6px; }

.btn-outline-secondary {
  color: var(--text-muted);
  border-color: var(--border-color);
  background: transparent;
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus,
.btn-outline-secondary:active,
.btn-outline-secondary.active {
  color: var(--text-dark);
  border-color: var(--border-color);
  background: var(--card-muted-bg);
}

/* ── Form controls ───────────────────────────── */
.form-control, .form-select {
  background: var(--input-bg);
  color: var(--input-text);
  border-radius: 8px;
  border-color: var(--border-color);
  font-size: 13.5px;
}
.form-control::placeholder { color: var(--text-muted); }
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,211,102,.15);
}

.form-label { font-size: 13px; font-weight: 500; color: var(--text-dark); margin-bottom: 4px; }

.form-control:disabled,
.form-control[readonly],
.form-select:disabled {
  background: var(--card-muted-bg);
  color: var(--text-muted);
}

/* ── Badges ──────────────────────────────────── */
.badge { font-size: 11px; padding: .35em .6em; border-radius: 6px; }

/* ── Progress bars ───────────────────────────── */
.progress { border-radius: 100px; height: 8px; }
.progress-bar { border-radius: 100px; }

/* ── Login page ──────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f1923 0%, #1a2a35 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-box {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

.login-logo {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, #25d366, #128c7e);
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: #fff;
  margin: 0 auto 20px;
}

/* ── Campaign status dot ─────────────────────── */
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  display: inline-block;
  margin-right: 6px;
}
.dot-running  { background: #25d366; animation: pulse 1.5s infinite; }
.dot-pending  { background: #f59e0b; }
.dot-done     { background: #64748b; }
.dot-failed   { background: #ef4444; }

@keyframes pulse {
  0%, 100% { opacity: 1; } 50% { opacity: .3; }
}

/* ── Import progress ─────────────────────────── */
.import-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius);
  padding: 40px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s;
}
.import-zone:hover, .import-zone.drag-over {
  border-color: var(--primary);
  background: rgba(37,211,102,.04);
}

.dropdown-menu {
  background: var(--dropdown-bg);
  color: var(--dropdown-text);
  border-color: var(--border-color);
  box-shadow: var(--shadow-md);
}

.dropdown-item,
.dropdown-item-text {
  color: var(--dropdown-text);
}

.dropdown-item:hover,
.dropdown-item:focus {
  background: var(--dropdown-hover-bg);
  color: var(--dropdown-text);
}

.dropdown-divider {
  border-top-color: var(--border-color);
}

.alert {
  border-color: var(--border-color);
  background: var(--card-bg);
  color: var(--text-dark);
}

.text-muted {
  color: var(--text-muted) !important;
}

:root[data-theme="dark"] .table,
:root[data-theme="dark"] .card,
:root[data-theme="dark"] .modal-content,
:root[data-theme="dark"] .offcanvas,
:root[data-theme="dark"] .list-group-item,
:root[data-theme="dark"] .pagination .page-link {
  background: var(--card-bg);
  color: var(--text-dark);
  border-color: var(--border-color);
}

:root[data-theme="dark"] .page-link:hover {
  background: var(--card-muted-bg);
  color: var(--text-dark);
}

:root[data-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
  color: var(--text-dark);
  background-color: rgba(255,255,255,.02);
}

:root[data-theme="dark"] .alert-warning {
  background: rgba(251, 191, 36, .12);
  color: #fcd34d;
}

:root[data-theme="dark"] .alert-success {
  background: rgba(34, 197, 94, .12);
  color: #86efac;
}

:root[data-theme="dark"] .alert-danger {
  background: rgba(248, 113, 113, .12);
  color: #fca5a5;
}

:root[data-theme="dark"] .alert-info {
  background: rgba(34, 211, 238, .12);
  color: #67e8f9;
}

/* ── Responsive ──────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
  .stat-card h3 { font-size: 22px; }
}

/* ── Toast Notifications ─────────────────────── */
.notif-toast {
  position: fixed;
  top: 18px;
  right: 22px;
  z-index: 9999;
  min-width: 290px;
  max-width: 420px;
  border-radius: 10px;
  padding: 14px 18px 14px 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  box-shadow: 0 4px 18px rgba(0,0,0,.15);
  animation: notifSlideIn .35s ease;
}
@keyframes notifSlideIn {
  from { opacity: 0; transform: translateX(60px); }
  to   { opacity: 1; transform: translateX(0); }
}
.notif-toast.success { background: #d1fae5; border-left: 5px solid #10b981; color: #065f46; }
.notif-toast.error   { background: #fee2e2; border-left: 5px solid #ef4444; color: #7f1d1d; }
.notif-toast.warning { background: #fef3c7; border-left: 5px solid #f59e0b; color: #78350f; }
.notif-toast.info    { background: #e0f2fe; border-left: 5px solid #0ea5e9; color: #0c4a6e; }
.notif-toast .notif-icon  { font-size: 1.2rem; margin-top: 1px; flex-shrink: 0; }
.notif-toast .notif-body  { flex: 1; font-size: .92rem; }
.notif-toast .notif-close {
  background: none; border: none; cursor: pointer;
  font-size: 1.1rem; opacity: .55; padding: 0; line-height: 1; margin-top: 1px; flex-shrink: 0;
}
.notif-toast .notif-close:hover { opacity: 1; }
