/* =====================================================
   مطاعم أبوزيد — Department Pages Styles
   dept-pages.css
   ===================================================== */

/* ── Dept Wrapper (الحاوية الخارجية لكل قسم) ── */
.dept-wrapper {
  width: 100%;
  max-width: 100%;
  display: block;
  box-sizing: border-box;
  min-width: 0;
}

/* ── Dept Pages outside <main> need page-content padding/layout ── */
#page-dept-operations,
#page-dept-procurement,
#page-dept-quality,
#page-dept-it,
#page-dept-maintenance,
#page-dept-franchise,
#page-dept-bizdev {
  padding: 24px 28px;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

/* All dept pages get RTL + full width by default */
[id^="page-dept-"] {
  direction: rtl;
  text-align: right;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 0;
}

/* ── Page Container ── */
.dept-page {
  width: 100%;
  max-width: 100%;
  display: block;
  text-align: right;
  direction: rtl;
  animation: deptFadeIn 0.3s ease;
  box-sizing: border-box;
  min-width: 0;
}
@keyframes deptFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ── Department Header ── */
.dept-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 14px;
  margin-bottom: 24px;
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  text-align: right;
}
.dept-header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
}
.dept-icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}
.dept-title h2 {
  font-size: 1.3rem; font-weight: 800;
  color: #e8edf5;
  margin-bottom: 3px;
}
.dept-title p {
  font-size: 0.8rem;
  color: #7a90a8;
}
.dept-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.dept-period-badge {
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 0.78rem;
  color: #7a90a8;
  display: flex; align-items: center; gap: 6px;
}
.dept-period-badge i { color: #1eb8d8; }

/* ── Summary Strip ── */
.dept-summary-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
  text-align: center;
}
.summary-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px;
  padding: 14px 16px;
  text-align: center;
  transition: all 0.2s;
}
.summary-card:hover {
  border-color: rgba(30,184,216,0.3);
  background: rgba(30,184,216,0.05);
}
.summary-card .sc-value {
  font-size: 1.6rem; font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
}
.summary-card .sc-label {
  font-size: 0.72rem;
  color: #7a90a8;
  font-weight: 500;
}
.sc-green  .sc-value { color: #22c55e; }
.sc-yellow .sc-value { color: #eab308; }
.sc-red    .sc-value { color: #ef4444; }
.sc-teal   .sc-value { color: #1eb8d8; }
.sc-gold   .sc-value { color: #D4AF37; }

/* ── Filter Bar ── */
.dept-filter-bar {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
  direction: rtl;
  text-align: right;
}
.filter-search {
  flex: 1; min-width: 180px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 9px 14px 9px 36px;
  color: #e8edf5;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
  position: relative;
}
.filter-search:focus { border-color: #1eb8d8; }
.filter-search-wrap {
  flex: 1; min-width: 180px;
  position: relative;
}
.filter-search-wrap i {
  position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%);
  color: #7a90a8; font-size: 0.8rem;
  pointer-events: none;
}
.filter-btn {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 8px 14px;
  color: #7a90a8;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
  white-space: nowrap;
}
.filter-btn:hover, .filter-btn.active {
  border-color: #1eb8d8;
  color: #1eb8d8;
  background: rgba(30,184,216,0.08);
}
.filter-btn.active-green  { border-color: #22c55e; color: #22c55e; background: rgba(34,197,94,0.08); }
.filter-btn.active-yellow { border-color: #eab308; color: #eab308; background: rgba(234,179,8,0.08); }
.filter-btn.active-red    { border-color: #ef4444; color: #ef4444; background: rgba(239,68,68,0.08); }

/* ── KPI Cards Grid ── */
.kpi-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 28px;
  direction: rtl;
  width: 100%;
  box-sizing: border-box;
  align-items: start;
}

/* ── Dept KPI Card (renamed to avoid conflict with style.css .kpi-card) ── */
.dept-kpi-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 14px;
  padding: 16px;
  cursor: pointer;
  transition: all 0.22s;
  position: relative;
  overflow: hidden;
  text-align: right;
  direction: rtl;
  box-sizing: border-box;
}
.dept-kpi-card::before {
  content: '';
  position: absolute; top: 0; right: 0;
  width: 4px; height: 100%;
  border-radius: 0 14px 14px 0;
  background: var(--kpi-color, #7a90a8);
  opacity: 0.7;
  left: auto;
}
.dept-kpi-card:hover {
  transform: translateY(-3px);
  border-color: rgba(30,184,216,0.3);
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}
.dept-kpi-card.status-green  { --kpi-color: #22c55e; }
.dept-kpi-card.status-yellow { --kpi-color: #eab308; }
.dept-kpi-card.status-red    { --kpi-color: #ef4444; }
.dept-kpi-card.status-neutral{ --kpi-color: #7a90a8; }

.dept-kpi-card .kpi-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.dept-kpi-card .kpi-card-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #e2e8f0;
  line-height: 1.4;
  flex: 1;
}
.kpi-status-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 99px;
  font-size: 0.7rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
}
.badge-green  { background: rgba(34,197,94,0.15);  color: #22c55e; }
.badge-yellow { background: rgba(234,179,8,0.15);  color: #eab308; }
.badge-red    { background: rgba(239,68,68,0.15);  color: #ef4444; }
.badge-neutral{ background: rgba(122,144,168,0.15);color: #7a90a8; }

.kpi-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 12px;
}
.kpi-metric {
  background: rgba(255,255,255,0.03);
  border-radius: 8px;
  padding: 8px 10px;
}
.kpi-metric-label {
  font-size: 0.68rem;
  color: #7a90a8;
  margin-bottom: 3px;
}
.kpi-metric-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: #e8edf5;
}
.kpi-metric-value.highlight { color: #1eb8d8; }

/* ── Progress Bar ── */
.kpi-progress-wrap {
  margin-bottom: 10px;
}
.kpi-progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.7rem;
  color: #7a90a8;
  margin-bottom: 4px;
}
.kpi-progress-bar {
  height: 5px;
  background: rgba(255,255,255,0.07);
  border-radius: 99px;
  overflow: hidden;
}
.kpi-progress-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.6s ease;
  background: var(--kpi-color, #7a90a8);
}

.dept-kpi-card .kpi-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.7rem;
  color: #7a90a8;
}
.kpi-owner {
  display: flex; align-items: center; gap: 4px;
}
.kpi-detail-hint {
  color: #1eb8d8;
  font-size: 0.68rem;
  display: flex; align-items: center; gap: 3px;
}

/* ── KPI Table ── */
.kpi-table-wrap {
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 14px;
  overflow: hidden;
  margin-bottom: 24px;
  direction: rtl;
}
.kpi-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.82rem;
  direction: rtl;
}
.kpi-table thead tr {
  background: rgba(255,255,255,0.04);
}
.kpi-table th {
  padding: 12px 14px;
  text-align: right;
  font-weight: 700;
  color: #7a90a8;
  font-size: 0.75rem;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  white-space: nowrap;
}
.kpi-table td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  color: #c8d4e0;
  vertical-align: middle;
  text-align: right;
}
.kpi-table tr:last-child td { border-bottom: none; }
.kpi-table tbody tr {
  cursor: pointer;
  transition: background 0.15s;
}
.kpi-table tbody tr:hover {
  background: rgba(30,184,216,0.05);
}
.kpi-table .td-name {
  font-weight: 600;
  color: #e8edf5;
  max-width: 220px;
}
.kpi-table .direction-badge {
  font-size: 0.65rem;
  padding: 2px 7px;
  border-radius: 99px;
}
.dir-up   { background: rgba(34,197,94,0.12); color: #22c55e; }
.dir-down { background: rgba(239,68,68,0.12); color: #ef4444; }

/* ── Section Divider ── */
.section-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0 16px;
}
.section-divider-line {
  flex: 1;
  height: 1px;
  background: rgba(255,255,255,0.07);
}
.section-divider-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: #7a90a8;
  white-space: nowrap;
  padding: 4px 12px;
  background: rgba(255,255,255,0.04);
  border-radius: 99px;
  border: 1px solid rgba(255,255,255,0.07);
}

/* ── Empty state ── */
.dept-empty {
  text-align: center;
  padding: 60px 20px;
  color: #7a90a8;
}
.dept-empty i { font-size: 2rem; margin-bottom: 12px; opacity: 0.4; }
.dept-empty p { font-size: 0.9rem; }
.dept-loading {
  text-align: center;
  padding: 60px 20px;
  color: #7a90a8;
}
.dept-loading .spinner-small {
  width: 36px; height: 36px;
  border: 3px solid rgba(30,184,216,0.2);
  border-top-color: #1eb8d8;
  border-radius: 50%;
  animation: spin2 0.8s linear infinite;
  margin: 0 auto 12px;
}
@keyframes spin2 { to { transform: rotate(360deg); } }

/* ── KPI Detail Modal ── */
.kpi-modal-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 9000;
  align-items: flex-start;
  justify-content: flex-end;
  padding: 0;
}
.kpi-modal-overlay.open {
  display: flex;
  animation: overlayFade 0.2s ease;
}
@keyframes overlayFade {
  from { opacity: 0; } to { opacity: 1; }
}

.kpi-modal-drawer {
  background: #0d1e35;
  border-right: none;
  border-left: 1px solid rgba(255,255,255,0.08);
  width: 480px;
  max-width: 100vw;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  animation: drawerSlide 0.3s ease;
}
@keyframes drawerSlide {
  from { transform: translateX(-40px); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}

.modal-close-btn {
  position: absolute;
  top: 14px; right: 14px;
  width: 34px; height: 34px;
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  color: #7a90a8;
  font-size: 0.9rem;
  transition: all 0.2s;
}
.modal-close-btn:hover {
  background: rgba(239,68,68,0.15);
  color: #ef4444;
  border-color: #ef4444;
}

.modal-header {
  padding: 24px 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
  position: relative;
}
.modal-status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}
.modal-kpi-name {
  font-size: 1.1rem;
  font-weight: 800;
  color: #e8edf5;
  line-height: 1.4;
  padding-left: 44px; /* room for close button */
}
.modal-kpi-goal {
  font-size: 0.78rem;
  color: #7a90a8;
  margin-top: 6px;
  line-height: 1.5;
}

.modal-metrics-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.modal-metric-box {
  background: rgba(255,255,255,0.04);
  border-radius: 10px;
  padding: 12px 10px;
  text-align: center;
}
.modal-metric-label {
  font-size: 0.67rem;
  color: #7a90a8;
  margin-bottom: 5px;
}
.modal-metric-value {
  font-size: 1.1rem;
  font-weight: 800;
}
.mv-actual  { color: #1eb8d8; }
.mv-target  { color: #D4AF37; }
.mv-pct     { color: #22c55e; }
.mv-pct.red { color: #ef4444; }
.mv-pct.yellow { color: #eab308; }

.modal-progress-section {
  padding: 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.modal-progress-track {
  height: 8px;
  background: rgba(255,255,255,0.07);
  border-radius: 99px;
  overflow: hidden;
  margin-top: 6px;
}
.modal-progress-fill {
  height: 100%;
  border-radius: 99px;
  transition: width 0.8s ease;
}
.fill-green  { background: linear-gradient(90deg, #16a34a, #22c55e); }
.fill-yellow { background: linear-gradient(90deg, #b45309, #eab308); }
.fill-red    { background: linear-gradient(90deg, #b91c1c, #ef4444); }
.fill-neutral{ background: linear-gradient(90deg, #374151, #7a90a8); }

.modal-fields {
  padding: 16px 20px;
  flex: 1;
}
.modal-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  color: #7a90a8;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}
.modal-field-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.modal-field {
  background: rgba(255,255,255,0.03);
  border-radius: 8px;
  padding: 10px 12px;
}
.modal-field.full-width {
  grid-column: 1 / -1;
}
.modal-field-label {
  font-size: 0.68rem;
  color: #7a90a8;
  margin-bottom: 4px;
}
.modal-field-value {
  font-size: 0.82rem;
  color: #e8edf5;
  font-weight: 500;
  line-height: 1.5;
}
.modal-field-value.empty {
  color: #3d5070;
  font-style: italic;
}

/* ── YTD section ── */
.ytd-row {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  padding: 14px 20px;
  background: rgba(255,255,255,0.02);
  border-top: 1px solid rgba(255,255,255,0.06);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.ytd-box {
  text-align: center;
}
.ytd-label {
  font-size: 0.65rem;
  color: #7a90a8;
  margin-bottom: 4px;
}
.ytd-value {
  font-size: 0.95rem;
  font-weight: 700;
  color: #e8edf5;
}

/* ── Notes area ── */
.modal-notes {
  padding: 14px 20px;
  background: rgba(234,179,8,0.04);
  border-top: 1px solid rgba(255,255,255,0.06);
  margin: 0 0 0;
}
.modal-notes-label {
  font-size: 0.7rem;
  color: #D4AF37;
  font-weight: 700;
  margin-bottom: 6px;
  display: flex; align-items: center; gap: 5px;
}
.modal-notes-text {
  font-size: 0.82rem;
  color: #a0b0c4;
  line-height: 1.6;
}

/* ── Responsive ── */
@media (max-width: 1100px) {
  .kpi-cards-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 680px) {
  .kpi-cards-grid { grid-template-columns: minmax(0, 1fr); }
  .dept-summary-strip { grid-template-columns: repeat(3, 1fr); }
  .kpi-modal-drawer { width: 100vw; }
  .modal-metrics-row { grid-template-columns: repeat(3, 1fr); }
  .kpi-table { font-size: 0.75rem; }
  .kpi-table th, .kpi-table td { padding: 8px 10px; }
}
