/* ============================================
   Camera Project Tracker - Main Stylesheet
   Arabic RTL Layout
   ============================================ */

@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;600;700;900&display=swap');

:root {
  --primary: #1a3a5c;
  --primary-light: #2563a8;
  --primary-dark: #0f2540;
  --accent: #0ea5e9;
  --success: #27ae60;
  --success-light: #d4edda;
  --warning: #f39c12;
  --warning-light: #fff3cd;
  --danger: #e74c3c;
  --danger-light: #f8d7da;
  --bg: #f0f4f9;
  --card-bg: #ffffff;
  --text: #1e293b;
  --text-muted: #64748b;
  --border: #e2e8f0;
  --border-radius: 12px;
  --shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --navbar-h: 70px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: 'Cairo', sans-serif;
  background: var(--bg);
  color: var(--text);
  direction: rtl;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* NAVBAR */
.navbar {
  background: var(--primary-dark);
  color: white;
  height: var(--navbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.navbar-brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.1rem; }
.navbar-menu { display: flex; gap: 10px; align-items: center; }

.nav-link {
  color: white;
  text-decoration: none;
  font-size: 0.85rem;
  padding: 8px 12px;
  border-radius: 8px;
  transition: var(--transition);
}
.nav-link:hover { background: rgba(255,255,255,0.1); }
.nav-add { background: var(--success); }
.nav-logout { background: rgba(231, 76, 60, 0.3); }

/* CONTAINER */
.page-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
  width: 100%;
}

/* STATS */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-bottom: 25px;
}
.stat-card {
  background: white;
  padding: 20px;
  border-radius: var(--border-radius);
  display: flex;
  align-items: center;
  gap: 15px;
  box-shadow: var(--shadow);
  border-right: 5px solid var(--primary);
}
.stat-number { font-size: 1.8rem; font-weight: 900; color: var(--primary); display: block; line-height: 1; }
.stat-label { font-size: 0.85rem; color: var(--text-muted); }

/* TOOLBAR */
.toolbar {
  background: white;
  padding: 15px;
  border-radius: var(--border-radius);
  margin-bottom: 20px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 15px;
}
.search-form { flex: 1; display: flex; gap: 10px; flex-wrap: wrap; }
.search-input { flex: 1; min-width: 200px; padding: 10px; border: 1px solid var(--border); border-radius: 8px; }

/* BRANCH LIST - THE CORE OF RESPONSIVE DESIGN */
.branches-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.branch-item {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  border-right: 6px solid var(--primary);
  transition: var(--transition);
}
.branch-item:hover { transform: translateY(-3px); box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); }

.branch-header {
  padding: 15px 20px;
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}
.branch-name { font-size: 1.1rem; font-weight: 700; color: var(--primary); }
.branch-info-badges { display: flex; gap: 8px; align-items: center; }
.badge { padding: 4px 10px; border-radius: 20px; font-size: 0.75rem; font-weight: 700; }

.branch-content {
  padding: 20px;
  display: grid;
  grid-template-columns: 1fr 2fr;
  gap: 20px;
}

@media (max-width: 768px) {
  .branch-content { grid-template-columns: 1fr; }
  .navbar-brand span:not(.nav-icon) { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

.cam-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
.ip-tag {
  background: #f1f5f9;
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 0.85rem;
  font-family: monospace;
  display: flex;
  align-items: center;
  gap: 10px;
  position: relative;
}
.ip-broken { background: #fee2e2 !important; border-color: #fca5a5 !important; color: #b91c1c !important; }

.btn-issue { background: none; border: none; cursor: pointer; font-size: 1.1rem; padding: 2px; }

/* MODALS */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}
.modal-content {
  background: white;
  width: 100%;
  max-width: 500px;
  border-radius: 15px;
  overflow: hidden;
}
.modal-header { padding: 15px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; }
.modal-footer { padding: 15px 20px; background: #f8fafc; display: flex; justify-content: flex-end; gap: 10px; }

/* BUTTONS */
.btn { padding: 10px 20px; border-radius: 8px; font-weight: 700; border: none; cursor: pointer; font-size: 0.9rem; text-decoration: none; display: inline-flex; align-items: center; gap: 8px; }
.btn-primary { background: var(--primary); color: white; }
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-edit { background: #e2e8f0; color: var(--text); }

/* UTILS */
.status-mktml { border-right-color: var(--success); }
.status-tanfiz { border-right-color: var(--warning); }
.status-mutawaqif { border-right-color: var(--danger); }

.badge-mktml { background: var(--success-light); color: #155724; }
.badge-tanfiz { background: var(--warning-light); color: #856404; }
.badge-mutawaqif { background: var(--danger-light); color: #721c24; }

.form-input { width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: 8px; font-family: inherit; }
.form-group { margin-bottom: 15px; }
.form-label { display: block; font-weight: 700; margin-bottom: 5px; font-size: 0.9rem; }

.alert { padding: 15px; border-radius: 8px; margin-bottom: 20px; font-weight: 700; }
.alert-error { background: var(--danger-light); color: var(--danger); }
.alert-success { background: var(--success-light); color: var(--success); }
