:root {
  --font-arabic: 'Cairo', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  --font-main: 'Cairo', system-ui, -apple-system, sans-serif;

  --color-bg: #f8fafc;
  --color-surface: #ffffff;
  --color-surface-hover: #f1f5f9;
  --color-border: #e2e8f0;
  --color-border-dark: #cbd5e1;

  --color-primary: #0284c7;
  --color-primary-hover: #0369a1;
  --color-primary-light: #e0f2fe;

  --color-navy: #0f172a;
  --color-text-main: #1e293b;
  --color-text-muted: #64748b;
  --color-text-dim: #94a3b8;

  --color-success: #10b981;
  --color-success-bg: #ecfdf5;
  --color-warning: #f59e0b;
  --color-warning-bg: #fffbeb;
  --color-danger: #ef4444;
  --color-danger-bg: #fef2f2;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.07);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.08);

  /* Shorthand aliases used by map.css */
  --primary: var(--color-primary);
  --primary-hover: var(--color-primary-hover);
  --primary-light: var(--color-primary-light);
  --primary-dark: #0369a1;
  --surface: var(--color-surface);
  --bg-alt: var(--color-surface-hover);
  --border: var(--color-border);
  --text: var(--color-text-main);
  --text-muted: var(--color-text-muted);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-arabic);
  background-color: var(--color-bg);
  color: var(--color-text-main);
  direction: rtl;
  text-align: right;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background-color: var(--color-navy);
  color: #ffffff;
  padding: 1.25rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-md);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-icon {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: white;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(2, 132, 199, 0.4);
}

.title-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.title-row h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.subtitle {
  font-size: 0.875rem;
  color: #94a3b8;
  margin-top: 0.2rem;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-version {
  background-color: rgba(255, 255, 255, 0.12);
  color: #e2e8f0;
}

.badge-geo {
  background-color: rgba(2, 132, 199, 0.3);
  color: #38bdf8;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.badge-success {
  background-color: var(--color-success-bg);
  color: #065f46;
  border: 1px solid #a7f3d0;
}

.badge-processing {
  background-color: var(--color-primary-light);
  color: var(--color-primary-hover);
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  color: #cbd5e1;
}

.indicator-dot {
  width: 8px;
  height: 8px;
  background-color: #10b981;
  border-radius: 50%;
  box-shadow: 0 0 8px #10b981;
}

/* Main Layout */
.app-main {
  flex: 1;
  padding: 2rem;
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

.grid-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  align-items: start;
}

@media (max-width: 1024px) {
  .grid-layout {
    grid-template-columns: 1fr;
  }
}

/* Cards */
.card {
  background-color: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: 1.5rem;
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.85rem;
  margin-bottom: 1.25rem;
}

.card-header h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--color-navy);
}

.card-hint {
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

/* Upload Drop Zone */
.drop-zone {
  border: 2px dashed var(--color-border-dark);
  border-radius: var(--radius-md);
  padding: 2.5rem 1.5rem;
  text-align: center;
  background-color: #fafbfc;
  cursor: pointer;
  transition: all 0.2s ease;
}

.drop-zone:hover, .drop-zone.dragover {
  border-color: var(--color-primary);
  background-color: var(--color-primary-light);
}

.drop-zone-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.upload-icon {
  color: var(--color-primary);
  background: white;
  padding: 0.75rem;
  border-radius: 50%;
  box-shadow: var(--shadow-sm);
}

.drop-prompt strong {
  display: block;
  font-size: 1.1rem;
  color: var(--color-navy);
}

.drop-prompt span {
  font-size: 0.9rem;
  color: var(--color-text-muted);
}

.btn-link {
  background: none;
  border: none;
  color: var(--color-primary);
  font-weight: 700;
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  text-decoration: underline;
}

.file-limits {
  font-size: 0.75rem;
  color: var(--color-text-dim);
}

.hidden-input {
  display: none;
}

/* Selected Files List */
.selected-files-wrapper {
  margin-top: 1.25rem;
  background-color: var(--color-surface-hover);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.file-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
}

.file-list-header h3 {
  font-size: 0.9rem;
  font-weight: 700;
}

.btn-text-danger {
  background: none;
  border: none;
  color: var(--color-danger);
  font-size: 0.8rem;
  cursor: pointer;
  font-family: inherit;
}

.btn-text-danger:hover {
  text-decoration: underline;
}

.file-list {
  list-style: none;
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.file-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background-color: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
}

.file-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--font-mono);
  direction: ltr;
  text-align: left;
}

.file-size {
  color: var(--color-text-muted);
  font-size: 0.75rem;
}

.btn-remove-file {
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
}

.btn-remove-file:hover {
  color: var(--color-danger);
  background-color: var(--color-danger-bg);
}

/* Settings Card */
.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-label {
  font-size: 0.95rem;
  color: var(--color-navy);
}

.form-select {
  padding: 0.65rem 0.85rem;
  border: 1px solid var(--color-border-dark);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.9rem;
  background-color: white;
  color: var(--color-text-main);
  outline: none;
}

.form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px var(--color-primary-light);
}

.radio-group {
  display: flex;
  gap: 1.5rem;
  background-color: var(--color-surface-hover);
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9rem;
}

.dim {
  color: var(--color-text-muted);
  font-size: 0.8rem;
}

.field-hint {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

/* Action Button */
.action-footer {
  margin-top: 1.5rem;
  border-top: 1px solid var(--color-border);
  padding-top: 1.25rem;
}

.btn-primary {
  width: 100%;
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
  color: white;
  border: none;
  border-radius: var(--radius-md);
  padding: 0.85rem 1.5rem;
  font-size: 1.05rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  box-shadow: 0 2px 4px rgba(2, 132, 199, 0.25);
  transition: all 0.15s ease;
}

.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 10px rgba(2, 132, 199, 0.35);
  transform: translateY(-1px);
}

.btn-primary:disabled {
  background: #cbd5e1;
  cursor: not-allowed;
  box-shadow: none;
}

/* Progress Card */
.progress-track {
  height: 8px;
  background-color: var(--color-border);
  border-radius: 4px;
  overflow: hidden;
  margin: 1rem 0;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), #38bdf8);
  transition: width 0.3s ease;
}

.stepper {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.step.active {
  color: var(--color-primary);
  font-weight: 700;
}

.step.done {
  color: var(--color-success);
}

/* Alerts */
.alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

.alert-danger {
  background-color: var(--color-danger-bg);
  border: 1px solid #fecaca;
  color: #991b1b;
}

.alert-warning {
  background-color: var(--color-warning-bg);
  border: 1px solid #fed7aa;
  color: #9a3412;
}

.alert-icon {
  flex-shrink: 0;
  margin-top: 2px;
}

.alert-body ul {
  margin-right: 1.25rem;
  margin-top: 0.35rem;
}

/* Empty Card */
.empty-card {
  text-align: center;
  padding: 3.5rem 2rem;
  color: var(--color-text-muted);
}

.empty-icon {
  color: var(--color-border-dark);
  margin-bottom: 1rem;
}

.empty-card h3 {
  color: var(--color-navy);
  margin-bottom: 0.5rem;
}

.empty-card p {
  font-size: 0.9rem;
  max-width: 440px;
  margin: 0 auto;
}

/* Results & Metrics */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 640px) {
  .metrics-grid {
    grid-template-columns: 1fr;
  }
}

.metric-box {
  background-color: var(--color-surface-hover);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.metric-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  font-weight: 600;
}

.metric-val {
  font-size: 1.35rem;
  font-weight: 800;
  font-family: var(--font-mono);
  color: var(--color-navy);
}

.metric-val-sm {
  font-size: 1rem;
  font-weight: 700;
  font-family: var(--font-mono);
  color: var(--color-navy);
}

.metric-sub {
  font-size: 0.75rem;
}

.text-success { color: var(--color-success); }
.text-muted { color: var(--color-text-muted); }

/* Downloads Section */
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-navy);
  margin-bottom: 0.85rem;
}

.download-buttons-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

@media (max-width: 640px) {
  .download-buttons-grid {
    grid-template-columns: 1fr;
  }
}

.btn-download {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background-color: white;
  border: 1px solid var(--color-border-dark);
  border-radius: var(--radius-sm);
  padding: 0.65rem 0.85rem;
  color: var(--color-navy);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.15s ease;
}

.btn-download:hover {
  border-color: var(--color-primary);
  background-color: var(--color-primary-light);
  color: var(--color-primary-hover);
}

.btn-download-primary {
  grid-column: 1 / -1;
  background: linear-gradient(135deg, #059669, #10b981);
  color: white;
  border: none;
  justify-content: center;
  padding: 0.85rem 1rem;
  font-size: 0.95rem;
  box-shadow: 0 2px 4px rgba(16, 185, 129, 0.2);
}

.btn-download-primary:hover {
  background: linear-gradient(135deg, #047857, #059669);
  color: white;
}

/* Diagnostics Table */
.table-responsive {
  overflow-x: auto;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.diag-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  text-align: right;
}

.diag-table th {
  background-color: var(--color-surface-hover);
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  font-weight: 700;
  color: var(--color-navy);
}

.diag-table td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
}

.diag-table tr:last-child td {
  border-bottom: none;
}

/* Footer */
.app-footer {
  background-color: white;
  border-top: 1px solid var(--color-border);
  padding: 1rem 2rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--color-text-muted);
}

.footer-meta {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.hidden {
  display: none !important;
}
