@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600&display=swap');

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

:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --border: rgba(0,0,0,0.09);
  --border-md: rgba(0,0,0,0.15);
  --text: #1a1a18;
  --text-secondary: #6b6b67;
  --text-tertiary: #9a9a96;
  --accent: #1a1a18;
  --radius: 12px;
  --radius-sm: 8px;
  --sidebar-w: 220px;
  --shadow: 0 1px 3px rgba(0,0,0,0.07), 0 1px 2px rgba(0,0,0,0.04);
}

body {
  font-family: 'IBM Plex Sans Arabic', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
  line-height: 1.6;
}

/* ─── SIDEBAR ─── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--surface);
  border-left: 0.5px solid var(--border);
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
  position: fixed;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 100;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 17px;
  font-weight: 600;
  padding: 0 0.5rem;
}
.logo-icon { font-size: 22px; }

nav { display: flex; flex-direction: column; gap: 2px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  text-decoration: none;
  transition: background 0.15s, color 0.15s;
}
.nav-item:hover { background: var(--bg); color: var(--text); }
.nav-item.active { background: var(--accent); color: #fff; }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

/* ─── MAIN ─── */
.main {
  flex: 1;
  margin-right: var(--sidebar-w);
  padding: 2rem;
  max-width: calc(100vw - var(--sidebar-w));
  overflow-x: hidden;
}

.page { display: none; }
.page.active { display: block; }

.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}
.page-header h1 { font-size: 22px; font-weight: 600; }

/* ─── CARDS ─── */
.card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow);
}
.card-title { font-size: 15px; font-weight: 500; margin-bottom: 1rem; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; margin-bottom: 1.25rem; }

/* ─── STATS ─── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 1rem; margin-bottom: 1.25rem; }
.stat-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow);
}
.stat-label { font-size: 12px; color: var(--text-secondary); margin-bottom: 6px; }
.stat-value { font-size: 22px; font-weight: 600; }
.stat-sub { font-size: 12px; color: var(--text-tertiary); margin-top: 3px; }

/* ─── BAR CHART ─── */
.bar-row { margin-bottom: 14px; }
.bar-meta { display: flex; justify-content: space-between; font-size: 13px; margin-bottom: 4px; }
.bar-meta span:last-child { color: var(--text-secondary); }
.bar-track { background: var(--bg); border-radius: 4px; height: 6px; overflow: hidden; }
.bar-fill { height: 6px; border-radius: 4px; background: var(--accent); transition: width 0.4s; }

/* ─── FILTERS ─── */
.filters-bar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.filters-bar input[type="text"],
.filters-bar input[type="date"],
.filters-bar select {
  flex: 1;
  min-width: 130px;
  max-width: 220px;
  height: 38px;
  border: 0.5px solid var(--border-md);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font-size: 13px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  outline: none;
}
.filters-bar input[type="text"] { flex: 2; max-width: 300px; }
.filters-bar input:focus, .filters-bar select:focus { border-color: var(--accent); }

/* ─── SUMMARY BAR ─── */
.summary-bar {
  display: flex;
  gap: 1.5rem;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
  padding: 0 0.25rem;
}
.summary-bar strong { color: var(--text); }

/* ─── TABLE ─── */
.inv-table { width: 100%; border-collapse: collapse; }
.inv-table thead th {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: right;
  padding: 10px 16px;
  border-bottom: 0.5px solid var(--border);
  background: var(--bg);
}
.inv-table tbody td {
  padding: 12px 16px;
  border-bottom: 0.5px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
.inv-table tbody tr:last-child td { border-bottom: none; }
.inv-table tbody tr:hover { background: var(--bg); }

/* ─── BADGES ─── */
.badge {
  display: inline-block;
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 99px;
  font-weight: 500;
  white-space: nowrap;
}
.badge-ac    { background: #E6F1FB; color: #0C447C; }
.badge-paint { background: #FAEEDA; color: #633806; }
.badge-eng   { background: #EEEDFE; color: #3C3489; }
.badge-gen   { background: #F1EFE8; color: #444441; }
.badge-villa { background: #EAF3DE; color: #27500A; }
.badge-other { background: #FBEAF0; color: #72243E; }

/* ─── ACTIONS ─── */
.row-actions { display: flex; gap: 4px; justify-content: flex-end; }
.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 14px;
  color: var(--text-secondary);
  transition: background 0.15s;
}
.btn-icon:hover { background: var(--bg); color: var(--text); }
.btn-icon.del:hover { background: #FCEBEB; color: #A32D2D; }

/* ─── PROJECTS GRID ─── */
.projects-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 1rem; }
.project-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.project-card h3 { font-size: 15px; font-weight: 500; }
.project-meta { font-size: 12px; color: var(--text-secondary); }
.project-total { font-size: 18px; font-weight: 600; margin-top: 4px; }
.project-actions { display: flex; gap: 6px; margin-top: 8px; }

/* ─── FORM ─── */
.form-row { display: flex; gap: 12px; margin-bottom: 0; }
.form-row .form-group { flex: 1; }
.form-group { margin-bottom: 14px; }
.form-group label { font-size: 13px; color: var(--text-secondary); display: block; margin-bottom: 5px; }
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  height: 38px;
  border: 0.5px solid var(--border-md);
  border-radius: var(--radius-sm);
  padding: 0 12px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}
.form-group textarea { height: auto; padding: 10px 12px; resize: vertical; }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--accent); }

/* ─── BUTTONS ─── */
.btn-primary {
  height: 38px;
  padding: 0 20px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  font-weight: 500;
  transition: opacity 0.15s;
}
.btn-primary:hover { opacity: 0.85; }
.btn-ghost {
  height: 38px;
  padding: 0 16px;
  background: none;
  border: 0.5px solid var(--border-md);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
  color: var(--text-secondary);
  transition: background 0.15s;
}
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-danger {
  height: 38px;
  padding: 0 20px;
  background: #A32D2D;
  color: #fff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  cursor: pointer;
}

/* ─── ALERTS ─── */
.alert-success { background: #EAF3DE; color: #27500A; border-radius: var(--radius-sm); padding: 10px 16px; margin-bottom: 1rem; font-size: 14px; }
.alert-error { background: #FCEBEB; color: #A32D2D; border-radius: var(--radius-sm); padding: 10px 16px; margin-bottom: 1rem; font-size: 14px; }

/* ─── MODAL ─── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}
.modal {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.15);
}
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.25rem; font-size: 16px; font-weight: 500; }
.btn-close { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-secondary); line-height: 1; }

/* ─── EMPTY / LOADING ─── */
.empty { text-align: center; padding: 3rem; color: var(--text-tertiary); font-size: 14px; }
.loading { text-align: center; padding: 2rem; color: var(--text-tertiary); }

/* ─── DROP ZONE ─── */
.drop-zone {
  border: 1.5px dashed var(--border-md);
  border-radius: var(--radius);
  padding: 2rem;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  margin-bottom: 1rem;
}
.drop-zone:hover, .drop-zone.dragover { background: var(--bg); border-color: var(--accent); }
.drop-icon { font-size: 2rem; margin-bottom: 6px; }
.drop-text { font-size: 15px; font-weight: 500; margin-bottom: 4px; }
.drop-sub { font-size: 12px; color: var(--text-tertiary); }

/* ─── FILE QUEUE ─── */
.file-queue { display: flex; flex-direction: column; gap: 6px; max-height: 220px; overflow-y: auto; }
.file-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.file-item-icon { font-size: 18px; flex-shrink: 0; }
.file-item-name { flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-item-size { color: var(--text-tertiary); font-size: 11px; flex-shrink: 0; }
.file-item-remove { background: none; border: none; cursor: pointer; color: var(--text-tertiary); font-size: 16px; padding: 0 4px; flex-shrink: 0; }
.file-item-remove:hover { color: #A32D2D; }
.file-item.done { opacity: 0.5; }
.file-item.error { background: #FCEBEB; }

/* ─── ATTACHMENTS GRID ─── */
.att-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
}
.att-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: box-shadow 0.15s;
}
.att-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.att-thumb {
  width: 100%;
  height: 130px;
  object-fit: cover;
  display: block;
  background: var(--bg);
}
.att-thumb-pdf {
  width: 100%;
  height: 130px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #FCEBEB;
  font-size: 3rem;
}
.att-info { padding: 10px; }
.att-name { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px; }
.att-project { font-size: 11px; color: var(--text-secondary); margin-bottom: 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.att-actions { display: flex; gap: 4px; }
.att-actions a, .att-actions button {
  flex: 1;
  text-align: center;
  font-size: 11px;
  padding: 4px;
  border-radius: 6px;
  border: 0.5px solid var(--border-md);
  background: none;
  cursor: pointer;
  color: var(--text-secondary);
  text-decoration: none;
  display: block;
}
.att-actions a:hover { background: var(--bg); color: var(--text); }
.att-actions button:hover { background: #FCEBEB; color: #A32D2D; border-color: #F09595; }

/* ─── RESPONSIVE ─── */
@media (max-width: 900px) {
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .sidebar { width: 60px; padding: 1rem 0.5rem; }
  .sidebar .logo span:last-child, .nav-item span:last-child { display: none; }
  .main { margin-right: 60px; padding: 1rem; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}
