/* Importing Google Fonts - Poppins */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Poppins", sans-serif;
}
:root {
  /* Light theme colors */
  --color-text-primary: #1F2936;
  --color-text-placeholder: #798EAE;
  --color-bg-primary: #f9fafb;
  --color-bg-secondary: #ECECFD;
  --color-bg-sidebar: #FFFFFF;
  --color-border-hr: #E2E8F0;
  --color-hover-primary: #695CFE;
  --color-hover-secondary: #e2e2fb;
  --color-shadow: rgba(0, 0, 0, 0.05);

  /* Extended app colors (light) */
  --input-bg: #ffffff;
  --table-th: #f8fafc;
  --row-hover: #f5f6fa;
  --dropzone-bg: #f6f7fb;
  --progress-track: #e9ecf3;
  --scrollbar: #d4d4dc;
  --scrollbar-hover: #b8b8c2;
  --success: #059669;
  --success-weak: #e7f8f1;
  --danger: #e11d48;
  --danger-weak: #fdecef;
  --warning: #d97706;
  --warning-weak: #fdf3e2;
  --console-bg: #17171d;
  --console-border: #26262e;
  --console-line: rgba(255, 255, 255, 0.07);
  --console-ink: #f5f5f8;
  --console-muted: #9d9daa;
  --console-dim: #5f5f6a;

  /* Compatibility aliases used by pages/JS */
  --accent: #695CFE;
  --ink-muted: var(--color-text-placeholder);
  --ink-dim: #94a3b8;
  --accent-weak: var(--color-hover-secondary);
  --accent-glow: rgba(105, 92, 254, 0.35);
  --grad: linear-gradient(135deg, #695CFE, #8b5cf6);
  --space: clamp(1rem, 0.7rem + 1.2vw, 1.5rem);
  --space-sm: calc(var(--space) * 0.6);
  --space-xs: calc(var(--space) * 0.3);
}
body.dark-theme {
  /* Dark theme colors */
  --color-text-primary: #F1F5F9;
  --color-text-placeholder: #A6B7D2;
  --color-bg-primary: #111827;
  --color-bg-secondary: #3D4859;
  --color-bg-sidebar: #1f2937;
  --color-border-hr: #3B475C;
  --color-hover-secondary: #48566a;
  --color-shadow: rgba(0, 0, 0, 0.3);

  /* Extended app colors (dark) */
  --input-bg: #111827;
  --table-th: #1f2937;
  --row-hover: #243046;
  --dropzone-bg: #1f2937;
  --progress-track: #3D4859;
  --scrollbar: #48566a;
  --scrollbar-hover: #5c6b82;
  --success: #34d399;
  --success-weak: rgba(52, 211, 153, 0.15);
  --danger: #fb7185;
  --danger-weak: rgba(251, 113, 133, 0.15);
  --warning: #fbbf24;
  --warning-weak: rgba(251, 191, 36, 0.15);
  --console-bg: #0b0f19;
  --console-border: #3B475C;
  --console-line: rgba(255, 255, 255, 0.08);
  --console-ink: #f1f5f9;
  --console-muted: #a6b7d2;
  --console-dim: #64748b;

  --ink-dim: #64748b;
  --accent-glow: rgba(105, 92, 254, 0.5);
}
body {
  min-height: 100vh;
  background: var(--color-bg-primary);
  color: var(--color-text-primary);
  -webkit-font-smoothing: antialiased;
}

/* ===== Sidebar ===== */
.sidebar {
  position: sticky;
  top: 0;
  width: 270px;
  height: 100vh;
  display: flex;
  flex-shrink: 0;
  flex-direction: column;
  background: var(--color-bg-sidebar);
  border-right: 1px solid var(--color-border-hr);
  box-shadow: 0 3px 9px var(--color-shadow);
  transition: width 0.4s ease;
}
.sidebar.collapsed {
  width: 90px;
}
.sidebar .sidebar-header {
  padding: 20px 18px;
  display: flex;
  position: relative;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--color-border-hr);
}
.sidebar-header .brand {
  display: flex;
  align-items: center;
  gap: 12px;
  overflow: hidden;
}
.sidebar-header .brand-icon {
  width: 46px;
  height: 46px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--grad);
  color: #fff;
  box-shadow: 0 4px 14px var(--accent-glow);
}
.sidebar-header .brand-icon svg {
  width: 22px;
  height: 22px;
}
.sidebar-header .brand-text {
  transition: opacity 0.4s ease;
  white-space: nowrap;
}
.sidebar.collapsed .brand-text {
  opacity: 0;
  pointer-events: none;
}
.brand-text h1 {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: -0.02em;
}
.site-nav .sidebar-toggle,
.sidebar-header .sidebar-toggle {
  height: 40px;
  width: 40px;
  border: none;
  cursor: pointer;
  display: flex;
  position: absolute;
  right: 18px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  color: var(--color-text-primary);
  background: var(--color-bg-secondary);
  transition: 0.4s ease;
}
.site-nav .sidebar-toggle:hover,
.sidebar-header .sidebar-toggle:hover {
  background: var(--color-hover-secondary);
}
.site-nav .sidebar-toggle svg,
.sidebar-header .sidebar-toggle svg {
  width: 22px;
  height: 22px;
}
.sidebar.collapsed .sidebar-header .sidebar-toggle {
  transform: translateX(-2px);
  height: 48px;
  width: 50px;
}
.sidebar-header .sidebar-toggle svg {
  transition: transform 0.4s ease;
}
.sidebar.collapsed .sidebar-toggle svg {
  transform: rotate(180deg);
}
.sidebar .sidebar-content {
  flex: 1;
  padding: 20px 18px;
  overflow: hidden auto;
  scrollbar-width: thin;
  scrollbar-color: var(--color-text-placeholder) transparent;
}
.sidebar.collapsed .sidebar-content {
  scrollbar-width: none;
}
.sidebar-content .menu-list {
  display: flex;
  gap: 4px;
  list-style: none;
  flex-direction: column;
}
.menu-list .menu-link {
  display: flex;
  gap: 12px;
  white-space: nowrap;
  width: 100%;
  border: none;
  border-radius: 8px;
  padding: 12px 15px;
  align-items: center;
  text-decoration: none;
  background: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  color: var(--color-text-primary);
  transition: 0.3s ease;
}
.menu-list .menu-link svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}
.menu-link .menu-label {
  transition: opacity 0.3s ease;
}
.sidebar.collapsed .menu-link .menu-label {
  opacity: 0;
  pointer-events: none;
}
.menu-list .menu-link:is(:hover, .active) {
  color: #fff;
  background: var(--color-hover-primary);
}
.sidebar .sidebar-footer {
  padding: 20px 18px;
  white-space: nowrap;
  border-top: 1px solid var(--color-border-hr);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-footer .theme-toggle {
  width: 100%;
  min-height: 48px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  cursor: pointer;
  border: none;
  padding: 0 15px;
  white-space: nowrap;
  color: var(--color-text-primary);
  background: var(--color-bg-secondary);
  transition: 0.3s ease;
  font-family: inherit;
}
.sidebar-footer .theme-toggle:hover {
  background: var(--color-hover-secondary);
}
.theme-toggle .theme-label {
  display: flex;
  gap: 10px;
  align-items: center;
}
.theme-icon {
  display: grid;
  place-items: center;
}
.theme-icon svg {
  width: 20px;
  height: 20px;
}
.theme-icon .icon-sun {
  display: none;
}
body.dark-theme .theme-icon .icon-moon {
  display: none;
}
body.dark-theme .theme-icon .icon-sun {
  display: block;
}
.theme-toggle .theme-label .theme-text {
  font-size: 1rem;
  transition: opacity 0.4s 0.2s ease;
}
.sidebar.collapsed .theme-toggle :where(.theme-text, .theme-toggle-track) {
  opacity: 0;
  width: 0;
  transition: all 0.2s ease;
}
.theme-toggle .theme-toggle-track {
  height: 24px;
  width: 48px;
  border-radius: 999px;
  margin-left: auto;
  background: #c3d1ec;
  position: relative;
  transition: opacity 0.4s 0.2s ease, background-color 0.3s ease;
  flex-shrink: 0;
}
body.dark-theme .theme-toggle-track {
  background: #695CFE;
}
.theme-toggle-track .theme-toggle-indicator {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background-color: #fff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  transition: transform 0.3s ease;
}
body.dark-theme .theme-toggle-indicator {
  transform: translateX(24px);
}

/* ===== Mobile nav ===== */
.site-nav {
  top: 0;
  display: none;
  padding: 15px 20px;
  position: sticky;
  z-index: 15;
  background: var(--color-bg-primary);
  border-bottom: 1px solid var(--color-border-hr);
}
.site-nav .sidebar-toggle {
  position: unset;
}

/* ===== Layout ===== */
.container {
  display: flex;
  min-height: 100vh;
}
.container .main-content {
  flex: 1;
  padding: 30px;
  color: var(--color-text-primary);
  display: flex;
  flex-direction: column;
  gap: var(--space);
}
.main-content .page-title {
  font-size: 1.5rem;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: -0.02em;
}

/* ===== Cards ===== */
.main-content .card {
  border-radius: 12px;
  padding: var(--space);
  background-color: var(--color-bg-sidebar);
  border: 1px solid var(--color-border-hr);
  box-shadow: 0 1px 3px var(--color-shadow);
  animation: fade-up 0.35s ease both;
}
.card-title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--space-sm);
  display: flex;
  align-items: center;
  gap: 10px;
  letter-spacing: -0.01em;
}
.card-title svg {
  width: 18px;
  height: 18px;
  color: var(--color-hover-primary);
  flex-shrink: 0;
}

/* ===== Forms ===== */
.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-sm);
}
label {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-text-placeholder);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
input[type="text"], input[type="password"], input[type="number"], input[type="url"], select, textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--color-border-hr);
  border-radius: 8px;
  background: var(--input-bg);
  color: var(--color-text-primary);
  font-family: inherit;
  font-size: 0.9rem;
  transition: border-color 0.2s, box-shadow 0.2s;
}
textarea {
  resize: vertical;
  min-height: 100px;
  line-height: 1.5;
}
input:hover, select:hover, textarea:hover {
  border-color: var(--color-text-placeholder);
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--color-hover-primary);
  box-shadow: 0 0 0 3px var(--color-hover-secondary);
}
input::placeholder, textarea::placeholder {
  color: var(--color-text-placeholder);
}
.hint {
  font-size: 0.75rem;
  color: var(--color-text-placeholder);
  margin-top: 4px;
}
.section-divider {
  height: 1px;
  background: var(--color-border-hr);
  margin: var(--space) 0;
}

/* ===== Buttons ===== */
.btn {
  appearance: none;
  border: none;
  background: var(--grad);
  color: #fff;
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 12px 28px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 16px var(--accent-glow);
}
.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px var(--accent-glow);
  filter: brightness(1.05);
}
.btn:active:not(:disabled) {
  transform: translateY(0);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-secondary {
  background: var(--color-bg-sidebar);
  color: var(--color-text-primary);
  box-shadow: none;
  border: 1px solid var(--color-border-hr);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--color-hover-secondary);
  box-shadow: none;
  filter: none;
}
.btn-danger {
  background: linear-gradient(135deg, var(--danger), #f43f5e);
  box-shadow: 0 4px 16px color-mix(in oklab, var(--danger) 25%, transparent);
}
.btn-sm {
  padding: 6px 14px;
  font-size: 0.78rem;
  border-radius: 8px;
  box-shadow: none;
}

/* ===== Mode switch ===== */
.mode-switch {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  background: var(--color-bg-primary);
  border: 1px solid var(--color-border-hr);
  border-radius: 999px;
  padding: 6px;
  width: fit-content;
}
.mode-option {
  position: relative;
}
.mode-option input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.mode-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--color-text-placeholder);
  cursor: pointer;
  transition: all 0.25s ease;
  user-select: none;
}
.mode-label svg {
  width: 18px;
  height: 18px;
  opacity: 0.6;
  transition: opacity 0.25s;
}
.mode-option input:checked + .mode-label {
  background: var(--color-hover-primary);
  color: #fff;
  box-shadow: 0 4px 18px var(--accent-glow);
}
.mode-option input:checked + .mode-label svg {
  opacity: 1;
  color: #fff;
}
.mode-label:hover {
  color: var(--color-text-primary);
}
.mode-option input:checked + .mode-label:hover {
  color: #fff;
}

/* ===== Dropzone ===== */
.dropzone {
  border: 2px dashed var(--color-border-hr);
  border-radius: 12px;
  padding: var(--space);
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--dropzone-bg);
  position: relative;
}
.dropzone:hover, .dropzone.dragover {
  border-color: var(--color-hover-primary);
  background: var(--color-hover-secondary);
}
.dropzone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}
.dropzone-icon {
  width: 40px;
  height: 40px;
  color: var(--color-text-placeholder);
  margin-bottom: var(--space-xs);
}
.dropzone-text {
  font-size: 0.9rem;
  color: var(--color-text-primary);
  font-weight: 500;
}
.dropzone-sub {
  font-size: 0.75rem;
  color: var(--color-text-placeholder);
  margin-top: 2px;
}
.dropzone-name {
  font-size: 0.85rem;
  color: var(--color-hover-primary);
  font-weight: 600;
  margin-top: var(--space-xs);
  word-break: break-all;
}

/* ===== Tables / preview ===== */
.preview-wrap {
  max-height: 280px;
  overflow: auto;
  border: 1px solid var(--color-border-hr);
  border-radius: 8px;
  margin-top: var(--space-sm);
}
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}
th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--color-border-hr);
}
th {
  background: var(--table-th);
  color: var(--color-text-placeholder);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  position: sticky;
  top: 0;
}
tr:last-child td {
  border-bottom: none;
}
tr:hover td {
  background: var(--row-hover);
}

/* ===== Progress ===== */
.progress-wrap {
  margin-top: var(--space-sm);
}
.progress-bar-bg {
  height: 8px;
  background: var(--progress-track);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid var(--color-border-hr);
}
.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--grad);
  border-radius: 999px;
  transition: width 0.3s ease;
  box-shadow: 0 0 12px var(--accent-glow);
}
.progress-text {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--color-text-placeholder);
  margin-top: 6px;
}

/* ===== Stats ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}
.stat-box {
  background: var(--color-bg-sidebar);
  border: 1px solid var(--color-border-hr);
  border-radius: 12px;
  padding: var(--space-sm);
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.2s;
}
.stat-box:hover {
  border-color: var(--color-text-placeholder);
  box-shadow: 0 4px 14px var(--color-shadow);
  transform: translateY(-1px);
}
.stat-icon {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  margin: 0 auto 8px;
}
.stat-icon svg {
  width: 16px;
  height: 16px;
}
.stat-icon.success { background: var(--success-weak); color: var(--success); }
.stat-icon.fail { background: var(--danger-weak); color: var(--danger); }
.stat-icon.pending { background: var(--warning-weak); color: var(--warning); }
.stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
}
.stat-value.success { color: var(--success); }
.stat-value.fail { color: var(--danger); }
.stat-value.pending { color: var(--warning); }
.stat-label {
  font-size: 0.7rem;
  color: var(--color-text-placeholder);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-top: 4px;
}

/* ===== Log console ===== */
.log-wrap {
  max-height: 320px;
  overflow: auto;
  background: var(--console-bg);
  border: 1px solid var(--console-border);
  border-radius: 8px;
  padding: var(--space-sm);
  margin-top: var(--space-sm);
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  color: var(--console-ink);
}
.log-entry {
  padding: 7px 0;
  border-bottom: 1px solid var(--console-line);
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.log-entry:last-child {
  border-bottom: none;
}
.log-status {
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin-top: 1px;
}
.log-status.ok { background: rgba(52, 211, 153, 0.16); color: #34d399; }
.log-status.err { background: rgba(251, 113, 133, 0.16); color: #fb7185; }
.log-status.wait { background: rgba(251, 191, 36, 0.16); color: #fbbf24; }
.log-status svg {
  width: 10px;
  height: 10px;
}
.log-body {
  flex: 1;
  min-width: 0;
}
.log-phone {
  font-weight: 600;
  color: var(--console-ink);
}
.log-msg {
  color: var(--console-muted);
  word-break: break-word;
}
.log-detail {
  color: var(--console-dim);
  font-size: 0.72rem;
  margin-top: 2px;
}

/* ===== Misc ===== */
.hidden {
  display: none !important;
}
.count-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--color-bg-sidebar);
  border: 1px solid var(--color-border-hr);
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  color: var(--color-text-placeholder);
  margin-top: var(--space-xs);
}
.count-badge strong {
  color: var(--color-hover-primary);
}
.guide-steps {
  list-style: none;
  counter-reset: guide;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.guide-steps li {
  counter-increment: guide;
  position: relative;
  padding-left: 1.9rem;
  font-size: 0.88rem;
  color: var(--color-text-placeholder);
  line-height: 1.6;
}
.guide-steps li::before {
  content: counter(guide);
  position: absolute;
  left: 0;
  top: 2px;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  background: var(--color-bg-sidebar);
  border: 1px solid var(--color-border-hr);
  color: var(--color-hover-primary);
  font-size: 0.72rem;
  font-weight: 600;
  display: grid;
  place-items: center;
}
.guide-steps strong {
  color: var(--color-text-primary);
}
.guide-steps code {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.78rem;
  background: var(--color-bg-secondary);
  border: 1px solid var(--color-border-hr);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--color-hover-primary);
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(1.3); }
}
.sending-indicator {
  width: 8px;
  height: 8px;
  background: var(--color-hover-primary);
  border-radius: 50%;
  display: inline-block;
  animation: pulse-dot 1.2s ease-in-out infinite;
  margin-right: 8px;
}

::selection {
  background: var(--color-hover-secondary);
}
:focus-visible {
  outline: 2px solid var(--color-hover-primary);
  outline-offset: 2px;
}
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar);
  border-radius: 999px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-hover);
}

/* Responsive media query code for small screens */
@media (max-width: 768px) {
  body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
    background: rgba(0, 0, 0, 0.6);
    transition: 0.4s ease;
  }
  body:has(.sidebar:not(.collapsed))::before {
    opacity: 1;
    pointer-events: auto;
  }
  body:has(.sidebar:not(.collapsed)) {
    overflow: hidden;
  }
  .site-nav {
    display: block;
  }
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 20;
    width: 270px;
    transition: left 0.4s ease;
  }
  .sidebar.collapsed {
    left: -270px;
    width: 270px;
  }
  .sidebar.collapsed .sidebar-header .sidebar-toggle {
    transform: none;
    height: 40px;
    width: 40px;
  }
  .sidebar.collapsed .sidebar-toggle svg {
    transform: none;
  }
  .sidebar.collapsed .brand-text,
  .sidebar.collapsed .menu-link .menu-label,
  .sidebar.collapsed .theme-toggle :where(.theme-text, .theme-toggle-track) {
    opacity: 1;
    pointer-events: auto;
    width: auto;
  }
  .container .main-content {
    padding: 30px 20px;
  }
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
  .mode-switch {
    width: 100%;
    justify-content: center;
  }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
