/* ═══════════════════════════════════════════════════════════════
   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;

  /* 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;
}

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 Root ─── */
#app {
  min-height: 100vh;
}

/* ─── Page Layout ─── */
.page-container {
  display: flex;
  min-height: 100vh;
}

/* ─── 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;
}

.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(100vw - 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); } }

/* ─── Loading Spinner ─── */
.loading-spinner {
  width: 48px;
  height: 48px;
  border: 3px solid rgba(244, 208, 63, 0.15);
  border-top-color: var(--heaven-gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

/* ─── 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) {
  .sidebar {
    transform: translateX(100%);
    box-shadow: var(--shadow-dark);
  }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-right: 0; padding: 80px 16px 16px; max-width: 100vw; }
  .mobile-topbar { display: flex; }
  .mobile-menu-btn { display: flex; }
}

@media (min-width: 901px) {
  .mobile-menu-btn { display: none !important; }
  .sidebar-backdrop { display: none !important; }
}
