/* ============================================
   DARAH SUITES - Main Stylesheet
   ============================================ */

:root {
  --brand: #3D3531;
  --brand-light: #5A4F49;
  --brand-soft: #8B7E76;
  --bg: #FAFAF8;
  --bg-secondary: #F4F2EE;
  --bg-card: #FFFFFF;
  --bg-elevated: #FDFCFA;
  --border: #E8E4DD;
  --border-strong: #D4CEC4;
  --text-primary: #2C2622;
  --text-secondary: #6B6157;
  --text-muted: #9C9389;
  --accent: #B8956A;
  --accent-soft: #D4B896;
  --success: #6B8E6E;
  --danger: #B85C50;
  --warning: #C99A4F;
  --info: #5A8CB5;
  --shadow-sm: 0 1px 2px rgba(60, 50, 45, 0.05);
  --shadow: 0 4px 16px rgba(60, 50, 45, 0.06);
  --shadow-lg: 0 12px 40px rgba(60, 50, 45, 0.10);
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

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

html, body {
  font-family: 'Tajawal', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 15px;
  line-height: 1.6;
}

::selection { background: var(--brand); color: white; }

.hidden { display: none !important; }

/* ============ LOGIN ============ */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg) 0%, var(--bg-secondary) 100%);
  padding: 2rem;
}

.login-card {
  background: var(--bg-card);
  border-radius: 24px;
  padding: 3rem 2.5rem;
  max-width: 440px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  position: relative;
  overflow: hidden;
}

.login-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--brand), var(--accent));
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 2rem;
}

.logo-mark {
  width: 80px;
  height: 80px;
  background: var(--brand);
  color: white;
  border-radius: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.logo-mark svg { width: 48px; height: 48px; }

.name-ar {
  font-family: 'Amiri', serif;
  font-size: 2rem;
  font-weight: 700;
  color: var(--brand);
  letter-spacing: 2px;
}

.name-en {
  font-family: 'Cormorant Garamond', serif;
  font-size: 0.9rem;
  color: var(--text-muted);
  letter-spacing: 6px;
  text-transform: uppercase;
  margin-top: 4px;
}

.login-title {
  text-align: center;
  font-size: 1.05rem;
  color: var(--text-secondary);
  margin-bottom: 2rem;
}

.login-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 1.5rem;
}

/* ============ FORMS ============ */
.form-group { margin-bottom: 1.25rem; }
.form-label { display: block; font-size: 0.85rem; font-weight: 500; color: var(--text-secondary); margin-bottom: 0.5rem; }

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.95rem;
  background: var(--bg-elevated);
  color: var(--text-primary);
  transition: all 0.2s;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--brand);
  background: white;
  box-shadow: 0 0 0 3px rgba(61, 53, 49, 0.08);
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 600px) { .form-row { grid-template-columns: 1fr; } }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--brand); color: white; }
.btn-primary:hover { background: var(--text-primary); transform: translateY(-1px); box-shadow: var(--shadow); }

.btn-secondary { background: var(--bg-secondary); color: var(--brand); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }

.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }

.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--bg-secondary); color: var(--brand); }

.btn-block { width: 100%; }
.btn-sm { padding: 0.5rem 0.85rem; font-size: 0.8rem; }

.btn-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s;
  position: relative;
}
.btn-icon:hover { background: var(--bg-secondary); color: var(--brand); }

/* ============ ALERTS ============ */
.alert {
  padding: 0.85rem 1rem;
  border-radius: var(--radius);
  font-size: 0.9rem;
  margin-bottom: 1rem;
}
.alert-danger { background: rgba(184, 92, 80, 0.1); color: var(--danger); border: 1px solid rgba(184, 92, 80, 0.2); }
.alert-success { background: rgba(107, 142, 110, 0.1); color: var(--success); }
.alert-warning { background: rgba(201, 154, 79, 0.1); color: var(--warning); }
.alert-info { background: rgba(90, 140, 181, 0.1); color: var(--info); }

/* ============ LAYOUT ============ */
.app { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  background: var(--bg-card);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  right: 0; top: 0; bottom: 0;
  z-index: 50;
  transition: transform 0.3s;
}

.sidebar-header { padding: 1.5rem 1.25rem; border-bottom: 1px solid var(--border); }

.sidebar-logo { display: flex; align-items: center; gap: 0.75rem; }
.sidebar-logo .mark {
  width: 44px; height: 44px;
  background: var(--brand); color: white;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-logo .mark svg { width: 26px; height: 26px; }
.sidebar-logo .text .ar { font-family: 'Amiri', serif; font-size: 1.4rem; font-weight: 700; color: var(--brand); line-height: 1; }
.sidebar-logo .text .en { font-family: 'Cormorant Garamond', serif; font-size: 0.7rem; letter-spacing: 4px; color: var(--text-muted); text-transform: uppercase; margin-top: 4px; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 1rem 0.75rem; }

.nav-section { margin-bottom: 1.5rem; }
.nav-section-title {
  font-size: 0.7rem; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  padding: 0 0.75rem; margin-bottom: 0.5rem;
}

.nav-item {
  display: flex; align-items: center; gap: 0.85rem;
  padding: 0.7rem 0.85rem;
  border-radius: 10px;
  color: var(--text-secondary);
  font-size: 0.9rem; font-weight: 500;
  cursor: pointer;
  border: none; background: transparent;
  width: 100%; text-align: right;
  font-family: inherit;
  margin-bottom: 2px;
  transition: all 0.15s;
}
.nav-item:hover { background: var(--bg-secondary); color: var(--brand); }
.nav-item.active { background: var(--brand); color: white; }
.nav-item.active .nav-icon { color: white; }
.nav-icon { width: 20px; height: 20px; flex-shrink: 0; color: var(--text-muted); }
.nav-item:hover .nav-icon { color: var(--brand); }

.sidebar-footer { padding: 1rem; border-top: 1px solid var(--border); }

.user-card {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem;
  border-radius: 10px;
  background: var(--bg-secondary);
}
.user-avatar {
  width: 36px; height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), var(--brand-light));
  color: white;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; flex-shrink: 0;
}
.user-info { flex: 1; min-width: 0; }
.user-info .name { font-size: 0.85rem; font-weight: 600; color: var(--text-primary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.user-info .role { font-size: 0.75rem; color: var(--text-muted); }

/* ============ MAIN CONTENT ============ */
.main { flex: 1; margin-right: 260px; min-height: 100vh; }

.topbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 1rem 2rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  position: sticky; top: 0; z-index: 40;
}

.menu-toggle { display: none; background: none; border: none; width: 40px; height: 40px; border-radius: 10px; cursor: pointer; color: var(--text-primary); }

.page-breadcrumb { flex: 1; display: flex; flex-direction: column; }
.page-breadcrumb .label { font-size: 0.75rem; color: var(--text-muted); letter-spacing: 1px; text-transform: uppercase; }
.page-breadcrumb .title { font-family: 'Amiri', serif; font-size: 1.5rem; font-weight: 700; color: var(--brand); }

.topbar-actions { display: flex; gap: 0.5rem; }

.content { padding: 2rem; max-width: 1600px; }

/* ============ CARDS ============ */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.card-title { font-family: 'Amiri', serif; font-size: 1.2rem; font-weight: 700; color: var(--brand); }
.card-subtitle { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; }
.card-body { padding: 1.5rem; }

/* ============ STATS ============ */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  position: relative;
  transition: all 0.2s;
}
.stat-card:hover { border-color: var(--border-strong); transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-card .top { display: flex; justify-content: space-between; margin-bottom: 1rem; }
.stat-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  background: var(--bg-secondary);
  color: var(--brand);
  display: flex; align-items: center; justify-content: center;
}
.stat-icon svg { width: 22px; height: 22px; }

.stat-trend { font-size: 0.75rem; font-weight: 600; padding: 0.25rem 0.6rem; border-radius: 20px; }
.stat-trend.up { background: rgba(107, 142, 110, 0.1); color: var(--success); }
.stat-trend.down { background: rgba(184, 92, 80, 0.1); color: var(--danger); }
.stat-trend.neutral { background: var(--bg-secondary); color: var(--text-muted); }

.stat-label { font-size: 0.85rem; color: var(--text-secondary); margin-bottom: 0.4rem; }
.stat-value {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--brand);
  font-family: 'Cormorant Garamond', serif;
  letter-spacing: -0.5px;
}
.stat-value .currency { font-size: 0.9rem; color: var(--text-muted); font-weight: 500; font-family: 'Tajawal'; margin-right: 4px; }

.grid-2 { display: grid; grid-template-columns: 2fr 1fr; gap: 1.5rem; margin-bottom: 2rem; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1.5rem; margin-bottom: 2rem; }
@media (max-width: 1024px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }

/* ============ TABLE ============ */
.table-wrap { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; min-width: 600px; }
.table th {
  background: var(--bg-secondary);
  padding: 0.85rem 1rem;
  text-align: right;
  font-weight: 600;
  font-size: 0.8rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.table td { padding: 0.95rem 1rem; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.table tbody tr:hover { background: var(--bg-secondary); }
.table tbody tr:last-child td { border-bottom: none; }

.badge {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 0.25rem 0.7rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}
.badge-success { background: rgba(107, 142, 110, 0.1); color: var(--success); }
.badge-danger { background: rgba(184, 92, 80, 0.1); color: var(--danger); }
.badge-warning { background: rgba(201, 154, 79, 0.1); color: var(--warning); }
.badge-info { background: rgba(90, 140, 181, 0.1); color: var(--info); }
.badge-neutral { background: var(--bg-secondary); color: var(--text-secondary); }
.badge-brand { background: rgba(61, 53, 49, 0.08); color: var(--brand); }

/* ============ MODAL ============ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(44, 38, 34, 0.5);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 100;
  padding: 1rem;
  animation: fadeIn 0.2s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  max-width: 600px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: slideUp 0.3s;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header { padding: 1.5rem; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; }
.modal-title { font-family: 'Amiri', serif; font-size: 1.3rem; font-weight: 700; color: var(--brand); }
.modal-close {
  width: 36px; height: 36px;
  border-radius: 10px;
  border: none;
  background: var(--bg-secondary);
  cursor: pointer;
  color: var(--text-secondary);
}
.modal-body { padding: 1.5rem; }
.modal-footer { padding: 1rem 1.5rem; border-top: 1px solid var(--border); display: flex; gap: 0.75rem; }

/* ============ TOAST ============ */
.toast-container {
  position: fixed; bottom: 2rem; left: 2rem;
  z-index: 200;
  display: flex; flex-direction: column; gap: 0.5rem;
}
.toast {
  background: var(--brand); color: white;
  padding: 0.85rem 1.25rem;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem;
  animation: slideInLeft 0.3s, fadeOut 0.3s 2.7s;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
.toast.warning { background: var(--warning); }

@keyframes slideInLeft { from { transform: translateX(-20px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes fadeOut { to { opacity: 0; transform: translateX(-20px); } }

/* ============ LOADING ============ */
.loading { display: flex; justify-content: center; padding: 4rem; }
.spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--bg-secondary);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============ NOTIFICATIONS PANEL ============ */
.notif-panel {
  position: fixed;
  top: 70px; left: 2rem;
  width: 380px; max-height: 70vh;
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  border: 1px solid var(--border);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.notif-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.notif-header h3 { font-family: 'Amiri', serif; font-size: 1.1rem; color: var(--brand); }
.notif-header button { background: none; border: none; color: var(--accent); cursor: pointer; font-size: 0.85rem; }
.notif-body { overflow-y: auto; flex: 1; }
.notif-item {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
}
.notif-item:hover { background: var(--bg-secondary); }
.notif-item.unread { background: rgba(184, 149, 106, 0.05); border-right: 3px solid var(--accent); }
.notif-item .title { font-weight: 600; font-size: 0.9rem; margin-bottom: 4px; }
.notif-item .msg { font-size: 0.85rem; color: var(--text-secondary); }
.notif-item .time { font-size: 0.75rem; color: var(--text-muted); margin-top: 4px; }

.notif-badge {
  position: absolute;
  top: 4px; left: 4px;
  min-width: 18px; height: 18px;
  background: var(--danger);
  color: white;
  border-radius: 9px;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

/* ============ INSIGHTS ============ */
.insight-card {
  display: flex;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-radius: var(--radius);
  background: var(--bg-card);
  border: 1px solid var(--border);
  margin-bottom: 0.75rem;
}
.insight-card .icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.insight-card.severity-info .icon { background: rgba(90, 140, 181, 0.1); color: var(--info); }
.insight-card.severity-success .icon { background: rgba(107, 142, 110, 0.1); color: var(--success); }
.insight-card.severity-warning .icon { background: rgba(201, 154, 79, 0.1); color: var(--warning); }
.insight-card.severity-danger .icon { background: rgba(184, 92, 80, 0.1); color: var(--danger); }
.insight-card .content { flex: 1; }
.insight-card .title { font-weight: 600; margin-bottom: 4px; color: var(--text-primary); }
.insight-card .msg { font-size: 0.85rem; color: var(--text-secondary); }

/* ============ HEATMAP ============ */
.heatmap { display: grid; grid-template-columns: 40px repeat(7, 1fr); gap: 2px; }
.heatmap-cell {
  aspect-ratio: 1;
  background: var(--bg-secondary);
  border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem;
  color: var(--text-muted);
}
.heatmap-cell.hot-1 { background: rgba(184, 149, 106, 0.2); color: var(--brand); }
.heatmap-cell.hot-2 { background: rgba(184, 149, 106, 0.4); color: var(--brand); }
.heatmap-cell.hot-3 { background: rgba(184, 149, 106, 0.7); color: white; }
.heatmap-cell.hot-4 { background: var(--accent); color: white; font-weight: 700; }

/* ============ UTILITY ============ */
.flex { display: flex; }
.flex-1 { flex: 1; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.text-lg { font-size: 1.1rem; }
.font-bold { font-weight: 700; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.amount { font-family: 'Cormorant Garamond', serif; font-weight: 600; font-size: 1.05rem; }
.amount.large { font-size: 1.4rem; }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .sidebar { transform: translateX(100%); }
  .sidebar.open { transform: translateX(0); box-shadow: -10px 0 40px rgba(0,0,0,0.2); }
  .main { margin-right: 0; }
  .menu-toggle { display: flex; align-items: center; justify-content: center; }
  .content { padding: 1rem; }
  .topbar { padding: 1rem; }
}
