/* ═══════════════════════════════════════════════════════════════
   Heaven Studio ERP — Main CSS
   Design System: Variables, Reset, Layout, Sidebar, Login
   ═══════════════════════════════════════════════════════════════ */

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

/* ─── CSS Variables ─── */
:root {
  /* Brand Colors */
  --heaven-gold: #F4D03F;
  --heaven-gold-light: #F9E79F;
  --heaven-gold-dark: #D4AF37;
  --heaven-bronze: #B8860B;
  --heaven-bronze-light: #D4A574;
  --heaven-black: #0F0F0F;
  --heaven-charcoal: #1A1A1A;
  --heaven-gray: #242424;
  --heaven-cloud: #FFFFFF;

  /* Backgrounds */
  --bg-primary: #0F0F0F;
  --bg-dark: #0A0A0A;
  --bg-elevated: #1A1A1A;
  --bg-elevated-2: #242424;
  --bg-hover: #2A2A2A;

  /* Text Colors */
  --text-primary: #FFFFFF;
  --text-secondary: #B0B0B0;
  --text-tertiary: #808080;
  --text-muted: #707070;

  /* Gradients */
  --gradient-golden: linear-gradient(135deg, var(--heaven-gold), var(--heaven-bronze));
  --gradient-dark: linear-gradient(135deg, #1A1A1A, #0F0F0F);

  /* Borders & Shadows */
  --border-subtle: #2A2A2A;
  --border-hover: #3A3A3A;
  --shadow-gold-sm: 0 2px 8px rgba(244, 208, 63, 0.1);
  --shadow-gold-md: 0 4px 16px rgba(244, 208, 63, 0.15);
  --shadow-gold-lg: 0 8px 32px rgba(244, 208, 63, 0.2);
  --shadow-lg: 0 12px 48px rgba(0, 0, 0, 0.5);

  /* Spacing */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2rem;
  --spacing-xl: 3rem;

  /* Status Colors */
  --status-success: #10B981;
  --status-warning: #F59E0B;
  --status-error: #EF4444;
  --status-info: #3B82F6;
  --sound-green: #52C41A;
  --sound-orange: #FAAD14;
  --sound-red: #F5222D;
  --sound-blue: #1890FF;
  --sound-cyan: #13C2C2;
  --sound-purple: #722ED1;

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 24px;

  /* Card & shadow */
  --bg-dark-card: #1c1c1c;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.35);

  /* Transition */
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;
  --sidebar-width: 280px;
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: 'IBM Plex Sans Arabic', 'Segoe UI', Tahoma, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  direction: rtl;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  width: 100%;
  overflow-y: auto !important;
  -webkit-overflow-scrolling: touch !important;
  height: auto !important;
}

a {
  color: inherit;
  text-decoration: none;
}

button, input, select, textarea {
  font-family: inherit;
  direction: rtl;
}

img, svg {
  display: block;
  max-width: 100%;
}

select option {
  background: var(--bg-elevated);
  color: var(--text-primary);
}

#app {
  min-height: 100vh;
  overflow-x: hidden;
  width: 100%;
  position: relative;
}
@media (max-width: 768px) {
  /* Allow child containers to scroll horizontally on mobile */
  #app { overflow-x: clip; }
}

.page-container {
  display: block;
  min-height: 100vh;
  width: 100%;
}

/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-elevated);
  border-left: 1px solid rgba(244, 208, 63, 0.12);
  display: flex;
  flex-direction: column;
  position: fixed;
  right: 0;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  transition: transform var(--transition-normal);
}

.sidebar::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 150px;
  background: repeating-linear-gradient(
    0deg,
    transparent 0px, transparent 3px,
    rgba(244, 208, 63, 0.02) 3px, rgba(244, 208, 63, 0.02) 6px
  );
  pointer-events: none;
}

.sidebar-header {
  padding: 32px 24px;
  border-bottom: 1px solid rgba(244, 208, 63, 0.12);
  text-align: center;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}

.sidebar-logo {
  width: 70px;
  height: 70px;
  margin: 0 auto 16px;
  filter: drop-shadow(0 0 16px rgba(244, 208, 63, 0.4));
}

.sidebar-title {
  font-size: 20px;
  font-weight: 700;
  background: var(--gradient-golden);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 4px;
}

.sidebar-subtitle {
  font-size: 12px;
  color: var(--text-tertiary);
}

.sidebar-nav {
  flex: 1;
  padding: 24px 0;
  overflow-y: auto;
}

.nav-section {
  margin-bottom: 32px;
}

.nav-section-title {
  padding: 0 24px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 24px;
  color: var(--text-secondary);
  text-decoration: none;
  transition: all var(--transition-normal);
  position: relative;
  margin: 2px 12px;
  border-radius: var(--radius-md);
  cursor: pointer;
}

.nav-item::before {
  content: '';
  position: absolute;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 0;
  background: var(--gradient-golden);
  border-radius: 2px;
  transition: height var(--transition-normal);
}

.nav-item:hover::before, .nav-item.active::before { height: 60%; }

.nav-item:hover, .nav-item.active {
  background: rgba(244, 208, 63, 0.08);
  color: var(--heaven-gold);
}

.nav-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.nav-item span {
  font-size: 15px;
  font-weight: 500;
}

/* Submenu Styles */
.nav-item-wrapper {
  margin-bottom: 2px;
}

.submenu-arrow {
  margin-right: auto;
  transition: transform var(--transition-normal);
}

.submenu-open .submenu-arrow {
  transform: rotate(180deg);
}

.submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-normal), opacity var(--transition-normal);
  opacity: 0;
  padding-right: 32px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0 12px;
}

.submenu-open .submenu {
  max-height: 500px;
  opacity: 1;
  padding-top: 4px;
  padding-bottom: 8px;
}

.submenu-item {
  padding: 8px 16px;
  font-size: 13.5px;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  display: block;
}

.submenu-item:hover, .submenu-item.active {
  background: rgba(244, 208, 63, 0.05);
  color: var(--heaven-gold);
}

.submenu-item.active {
  font-weight: 600;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid rgba(244, 208, 63, 0.12);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.user-avatar-sm {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--gradient-golden);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--heaven-black);
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.user-info-sm { flex: 1; min-width: 0; }

.user-name-sm {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-sm {
  font-size: 12px;
  color: var(--text-tertiary);
}

.logout-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: rgba(231, 76, 60, 0.08);
  border: 1px solid rgba(231, 76, 60, 0.15);
  color: var(--sound-red);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-normal);
  flex-shrink: 0;
}

.logout-btn:hover {
  background: rgba(231, 76, 60, 0.15);
}

/* ─── Main Content ─── */
.main-content {
  flex: 1;
  margin-right: var(--sidebar-width);
  padding: 32px;
  min-height: 100vh;
  max-width: calc(100% - var(--sidebar-width));
}

/* ─── Animations ─── */
.page-enter {
  animation: fadeInUp 0.3s ease;
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Premium UI Overhaul ─── */
:root {
  --glass-bg: rgba(26, 26, 26, 0.7);
  --glass-border: rgba(244, 208, 63, 0.15);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
}

.card {
  background: var(--bg-dark-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
  padding: 0 !important;
}

.card:hover {
  border-color: rgba(244, 208, 63, 0.25);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

/* Dashboard Stats Premium */
.stat-card {
  background: linear-gradient(145deg, #1e1e1e, #141414);
  padding: 24px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  gap: 20px;
  position: relative;
  overflow: hidden;
}

.stat-card::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(244, 208, 63, 0.03) 0%, transparent 70%);
  pointer-events: none;
}

.stat-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: inset 0 0 12px rgba(0, 0, 0, 0.2);
}

.stat-value {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  margin-bottom: 4px;
  background: var(--gradient-golden);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.stat-label {
  font-size: 13px;
  color: var(--text-tertiary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Quick Actions Premium */
.quick-action-btn {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(244, 208, 63, 0.1);
  color: var(--text-primary);
  padding: 16px;
  border-radius: var(--radius-md);
  text-align: right;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.quick-action-btn:hover {
  background: rgba(244, 208, 63, 0.08);
  border-color: var(--heaven-gold);
  transform: translateX(-5px);
  color: var(--heaven-gold);
}

/* Modal Premium Overhaul */
.modal-overlay {
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
}

.modal-box {
  background: #1a1a1a;
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  box-shadow: var(--glass-shadow);
  animation: modalSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(40px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
  padding: 24px 32px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: linear-gradient(to bottom, rgba(244, 208, 63, 0.03), transparent);
}

.modal-title {
  color: var(--heaven-gold);
  font-size: 20px;
  font-weight: 700;
}

.close-modal {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-tertiary);
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.close-modal:hover {
  background: var(--sound-red);
  color: white;
  transform: rotate(90deg);
}

/* Text/secondary buttons that also carry close-modal for event delegation must NOT rotate */
.btn-secondary.close-modal,
.btn-secondary.close-modal:hover {
  width: auto;
  height: auto;
  border-radius: 50px;
  transform: none;
}

/* Utility */
.p-24 { padding: 24px; }

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Premium Form Inputs */
.form-input, .form-select, .form-textarea {
  background: rgba(255, 255, 255, 0.07) !important;
  border: 1px solid rgba(255, 255, 255, 0.15) !important;
  color: #fff !important;
  padding: 12px 16px !important;
  border-radius: 12px !important;
  transition: all 0.2s ease !important;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--heaven-gold) !important;
  background: rgba(244, 208, 63, 0.04) !important;
  box-shadow: 0 0 0 4px rgba(244, 208, 63, 0.1) !important;
  outline: none !important;
}

.btn-primary {
  background: var(--gradient-golden);
  color: var(--heaven-black);
  font-weight: 700;
  border: none;
  box-shadow: 0 4px 15px rgba(244, 208, 63, 0.3);
  transition: all 0.3s ease;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(244, 208, 63, 0.4);
}

/* ─── Login Page ─── */
.login-page-bg {
  min-height: 100vh;
  background: var(--bg-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  position: relative;
  overflow: hidden;
}

.login-page-bg::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(244, 208, 63, 0.07) 0%, transparent 70%);
  top: -100px; right: -100px;
  pointer-events: none;
}

.login-page-bg::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(244, 208, 63, 0.04) 0%, transparent 70%);
  bottom: -50px; left: -50px;
  pointer-events: none;
}

/* ─── Offline Banner ─── */
.offline-banner {
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--sound-orange);
  color: #fff;
  text-align: center;
  padding: 10px;
  font-size: 14px;
  font-weight: 600;
  z-index: 99999;
  transform: translateY(-100%);
  transition: transform var(--transition-normal);
}

.offline-banner.visible { transform: translateY(0); }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(244, 208, 63, 0.18); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(244, 208, 63, 0.35); }

/* ─── Mobile Support ─── */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0; right: 0; left: 0;
  height: 60px;
  background: var(--bg-elevated);
  border-bottom: 1px solid rgba(244, 208, 63, 0.12);
  z-index: 99;
  padding: 0 16px;
  align-items: center;
  gap: 12px;
}

.mobile-menu-btn {
  width: 40px; height: 40px;
  border-radius: var(--radius-sm);
  background: rgba(244, 208, 63, 0.08);
  border: 1px solid rgba(244, 208, 63, 0.15);
  color: var(--heaven-gold);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 99;
  display: none;
}

.sidebar-backdrop.visible { display: block; }

@media (max-width: 900px) {
  html { font-size: 14px; } /* Scale typography down slightly */
  
  .sidebar {
    transform: translateX(100%);
    box-shadow: var(--shadow-dark);
  }
  .sidebar.open { transform: translateX(0); }
  
  .main-content { 
    margin-right: 0; 
    padding: 80px 16px 24px; 
    max-width: 100%; 
    width: 100%;
  }
  
  .mobile-topbar { display: flex; }
  .mobile-menu-btn { display: flex; }
  
  /* Make buttons and inputs easier to tap */
  button, input, select {
    min-height: 44px;
  }
}

@media (min-width: 901px) {
  .mobile-menu-btn { display: none !important; }
  .sidebar-backdrop { display: none !important; }
}
/* ─── Premium UI Extensions ─── */
.stat-mini {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex: 1;
  min-width: 200px;
}

.stat-mini-icon {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.03);
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-mini-label {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}

.stat-mini-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
}

/* Switch / Toggle */
.switch {
  position: relative;
  display: inline-block;
  width: 48px;
  height: 24px;
}

.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0; left: 0; right: 0; bottom: 0;
  background-color: #333;
  transition: .4s;
  border: 1px solid rgba(255,255,255,0.1);
}

.slider:before {
  position: absolute;
  content: "";
  height: 16px;
  width: 16px;
  left: 4px;
  bottom: 3px;
  background-color: white;
  transition: .4s;
}

input:checked + .slider {
  background-color: var(--heaven-gold);
}

input:checked + .slider:before {
  transform: translateX(24px);
  background-color: var(--heaven-black);
}

.slider.round {
  border-radius: 24px;
}

.slider.round:before {
  border-radius: 50%;
}

/* Empty State */
.empty-state {
  padding: 60px 24px;
  text-align: center;
  background: rgba(255,255,255,0.01);
  border: 1px dashed var(--border-subtle);
  border-radius: var(--radius-lg);
  margin: 20px 0;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.empty-state-text {
  font-size: 14px;
  color: var(--text-tertiary);
  max-width: 300px;
  margin: 0 auto;
}
