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

:root {
  --primary: #6366f1;
  --primary-light: #818cf8;
  --primary-dark: #4f46e5;
  --bg: #0f0f14;
  --bg-card: #1a1a24;
  --bg-input: #12121a;
  --bg-hover: #252535;
  --text: #e8e8ed;
  --text-muted: #8888a0;
  --text-dim: #55556a;
  --success: #22c55e;
  --danger: #ef4444;
  --warning: #f59e0b;
  --border: #2a2a3a;
  --radius: 14px;
  --radius-sm: 10px;
  --transition: 0.2s ease;
}

html {
  font-size: 16px;
}

body {
  font-family: 'Heebo', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}

/* ===== Top Bar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(15, 15, 20, 0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.logo {
  font-size: 1.25rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary-light), var(--primary));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.topbar-left {
  display: flex;
  gap: 4px;
}

.icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 10px;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}

.icon-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}

/* ===== Container ===== */
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  padding-bottom: 40px;
}

/* ===== Screens ===== */
.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ===== Card ===== */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--border);
}

/* ===== Typography ===== */
.screen-title {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 20px;
}

.screen-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.screen-header .screen-title {
  margin-bottom: 0;
}

/* ===== Back Button ===== */
.btn-back {
  display: flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.9rem;
  padding: 6px 8px;
  border-radius: 8px;
  transition: var(--transition);
}

.btn-back:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.btn-back svg {
  transform: scaleX(-1);
}

/* ===== Form Elements ===== */
.form-group {
  margin-bottom: 16px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

input[type="text"],
select,
textarea {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 0.95rem;
  transition: var(--transition);
  outline: none;
}

input[type="text"]:focus,
select:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

textarea {
  resize: vertical;
  min-height: 120px;
  line-height: 1.6;
}

select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238888a0' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 12px center;
}

/* ===== Phone Summary ===== */
.phone-summary {
  display: flex;
  gap: 16px;
  padding: 12px 14px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.85rem;
}

.summary-item {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-valid { background: var(--success); }
.dot-invalid { background: var(--danger); }
.dot-duplicate { background: var(--warning); }

.summary-item strong {
  color: var(--text);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  width: 100%;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  background: var(--primary-dark);
  transform: translateY(-1px);
}

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

.btn-secondary {
  background: var(--bg-hover);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--border);
}

.btn-danger {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
  background: rgba(239, 68, 68, 0.25);
}

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

.btn-outline:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-small {
  padding: 8px 14px;
  font-size: 0.85rem;
  width: auto;
}

/* ===== Preview Table ===== */
.preview-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}

.checkbox-label input[type="checkbox"] {
  accent-color: var(--primary);
  width: 16px;
  height: 16px;
}

.table-container {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 16px;
  overflow: hidden;
}

.table-header {
  display: flex;
  padding: 10px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 1px solid var(--border);
  background: rgba(99, 102, 241, 0.05);
}

.col { flex-shrink: 0; }
.col-check { width: 30px; }
.col-idx { width: 30px; }
.col-original { flex: 1; min-width: 0; }
.col-processed { flex: 1; min-width: 0; }
.col-country { width: 50px; text-align: center; }
.col-status { width: 60px; text-align: center; }

.virtual-table {
  height: 300px;
  overflow-y: auto;
  position: relative;
}

.table-row {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  font-size: 0.82rem;
  border-bottom: 1px solid rgba(42, 42, 58, 0.5);
  transition: background var(--transition);
}

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

.table-row.row-invalid {
  opacity: 0.5;
}

.table-row.row-duplicate {
  opacity: 0.6;
}

.table-row input[type="checkbox"] {
  accent-color: var(--primary);
  width: 14px;
  height: 14px;
}

.status-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.7rem;
  font-weight: 600;
}

.status-badge.valid {
  background: rgba(34, 197, 94, 0.15);
  color: var(--success);
}

.status-badge.invalid {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.status-badge.duplicate {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
}

/* ===== Progress Ring ===== */
.progress-ring-container {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 0 auto 20px;
}

.progress-ring {
  transform: rotate(-90deg);
}

.progress-ring-bg {
  fill: none;
  stroke: var(--border);
  stroke-width: 8;
}

.progress-ring-fill {
  fill: none;
  stroke: var(--primary);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 439.82;
  stroke-dashoffset: 439.82;
  transition: stroke-dashoffset 0.4s ease;
}

.progress-ring-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.progress-percent {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary-light);
}

/* ===== Stats Grid ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

.stat-card {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 8px;
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.stat-card-success .stat-value { color: var(--success); }
.stat-card-fail .stat-value { color: var(--danger); }

.eta {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ===== Send Controls ===== */
.send-controls {
  display: flex;
  gap: 10px;
  margin-bottom: 20px;
}

.send-controls .btn {
  flex: 1;
}

/* ===== Log ===== */
.log-container {
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}

.log-title {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-dim);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.log-list {
  height: 200px;
  overflow-y: auto;
  padding: 8px 14px;
  font-size: 0.78rem;
  font-family: 'Courier New', monospace;
  direction: ltr;
  text-align: left;
}

.log-entry {
  padding: 3px 0;
  border-bottom: 1px solid rgba(42, 42, 58, 0.3);
  display: flex;
  gap: 8px;
}

.log-entry .log-phone {
  color: var(--text-muted);
  min-width: 120px;
}

.log-entry .log-status {
  font-weight: 600;
}

.log-entry .log-status.ok { color: var(--success); }
.log-entry .log-status.fail { color: var(--danger); }

.log-entry .log-time {
  color: var(--text-dim);
  margin-right: auto;
}

/* ===== Summary ===== */
.summary-header {
  padding: 12px 14px;
  background: var(--bg-input);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
  font-size: 0.9rem;
  line-height: 1.8;
  color: var(--text-muted);
}

.summary-header strong {
  color: var(--text);
}

.summary-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.summary-actions .btn {
  flex: 1;
  min-width: 0;
  font-size: 0.82rem;
  padding: 10px 8px;
}

.summary-bottom-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* ===== Settings ===== */
.settings-section {
  margin-bottom: 24px;
}

.settings-section h3 {
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.help-text {
  font-size: 0.8rem;
  color: var(--text-dim);
  line-height: 1.7;
  padding: 10px 14px;
  background: rgba(99, 102, 241, 0.05);
  border: 1px solid rgba(99, 102, 241, 0.1);
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
}

.help-text strong {
  color: var(--text-muted);
}

.list-manager {
  margin-bottom: 10px;
}

.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 6px;
  font-size: 0.9rem;
}

.list-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.list-item-name {
  font-weight: 500;
}

.list-item-id {
  font-size: 0.75rem;
  color: var(--text-dim);
  font-family: monospace;
  direction: ltr;
  text-align: right;
}

.list-item .btn-delete {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: var(--transition);
  display: flex;
  align-items: center;
}

.list-item .btn-delete:hover {
  background: rgba(239, 68, 68, 0.15);
}

.add-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.add-form input {
  flex: 1;
  padding: 8px 12px;
  font-size: 0.85rem;
}

/* ===== Slider ===== */
.slider-group {
  display: flex;
  align-items: center;
  gap: 14px;
}

.slider-group input[type="range"] {
  flex: 1;
  accent-color: var(--primary);
  height: 6px;
}

.slider-value {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--primary-light);
  min-width: 60px;
  text-align: center;
  direction: ltr;
}

/* ===== Retries ===== */
.retries-group {
  display: flex;
  gap: 8px;
}

.retries-btn {
  flex: 1;
  padding: 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.retries-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
}

.retries-btn:hover:not(.active) {
  background: var(--bg-hover);
}

/* ===== History ===== */
.history-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: var(--transition);
}

.history-item:hover {
  background: var(--bg-hover);
  border-color: var(--primary);
}

.history-item-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.history-item-name {
  font-weight: 600;
  font-size: 0.95rem;
}

.history-item-meta {
  font-size: 0.78rem;
  color: var(--text-dim);
}

.history-item-stats {
  text-align: left;
  font-size: 0.85rem;
}

.history-item-stats .h-success {
  color: var(--success);
  font-weight: 600;
}

.history-item-stats .h-fail {
  color: var(--danger);
  font-weight: 600;
}

.empty-state {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-dim);
  font-size: 0.9rem;
}

/* ===== Scrollbar ===== */
::-webkit-scrollbar {
  width: 4px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* ===== Mobile Adjustments ===== */
@media (max-width: 480px) {
  .container {
    padding: 12px;
  }

  .card {
    padding: 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .phone-summary {
    flex-wrap: wrap;
    gap: 10px;
  }

  .summary-actions .btn {
    font-size: 0.78rem;
    padding: 8px 6px;
  }
}
