/* ===== CSS Variables ===== */
:root {
  --bg: #f0f2f5;
  --surface: #ffffff;
  --primary: #1a73e8;
  --primary-dark: #1557b0;
  --success: #2e7d32;
  --danger: #c00000;
  --warning: #e65100;
  --text: #1f1f1f;
  --text-secondary: #5f6368;
  --border: #dadce0;
  --shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --shadow-lg: 0 4px 16px rgba(0,0,0,.12);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: .2s ease;
}

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

body {
  font-family: 'Segoe UI', 'Inter', -apple-system, BlinkMacSystemFont, 'Noto Sans Arabic', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.5;
}

/* ===== RTL Support ===== */
[dir="rtl"] body { font-family: 'Noto Sans Arabic', 'Segoe UI', 'Inter', sans-serif; }
[dir="rtl"] .stat-icon { margin-right: 0; margin-left: 12px; }
[dir="rtl"] .nav-actions { margin-left: 0; margin-right: auto; }
[dir="rtl"] .upload-zone { text-align: right; }

/* ===== Utility ===== */
.hidden { display: none !important; }

/* ===== Login Screen ===== */
.login-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100dvh;
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 40px 32px;
  width: 100%;
  max-width: 400px;
}

.login-card h1 {
  font-size: 24px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 8px;
  color: var(--primary);
}

.login-card .subtitle {
  text-align: center;
  color: var(--text-secondary);
  margin-bottom: 28px;
  font-size: 14px;
}

.form-group {
  margin-bottom: 16px;
}

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

.form-group input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  transition: border var(--transition);
  outline: none;
}

.form-group input:focus {
  border-color: var(--primary);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: #fff;
  width: 100%;
  padding: 12px;
  font-size: 15px;
}
.btn-primary:hover { background: var(--primary-dark); }
.btn-primary:disabled { opacity: .6; cursor: not-allowed; }

.btn-sm {
  padding: 6px 14px;
  font-size: 13px;
}

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

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { opacity: .9; }

.btn-danger { background: var(--danger); color: #fff; }

.error-msg {
  background: #fce4ec;
  color: var(--danger);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
  text-align: center;
}

/* ===== Top Nav ===== */
.topnav {
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 0 24px;
  height: 56px;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topnav .brand {
  font-size: 17px;
  font-weight: 600;
  color: var(--primary);
  white-space: nowrap;
}

.nav-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
}

.lang-toggle {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 13px;
  cursor: pointer;
  font-weight: 500;
}

.user-badge {
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--bg);
  padding: 4px 12px;
  border-radius: 20px;
}

/* ===== Main Layout ===== */
.main {
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px;
}

/* ===== Stats Row ===== */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 20px;
  display: flex;
  align-items: center;
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-right: 12px;
  flex-shrink: 0;
}

.stat-icon.blue { background: #e3f2fd; color: var(--primary); }
.stat-icon.green { background: #e8f5e9; color: var(--success); }
.stat-icon.red { background: #fce4ec; color: var(--danger); }
.stat-icon.orange { background: #fff3e0; color: var(--warning); }

.stat-info h3 {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.2;
}

.stat-info p {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* ===== Location Banner ===== */
.location-banner {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  text-align: center;
  margin-bottom: 24px;
}

.location-banner h2 {
  font-size: 18px;
  margin-bottom: 8px;
}

.location-banner p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 16px;
}

.site-name {
  font-size: 20px;
  font-weight: 600;
  color: var(--primary);
  margin: 12px 0 4px;
}

.site-coords {
  font-size: 12px;
  color: var(--text-secondary);
}

.spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin: 12px 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Section Cards ===== */
.section {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
  overflow: hidden;
}

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

.section-header h2 {
  font-size: 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}

.section-header .count {
  font-size: 12px;
  background: var(--bg);
  color: var(--text-secondary);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
}

/* ===== Asset Table ===== */
.table-wrap {
  overflow-x: auto;
}

.asset-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.asset-table th {
  background: var(--bg);
  padding: 10px 14px;
  text-align: start;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .5px;
  white-space: nowrap;
}

.asset-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f3f4;
  vertical-align: middle;
}

.asset-table tr:hover { background: #f8f9fa; }

.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-verified { background: #e8f5e9; color: var(--success); }
.badge-pending { background: #fff3e0; color: var(--warning); }
.badge-open { background: #fce4ec; color: var(--danger); }
.badge-resolved { background: #e8f5e9; color: var(--success); }

/* ===== Upload Zone ===== */
.upload-section {
  padding: 20px;
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
  position: relative;
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--primary);
  background: #e8f0fe;
}

.upload-zone .icon {
  font-size: 40px;
  margin-bottom: 8px;
}

.upload-zone p {
  color: var(--text-secondary);
  font-size: 14px;
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

/* ===== Upload Results ===== */
.upload-results {
  padding: 0 20px 20px;
}

.result-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  font-size: 13px;
}

.result-item.verified { background: #e8f5e9; }
.result-item.error { background: #fce4ec; }
.result-item.warning { background: #fff3e0; }

.result-item .icon { font-size: 18px; }
.result-item .detail { flex: 1; }
.result-item .detail strong { display: block; }
.result-item .detail small { color: var(--text-secondary); }

/* ===== Observations List ===== */
.obs-list {
  padding: 0;
  list-style: none;
}

.obs-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid #f1f3f4;
}

.obs-item:last-child { border-bottom: none; }

.obs-code {
  font-weight: 600;
  font-size: 13px;
  color: var(--primary);
  white-space: nowrap;
}

.obs-desc {
  flex: 1;
  font-size: 13px;
}

.obs-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* ===== Manual Verify Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 420px;
  padding: 28px;
}

.modal h3 {
  font-size: 18px;
  margin-bottom: 16px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 20px;
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

[dir="rtl"] .toast-container { right: auto; left: 20px; }

.toast {
  background: #323232;
  color: #fff;
  padding: 12px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  animation: slideUp .3s ease;
  max-width: 360px;
}

.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

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

/* ===== Responsive ===== */
@media (max-width: 640px) {
  .topnav { padding: 0 14px; }
  .main { padding: 14px; }
  .stats-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px; }
  .stat-info h3 { font-size: 20px; }
  .asset-table th, .asset-table td { padding: 8px 10px; }
  .section-header { padding: 12px 14px; }
  .upload-section { padding: 14px; }
  .obs-item { padding: 12px 14px; }
}

/* ===== Progress bar for upload ===== */
.progress-bar {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin: 12px 0;
}

.progress-bar .fill {
  height: 100%;
  background: var(--primary);
  transition: width .3s ease;
}

/* ===== Setup password screen ===== */
.setup-card {
  background: #fff8e1;
  border: 1px solid #ffcc02;
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 16px;
  font-size: 13px;
  text-align: center;
}
