/* ══════════════════════════════════════════════════════════════════════════
   YouTube Ads Tool — Dark UI Theme
   Watan Network
   ══════════════════════════════════════════════════════════════════════════ */

/* ── CSS Variables ────────────────────────────────────────────────────────── */
:root {
  --bg:           #0d1117;
  --surface:      #161b22;
  --surface2:     #21262d;
  --surface3:     #2d333b;
  --border:       #30363d;
  --border-muted: #21262d;
  --text:         #e6edf3;
  --text-muted:   #8b949e;
  --text-subtle:  #484f58;
  --accent:       #58a6ff;
  --green:        #238636;
  --green-hover:  #2ea043;
  --success:      #3fb950;
  --warning:      #d29922;
  --danger:       #f85149;
  --info:         #58a6ff;
  --radius:       6px;
  --radius-lg:    10px;
  --font-mono:    'JetBrains Mono', 'Fira Code', 'Consolas', 'Courier New', monospace;
  --font-ui:      -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --navbar-h:     52px;
}

/* ── Reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ── Scrollbar ────────────────────────────────────────────────────────────── */
::-webkit-scrollbar        { width: 6px; height: 6px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-subtle); }

/* ── Navbar ───────────────────────────────────────────────────────────────── */
.navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--navbar-h);
  padding: 0 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  flex-shrink: 0;
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand-icon {
  font-size: 18px;
  color: #ff4444;
  line-height: 1;
}

.brand-name {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.brand-sep {
  color: var(--text-subtle);
}

.brand-sub {
  font-size: 13px;
  color: var(--text-muted);
}

.navbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.navbar-user {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted);
}

.icon-user {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ── Flash messages ───────────────────────────────────────────────────────── */
.flash-container {
  padding: 10px 16px 0;
  flex-shrink: 0;
}

.flash {
  padding: 10px 14px;
  border-radius: var(--radius);
  margin-bottom: 8px;
  font-size: 13px;
  line-height: 1.5;
}

.flash-danger,
.flash-error   { background: rgba(248, 81, 73,  0.12); border: 1px solid rgba(248, 81, 73,  0.35); color: #f85149; }
.flash-success { background: rgba(63, 185, 80,  0.12); border: 1px solid rgba(63, 185, 80,  0.35); color: #3fb950; }
.flash-info,
.flash-message { background: rgba(88, 166, 255, 0.12); border: 1px solid rgba(88, 166, 255, 0.35); color: #79c0ff; }
.flash-warning { background: rgba(210, 153, 34, 0.12); border: 1px solid rgba(210, 153, 34, 0.35); color: #d29922; }

/* ── Page wrapper ─────────────────────────────────────────────────────────── */
.page {
  height: calc(100vh - var(--navbar-h));
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Unauthenticated pages (login) — no navbar, full viewport height */
.page-anon {
  height: 100vh;
  overflow: auto;
}

/* ── Login ────────────────────────────────────────────────────────────────── */
.login-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  padding: 24px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5);
}

.login-header {
  text-align: center;
  margin-bottom: 28px;
}

.login-logo {
  font-size: 44px;
  color: #ff4444;
  margin-bottom: 14px;
  line-height: 1;
}

.login-title {
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 6px;
  letter-spacing: -0.3px;
}

.login-sub {
  font-size: 13px;
  color: var(--text-muted);
}

.login-flashes {
  margin-bottom: 20px;
}

.login-flashes .flash:last-child {
  margin-bottom: 0;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.mt-form {
  margin-top: 4px;
}

/* ── Dashboard layout ─────────────────────────────────────────────────────── */
.dashboard {
  display: flex;
  flex: 1;
  overflow: hidden;
  height: 100%;
}

/* ── Sidebar ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: 300px;
  flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-section {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border-muted);
}

.sidebar-section:last-child {
  border-bottom: none;
  margin-top: auto;
}

.sidebar-run {
  padding: 18px;
  margin-top: auto;
  border-top: 1px solid var(--border);
  border-bottom: none;
}

.section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

/* ── Main area ────────────────────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 16px;
  gap: 14px;
  min-width: 0;
}

/* ── Panel header ─────────────────────────────────────────────────────────── */
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-muted);
}

/* ── Terminal ─────────────────────────────────────────────────────────────── */
.terminal-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  min-height: 0;
}

.terminal {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  line-height: 1.8;
  background: #010409;
  color: #c9d1d9;
  min-height: 0;
}

.log-line              { white-space: pre-wrap; word-break: break-all; }
.log-line.log-info     { color: #c9d1d9; }
.log-line.log-warning,
.log-line.log-warn     { color: #d29922; }
.log-line.log-error    { color: #f85149; }
.log-line.log-critical { color: #f85149; font-weight: 700; }
.log-line.log-debug    { color: var(--text-subtle); }

/* ── Reports panel ────────────────────────────────────────────────────────── */
.reports-panel {
  flex-shrink: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  max-height: 220px;
}

.table-wrapper {
  overflow-y: auto;
  flex: 1;
}

.reports-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}

.reports-table th {
  padding: 8px 14px;
  text-align: left;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1;
}

.reports-table td {
  padding: 8px 14px;
  border-bottom: 1px solid var(--border-muted);
  color: var(--text);
}

.reports-table tbody tr:last-child td {
  border-bottom: none;
}

.reports-table tbody tr:hover td {
  background: var(--surface2);
}

td.empty {
  color: var(--text-muted);
  text-align: center;
  padding: 20px;
  font-style: italic;
  font-size: 12px;
}

.dl-link {
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.dl-link:hover {
  color: #79c0ff;
}

/* ── Form elements ────────────────────────────────────────────────────────── */
.form-group {
  margin-bottom: 12px;
}

.form-group:last-child {
  margin-bottom: 0;
}

.form-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-ui);
  font-size: 13px;
  padding: 7px 10px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  -webkit-appearance: none;
}

.form-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.12);
}

.form-input::placeholder {
  color: var(--text-subtle);
}

.form-hint {
  display: block;
  font-size: 11px;
  color: var(--text-subtle);
  margin-top: 4px;
}

/* ── Radio buttons ────────────────────────────────────────────────────────── */
.radio-group {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.radio-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
}

.radio-label:hover {
  background: var(--surface2);
  border-color: var(--border);
}

.radio-label input[type="radio"] {
  display: none;
}

.radio-label:has(input:checked) {
  background: rgba(88, 166, 255, 0.07);
  border-color: rgba(88, 166, 255, 0.3);
}

.radio-dot {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border);
  margin-top: 3px;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
}

.radio-label input[type="radio"]:checked ~ .radio-dot {
  border-color: var(--accent);
  background: var(--accent);
  box-shadow: inset 0 0 0 3px var(--surface);
}

.radio-text strong {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.radio-text em {
  display: block;
  font-size: 11px;
  font-style: normal;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ── Checkboxes ───────────────────────────────────────────────────────────── */
.checkbox-label {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid transparent;
  transition: background 0.12s, border-color 0.12s;
  margin-bottom: 2px;
}

.checkbox-label:hover {
  background: var(--surface2);
  border-color: var(--border);
}

.checkbox-label input[type="checkbox"] {
  display: none;
}

.checkbox-box {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border-radius: 3px;
  border: 2px solid var(--border);
  margin-top: 2px;
  transition: background 0.15s, border-color 0.15s;
  position: relative;
}

.checkbox-label input:checked ~ .checkbox-box {
  background: var(--accent);
  border-color: var(--accent);
}

.checkbox-label input:checked ~ .checkbox-box::after {
  content: '';
  position: absolute;
  left: 2px;
  top: -1px;
  width: 6px;
  height: 9px;
  border: 2px solid #fff;
  border-top: none;
  border-left: none;
  transform: rotate(45deg);
}

.checkbox-text {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
}

.checkbox-text em {
  display: block;
  font-size: 11px;
  font-style: normal;
  color: var(--text-muted);
  margin-top: 1px;
}

/* ── Advanced details ─────────────────────────────────────────────────────── */
.advanced-details {
  cursor: default;
}

.advanced-summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  padding: 4px 0;
  user-select: none;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
}

.advanced-summary::-webkit-details-marker {
  display: none;
}

.advanced-summary::before {
  content: '▸';
  font-size: 10px;
  transition: transform 0.15s;
}

.advanced-details[open] .advanced-summary::before {
  transform: rotate(90deg);
}

.advanced-summary:hover {
  color: var(--text);
}

.advanced-body {
  padding-top: 14px;
}

/* ── Status row ───────────────────────────────────────────────────────────── */
.status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 12px;
  padding: 6px 10px;
  background: var(--bg);
  border-radius: var(--radius);
  border: 1px solid var(--border-muted);
}

.status-label {
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

/* ── Badges ───────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
}

.badge-idle    { background: var(--surface3); color: var(--text-muted); }
.badge-info    { background: rgba(88, 166, 255, 0.18);  color: #58a6ff; }
.badge-warning { background: rgba(210, 153, 34, 0.18);  color: #d29922; }
.badge-success { background: rgba(63, 185, 80, 0.18);   color: #3fb950; }
.badge-danger  { background: rgba(248, 81, 73, 0.18);   color: #f85149; }

/* ── Alerts ───────────────────────────────────────────────────────────────── */
.alert {
  padding: 10px 12px;
  border-radius: var(--radius);
  font-size: 12px;
  margin-bottom: 12px;
  line-height: 1.6;
}

.alert code {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.3);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 11px;
}

.alert-warning {
  background: rgba(210, 153, 34, 0.12);
  border: 1px solid rgba(210, 153, 34, 0.35);
  color: #d29922;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-ui);
  cursor: pointer;
  transition: background 0.12s, opacity 0.12s, color 0.12s, box-shadow 0.12s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1.3;
}

.btn-primary {
  background: var(--green);
  color: #ffffff;
}

.btn-primary:hover:not(:disabled) {
  background: var(--green-hover);
  text-decoration: none;
  box-shadow: 0 0 0 3px rgba(35, 134, 54, 0.25);
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}

.btn-outline:hover:not(:disabled) {
  background: var(--surface2);
  text-decoration: none;
}

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  padding: 4px 10px;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--surface2);
  color: var(--text);
  text-decoration: none;
}

.btn-sm {
  padding: 4px 10px;
  font-size: 12px;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ── Smart Ad ─────────────────────────────────────────────────────────────── */

.smart-ad-label:has(input:checked) {
  background: rgba(88, 166, 255, 0.07);
  border-color: rgba(88, 166, 255, 0.3);
}

.smart-ad-label:has(input:checked) .checkbox-text {
  color: var(--accent);
}

.smart-ad-info {
  background: var(--bg);
}

.smart-phases {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.smart-phase {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.phase-dot {
  flex-shrink: 0;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-top: 5px;
}

.phase-1 .phase-dot { background: #f85149; }  /* red   — high density  */
.phase-2 .phase-dot { background: #d29922; }  /* amber — medium        */
.phase-3 .phase-dot { background: #3fb950; }  /* green — low density   */

.phase-text strong {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text);
}

.phase-text em {
  display: block;
  font-size: 11px;
  font-style: normal;
  color: var(--text-muted);
  margin-top: 1px;
}
