/* ===== FALYUM FURNITURE FACTORY - MAIN STYLES ===== */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800&display=swap');

:root {
  --primary: #1a3a5c;
  --primary-light: #2563a8;
  --gold: #c9a84c;
  --gold-light: #f0d080;
  --dark: #0d1b2a;
  --surface: #1e2d3d;
  --surface2: #243447;
  --border: rgba(201,168,76,0.2);
  --text: #e8edf2;
  --text-muted: #8899aa;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  --radius: 12px;
  --shadow: 0 8px 32px rgba(0,0,0,0.3);
}

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

body {
  font-family: 'Tajawal', sans-serif;
  background: var(--dark);
  color: var(--text);
  direction: rtl;
  min-height: 100vh;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--dark); }
::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 3px; }

/* ===== LAYOUT ===== */
.app-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  grid-template-rows: 70px 1fr;
  min-height: 100vh;
}

.sidebar {
  grid-row: 1 / -1;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
  text-align: center;
}

.sidebar-logo .logo-text {
  font-size: 1.6rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.sidebar-logo .logo-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.sidebar-nav { padding: 16px 12px; flex: 1; }

.nav-section-title {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 8px 10px 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 3px;
  text-decoration: none;
  border: 1px solid transparent;
}

.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: rgba(201,168,76,0.15); color: var(--gold); border-color: var(--border); }
.nav-item .icon { font-size: 1.1rem; width: 22px; text-align: center; }

.badge {
  margin-right: auto;
  background: var(--danger);
  color: #fff;
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 20px;
  font-weight: 700;
}

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

.user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  background: var(--surface2);
  border-radius: 10px;
}

.user-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-light), var(--gold));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.user-name { font-size: 0.85rem; font-weight: 600; }
.user-role { font-size: 0.72rem; color: var(--gold); }

.btn-logout {
  margin-right: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: 4px;
  transition: color 0.2s;
}
.btn-logout:hover { color: var(--danger); }

/* ===== TOPBAR ===== */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-title { font-size: 1.1rem; font-weight: 700; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

/* ===== MAIN CONTENT ===== */
.main-content { padding: 28px; overflow-y: auto; }

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

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

.card-title { font-size: 1.05rem; font-weight: 700; }

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

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

.stat-icon.gold { background: rgba(201,168,76,0.15); }
.stat-icon.blue { background: rgba(59,130,246,0.15); }
.stat-icon.green { background: rgba(16,185,129,0.15); }
.stat-icon.red { background: rgba(239,68,68,0.15); }
.stat-icon.purple { background: rgba(139,92,246,0.15); }

.stat-value { font-size: 1.8rem; font-weight: 800; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); margin-top: 2px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 9px;
  border: none;
  cursor: pointer;
  font-family: 'Tajawal', sans-serif;
  font-size: 0.88rem;
  font-weight: 600;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary { background: linear-gradient(135deg, var(--primary-light), var(--primary)); color: #fff; }
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-gold { background: linear-gradient(135deg, var(--gold), #a07830); color: #fff; }
.btn-gold:hover { opacity: 0.9; transform: translateY(-1px); }

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

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

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

.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-lg { padding: 12px 28px; font-size: 1rem; }

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

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

th {
  background: var(--surface2);
  padding: 12px 14px;
  text-align: right;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.8rem;
  white-space: nowrap;
}

td { padding: 12px 14px; border-bottom: 1px solid rgba(255,255,255,0.05); vertical-align: middle; }
tr:hover td { background: rgba(255,255,255,0.02); }

/* ===== STATUS BADGES ===== */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.status-new { background: rgba(59,130,246,0.2); color: #60a5fa; }
.status-factory { background: rgba(245,158,11,0.2); color: #fbbf24; }
.status-accountant { background: rgba(139,92,246,0.2); color: #a78bfa; }
.status-approved { background: rgba(16,185,129,0.2); color: #34d399; }
.status-rejected { background: rgba(239,68,68,0.2); color: #f87171; }
.status-sent { background: rgba(201,168,76,0.2); color: var(--gold); }

/* ===== FORMS ===== */
.form-group { margin-bottom: 18px; }

label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 7px;
  font-weight: 500;
}

input, textarea, select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 10px 14px;
  color: var(--text);
  font-family: 'Tajawal', sans-serif;
  font-size: 0.9rem;
  transition: border-color 0.2s;
  outline: none;
}

input:focus, textarea:focus, select:focus { border-color: var(--gold); }

textarea { resize: vertical; min-height: 90px; }

select option { background: var(--surface); }

.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.col-span-2 { grid-column: span 2; }
.col-span-3 { grid-column: span 3; }

/* ===== FILE UPLOAD ===== */
.upload-area {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}

.upload-area:hover { border-color: var(--gold); background: rgba(201,168,76,0.05); }
.upload-area.dragover { border-color: var(--gold); background: rgba(201,168,76,0.1); }
.upload-icon { font-size: 2.5rem; margin-bottom: 8px; }
.upload-text { color: var(--text-muted); font-size: 0.88rem; }

.img-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.img-preview-item {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 1;
}

.img-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.img-remove {
  position: absolute;
  top: 4px;
  left: 4px;
  background: var(--danger);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 22px;
  height: 22px;
  cursor: pointer;
  font-size: 0.7rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ===== WORKFLOW TIMELINE ===== */
.workflow-timeline {
  display: flex;
  align-items: center;
  gap: 0;
  margin: 20px 0;
  overflow-x: auto;
  padding: 10px 0;
}

.wf-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  min-width: 100px;
}

.wf-dot {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--surface2);
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  position: relative;
  z-index: 1;
  transition: all 0.3s;
}

.wf-dot.done { background: rgba(16,185,129,0.2); border-color: var(--success); color: var(--success); }
.wf-dot.active { background: rgba(201,168,76,0.2); border-color: var(--gold); color: var(--gold); animation: pulse 2s infinite; }

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(201,168,76,0.4); }
  50% { box-shadow: 0 0 0 8px rgba(201,168,76,0); }
}

.wf-label { font-size: 0.72rem; color: var(--text-muted); text-align: center; line-height: 1.3; }
.wf-connector { flex: 1; height: 2px; background: var(--border); min-width: 30px; }
.wf-connector.done { background: var(--success); }

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 100%;
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95);
  transition: transform 0.2s;
}

.modal-overlay.open .modal { transform: scale(1); }

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

.modal-title { font-size: 1.05rem; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 1.2rem; }
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ===== ALERT ===== */
.alert {
  padding: 12px 16px;
  border-radius: 9px;
  margin-bottom: 16px;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-success { background: rgba(16,185,129,0.15); border: 1px solid rgba(16,185,129,0.3); color: #34d399; }
.alert-warning { background: rgba(245,158,11,0.15); border: 1px solid rgba(245,158,11,0.3); color: #fbbf24; }
.alert-danger { background: rgba(239,68,68,0.15); border: 1px solid rgba(239,68,68,0.3); color: #f87171; }
.alert-info { background: rgba(59,130,246,0.15); border: 1px solid rgba(59,130,246,0.3); color: #60a5fa; }

/* ===== TABS ===== */
.tabs { display: flex; gap: 4px; margin-bottom: 20px; border-bottom: 1px solid var(--border); }

.tab {
  padding: 10px 18px;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text-muted);
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  font-weight: 500;
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--gold); border-bottom-color: var(--gold); }

.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== NOTIFICATION DOT ===== */
.notif-dot {
  width: 8px;
  height: 8px;
  background: var(--danger);
  border-radius: 50%;
  display: inline-block;
  animation: blink 1.5s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* ===== COST TABLE ===== */
.cost-table input {
  background: var(--dark);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 0.85rem;
}

.cost-total {
  background: rgba(201,168,76,0.1);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-top: 16px;
  border: 1px solid var(--border);
}

/* ===== PRINT BUTTON ===== */
.btn-print { background: #fff; color: #333; }
.btn-print:hover { background: #f0f0f0; }

/* ===== EMPTY STATE ===== */
.empty-state {
  text-align: center;
  padding: 48px 24px;
  color: var(--text-muted);
}

.empty-icon { font-size: 3rem; margin-bottom: 12px; }
.empty-text { font-size: 0.9rem; }

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .app-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 60px 1fr;
  }

  .sidebar {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 500;
    width: 260px;
  }

  .sidebar.open { display: flex; }

  .form-grid, .form-grid-3 { grid-template-columns: 1fr; }
  .col-span-2, .col-span-3 { grid-column: span 1; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .main-content { padding: 16px; }
}

@media (max-width: 500px) {
  .stats-grid { grid-template-columns: 1fr; }
}

/* ===== LOGIN PAGE ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--dark);
  position: relative;
  overflow: hidden;
}

.login-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 50%, rgba(37,99,168,0.15) 0%, transparent 60%),
    radial-gradient(ellipse at 80% 20%, rgba(201,168,76,0.1) 0%, transparent 50%);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 44px 40px;
  width: 100%;
  max-width: 420px;
  position: relative;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo-text {
  font-size: 2.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-logo-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.login-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 24px;
  text-align: center;
}

/* ===== PRINT STYLES ===== */
@media print {
  body { background: #fff; color: #333; direction: rtl; }
  .no-print { display: none !important; }
  .print-only { display: block !important; }
}
