@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap');

:root {
  --bg-main: #0c0d10;
  --bg-card: #15171d;
  --bg-card-hover: #1c1f26;
  --bg-input: #1b1e26;
  --border-color: #262a35;
  --border-focus: #ff5e62;
  --accent-coral: #ff5e62;
  --accent-coral-glow: rgba(255, 94, 98, 0.25);
  --accent-blue: #7ca8d8;
  --accent-green: #10b981;
  --accent-green-bg: rgba(16, 185, 129, 0.12);
  --accent-red: #ef4444;
  --accent-yellow: #f59e0b;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --text-dim: #6b7280;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow-lg: 0 14px 34px rgba(0, 0, 0, 0.45);
}

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

body {
  font-family: 'Cairo', -apple-system, BlinkMacSystemFont, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  direction: rtl;
  text-align: right;
  min-height: 100vh;
  line-height: 1.6;
}

/* Scrollbars */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: #3c4252;
}

/* Container */
.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 20px 80px 20px;
}

/* Top Navbar */
.top-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  margin-bottom: 24px;
  box-shadow: var(--shadow-lg);
}

.brand-badge {
  display: flex;
  flex-direction: column;
}

.brand-logo {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 24px;
  font-weight: 800;
  letter-spacing: 3px;
  color: #ffffff;
  line-height: 1.1;
}

.brand-sub {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  text-decoration: none;
}

.btn-primary {
  background: var(--accent-coral);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--accent-coral-glow);
}
.btn-primary:hover {
  background: #ff474d;
  transform: translateY(-1px);
}

.btn-secondary {
  background: #232733;
  color: #e5e7eb;
  border-color: var(--border-color);
}
.btn-secondary:hover {
  background: #2b303f;
  color: #ffffff;
}

.btn-blue {
  background: var(--accent-blue);
  color: #0b192c;
  font-weight: 700;
}
.btn-blue:hover {
  background: #8bb3e0;
}

.btn-success {
  background: var(--accent-green);
  color: #ffffff;
}
.btn-success:hover {
  background: #0ea372;
}

.btn-danger {
  background: var(--accent-red);
  color: #ffffff;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* Grid Layout */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

@media (max-width: 992px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }
}

/* Cards */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-lg);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
  margin-bottom: 20px;
}

.card-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 700;
  color: #ffffff;
}

.card-title .step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--accent-coral);
  color: #ffffff;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 800;
}

/* Form Controls */
.form-group {
  margin-bottom: 18px;
}

.form-label {
  display: block;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 7px;
}

.form-control {
  width: 100%;
  padding: 11px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-family: inherit;
  font-size: 14px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-coral-glow);
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 576px) {
  .form-row {
    grid-template-columns: 1fr;
  }
}

/* File Upload Drag & Drop Area */
.upload-dropzone {
  border: 2px dashed var(--border-color);
  border-radius: var(--radius);
  background: rgba(27, 30, 38, 0.6);
  padding: 30px 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
}

.upload-dropzone:hover, .upload-dropzone.drag-over {
  border-color: var(--accent-coral);
  background: rgba(255, 94, 98, 0.04);
}

.upload-icon {
  font-size: 36px;
  margin-bottom: 12px;
  color: var(--accent-coral);
}

.upload-dropzone input[type="file"] {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

/* Tabs for Recipients Input */
.tabs-nav {
  display: flex;
  gap: 8px;
  background: var(--bg-input);
  padding: 4px;
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.tab-btn {
  flex: 1;
  padding: 9px 14px;
  font-size: 13.5px;
  font-weight: 600;
  border-radius: 6px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
}

.tab-btn.active {
  background: var(--bg-card);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
}

/* Recipients Table */
.table-responsive {
  max-height: 280px;
  overflow-y: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  margin-top: 14px;
}

.recipients-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

.recipients-table th {
  background: #12141a;
  color: var(--text-muted);
  padding: 10px 14px;
  text-align: right;
  position: sticky;
  top: 0;
  z-index: 1;
  border-bottom: 1px solid var(--border-color);
}

.recipients-table td {
  padding: 9px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-main);
}

.recipients-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 11.5px;
  font-weight: 600;
}
.badge-valid { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-invalid { background: rgba(239, 68, 68, 0.15); color: #f87171; }
.badge-sent { background: rgba(16, 185, 129, 0.2); color: #10b981; }
.badge-pending { background: rgba(156, 163, 175, 0.15); color: #9ca3af; }

/* Live Preview Iframe Container */
.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.device-switcher {
  display: flex;
  gap: 6px;
  background: var(--bg-input);
  padding: 3px;
  border-radius: 6px;
}

.device-btn {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 4px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
}

.device-btn.active {
  background: var(--bg-card);
  color: #ffffff;
}

.preview-wrapper {
  background: #0b0c0e;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
  overflow: hidden;
}

.preview-iframe {
  width: 100%;
  max-width: 600px;
  height: 520px;
  border: none;
  border-radius: 8px;
  background: #0f1013;
  transition: max-width 0.3s ease;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
}

.preview-iframe.mobile-mode {
  max-width: 380px;
}

/* Dispatch Queue & Anti-Spam Controls */
.anti-spam-box {
  background: rgba(245, 158, 11, 0.06);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  margin-bottom: 20px;
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.anti-spam-box .icon {
  font-size: 20px;
  color: var(--accent-yellow);
}

.anti-spam-box .text {
  font-size: 13px;
  color: #fde68a;
  line-height: 1.6;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.stat-item {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
}

.stat-val {
  font-size: 24px;
  font-weight: 800;
  color: #ffffff;
  font-family: 'JetBrains Mono', monospace;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* Progress Bar */
.progress-container {
  margin-bottom: 20px;
}

.progress-info {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.progress-bar-bg {
  width: 100%;
  height: 12px;
  background: #101217;
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #ff5e62 0%, #34d399 100%);
  border-radius: 6px;
  transition: width 0.3s ease;
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.4);
}

/* Terminal / Live Log */
.terminal-card {
  background: #090a0d;
  border: 1px solid #1f222b;
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12.5px;
  height: 200px;
  overflow-y: auto;
  color: #94a3b8;
  line-height: 1.7;
}

.terminal-line {
  margin-bottom: 4px;
  word-break: break-all;
}

.terminal-line.success { color: #34d399; }
.terminal-line.error { color: #f87171; }
.terminal-line.info { color: #60a5fa; }
.terminal-line.warn { color: #fbbf24; }

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 999;
  padding: 16px;
}

.modal-overlay.active {
  display: flex;
}

.modal-dialog {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  max-width: 540px;
  width: 100%;
  padding: 24px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.8);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 14px;
  margin-bottom: 18px;
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 20px;
  color: var(--text-muted);
  cursor: pointer;
}
.modal-close:hover { color: #ffffff; }

/* Helper classes */
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.d-flex { display: flex; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.mt-3 { margin-top: 14px; }
.mb-3 { margin-bottom: 14px; }
