/* CSS Variables based on Sidar AI Theme */
:root {
  --bg: #0d1310;
  --bg2: #141c18;
  --bg-sidebar: #0a0f0d;
  --border: rgba(197, 162, 69, 0.3);
  --bord2: rgba(255, 255, 255, 0.08);
  --gold: #c5a245;
  --gold-hover: #d8b456;
  --gold3: rgba(197, 162, 69, 0.1);
  --gold4: rgba(197, 162, 69, 0.05);
  --muted: #9ca3af;
  --text: #f3f4f6;
  --teal: #1e5238;
  --danger: #ef4444;
  --danger-bg: rgba(239, 68, 68, 0.1);
  --warning: #f59e0b;
  --warning-bg: rgba(245, 158, 11, 0.1);
  --success: #10b981;
  --success-bg: rgba(16, 185, 129, 0.1);
  
  --r: 0.5rem;
  --rL: 1rem;
  --rXL: 1.5rem;
  
  --glass-bg: rgba(20, 28, 24, 0.4);
  --shadow-glow: 0 4px 20px rgba(197, 162, 69, 0.15);
}

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

body {
  font-family: 'Inter', 'Tajawal', sans-serif;
  background-color: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow: hidden; /* Prevent full page scroll, let main-content scroll */
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Cormorant Garamond', serif;
  color: var(--gold);
  margin: 0;
  font-weight: 600;
}

a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: transparent; font-family: inherit; color: inherit; }
ul { list-style: none; }

/* Dashboard Layout */
.app-container {
  display: flex;
  height: 100vh;
  width: 100%;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--bord2);
  display: flex;
  flex-direction: column;
  transition: transform 0.3s ease;
  z-index: 50;
}

.sidebar-header {
  height: 70px;
  display: flex;
  align-items: center;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--bord2);
}

.logo {
  font-family: 'Cormorant Garamond', serif;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 1px;
}
.logo sup { color: var(--gold); font-family: 'Inter', sans-serif; font-size: 0.8rem; font-weight: normal; }

.nav-menu {
  flex: 1;
  padding: 1.5rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.8rem 1rem;
  border-radius: var(--r);
  color: var(--muted);
  transition: all 0.3s;
}

.nav-item i { width: 20px; text-align: center; font-size: 1.1rem; }
.nav-item:hover { background: var(--gold4); color: var(--text); }
.nav-item.active { background: var(--gold3); color: var(--gold); border-left: 3px solid var(--gold); }

.sidebar-footer {
  padding: 1.5rem;
  border-top: 1px solid var(--bord2);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.admin-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--gold), var(--teal));
  display: flex; align-items: center; justify-content: center;
  font-weight: bold; color: var(--bg); font-family: 'Cormorant Garamond', serif;
}
.admin-info h4 { font-family: 'Inter', sans-serif; font-size: 0.9rem; color: var(--text); }
.admin-info p { font-size: 0.75rem; color: var(--muted); margin: 0; }

/* Main Content Area */
.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at top right, rgba(30,82,56,0.1), transparent 40%), var(--bg);
  min-width: 0;
}

.top-header {
  height: 70px;
  background: rgba(13, 19, 16, 0.8);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--bord2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 2rem;
}

.header-left { display: flex; align-items: center; gap: 1rem; }
.menu-toggle { display: none; font-size: 1.2rem; color: var(--muted); }

.page-title {
  font-size: 1.5rem;
  color: var(--text);
  margin: 0;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
}

.header-right { display: flex; align-items: center; gap: 1.5rem; }
.icon-btn { position: relative; font-size: 1.2rem; color: var(--muted); transition: color 0.3s; }
.icon-btn:hover { color: var(--gold); }
.badge {
  position: absolute; top: -5px; right: -5px;
  background: var(--danger); color: white;
  font-size: 0.6rem; font-weight: bold;
  width: 16px; height: 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

/* Page Content */
.page-content {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
  display: none; /* Handled by JS */
}
.page-content.active { display: block; animation: fadeIn 0.4s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Cards & Glassmorphism */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--bord2);
  border-radius: var(--rL);
  padding: 1.5rem;
  transition: all 0.3s;
}

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

.kpi-card {
  display: flex;
  align-items: center;
  gap: 1.5rem;
}
.kpi-icon {
  width: 56px; height: 56px;
  border-radius: var(--r);
  background: var(--gold3);
  color: var(--gold);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
}
.kpi-details span { font-size: 0.85rem; color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.kpi-details strong { display: block; font-family: 'Cormorant Garamond', serif; font-size: 2rem; color: var(--text); line-height: 1.1; }

/* Tables */
.table-container {
  width: 100%;
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.data-table th {
  padding: 1rem;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
  border-bottom: 1px solid var(--bord2);
  white-space: nowrap;
}

.data-table td {
  padding: 1rem;
  font-size: 0.9rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
  vertical-align: middle;
}

.data-table tbody tr { transition: background 0.3s; }
.data-table tbody tr:hover { background: rgba(30, 82, 56, 0.1); }

/* Status Badges */
.status-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 99px;
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: capitalize;
}
.status-completed { background: var(--success-bg); color: var(--success); border: 1px solid var(--success); }
.status-pending { background: var(--warning-bg); color: var(--warning); border: 1px solid var(--warning); }
.status-failed { background: var(--danger-bg); color: var(--danger); border: 1px solid var(--danger); }

/* Urgency / Severity Badges */
.urgency-high { color: var(--danger); }
.urgency-medium { color: var(--warning); }
.urgency-low { color: var(--success); }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 1rem; border-radius: var(--r);
  font-size: 0.85rem; font-weight: 500;
  transition: all 0.3s;
}
.btn-primary { background: var(--gold); color: var(--bg); }
.btn-primary:hover { background: var(--gold-hover); transform: translateY(-1px); box-shadow: var(--shadow-glow); }
.btn-outline { border: 1px solid var(--bord2); color: var(--text); }
.btn-outline:hover { border-color: var(--gold); color: var(--gold); }
.btn-action { padding: 0.4rem; color: var(--muted); border-radius: var(--r); }
.btn-action:hover { background: var(--gold3); color: var(--gold); }

/* User Cell */
.user-cell { display: flex; align-items: center; gap: 0.8rem; }
.user-avatar { width: 36px; height: 36px; border-radius: 50%; object-fit: cover; background: var(--bg2); }
.user-cell-info strong { display: block; font-weight: 500; color: var(--text); }
.user-cell-info span { font-size: 0.75rem; color: var(--muted); }

/* Arrays & Tags */
.tags-list { display: flex; gap: 0.4rem; flex-wrap: wrap; }
.tag { background: rgba(255,255,255,0.05); border: 1px solid var(--bord2); padding: 0.2rem 0.6rem; border-radius: var(--r); font-size: 0.75rem; color: var(--muted); }

/* Score Formatting */
.score-display { display: flex; align-items: center; gap: 0.5rem; }
.score-display strong { font-size: 1.1rem; color: var(--gold); }

/* Section Headers */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}
.section-header h2 { font-size: 1.8rem; }

/* Layout Grids */
.dashboard-grid {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 1.5rem;
}
@media (max-width: 1024px) {
  .dashboard-grid { grid-template-columns: 1fr; }
}

/* Modal Overlay */
.modal-overlay {
  position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
  background: rgba(0,0,0,0.7); backdrop-filter: blur(5px);
  display: flex; align-items: center; justify-content: center;
  z-index: 1000; opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal-overlay.active { opacity: 1; pointer-events: auto; }

.modal-content {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--rL);
  width: 90%; max-width: 800px; max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-glow);
  transform: translateY(20px); transition: transform 0.3s;
}
.modal-overlay.active .modal-content { transform: translateY(0); }

.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 1.5rem; border-bottom: 1px solid var(--bord2);
}
.modal-body { padding: 1.5rem; }
.modal-close { font-size: 1.2rem; color: var(--muted); }
.modal-close:hover { color: var(--danger); }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--bord2);
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 1.2rem;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.form-control {
  width: 100%;
  padding: 0.8rem 1rem;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--bord2);
  border-radius: var(--r);
  color: var(--text);
  font-family: inherit;
  transition: all 0.3s;
}
.form-control:focus {
  outline: none;
  border-color: var(--gold);
  background: rgba(20, 28, 24, 0.6);
  box-shadow: 0 0 0 2px var(--gold4);
}
textarea.form-control {
  resize: vertical;
  min-height: 80px;
}
select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%239ca3af' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14 2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  padding-right: 2.5rem;
}
select.form-control option {
  background: var(--bg2);
  color: var(--text);
}

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #dc2626; transform: translateY(-1px); box-shadow: 0 4px 15px rgba(239, 68, 68, 0.2); }

/* Grid specific to forms */
.form-grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* Pricing Plans */
.pricing-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.5rem;
}
.pricing-card {
  background: var(--glass-bg);
  border: 1px solid var(--bord2);
  border-radius: var(--rL);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  transition: transform 0.3s, box-shadow 0.3s;
  position: relative;
  overflow: hidden;
}
.pricing-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-glow);
  border-color: var(--border);
}
.pricing-card.inactive {
  opacity: 0.6;
  filter: grayscale(100%);
}
.pricing-header {
  text-align: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--bord2);
}
.pricing-header h3 { font-size: 1.8rem; margin-bottom: 0.5rem; }
.pricing-price {
  font-family: 'Inter', sans-serif;
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--text);
}
.pricing-price span { font-size: 1rem; color: var(--muted); font-weight: normal; }
.pricing-features {
  list-style: none;
  margin-bottom: 2rem;
  flex: 1;
}
.pricing-features li {
  margin-bottom: 0.8rem;
  font-size: 0.9rem;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.pricing-features li::before {
  content: '\f00c';
  font-family: 'Font Awesome 6 Free';
  font-weight: 900;
  color: var(--gold);
  font-size: 0.8rem;
}
.pricing-actions {
  display: flex; gap: 0.5rem;
  margin-top: auto;
}
.pricing-actions .btn { flex: 1; justify-content: center; }

/* Product Thumbnail */
.product-thumb {
  width: 48px;
  height: 48px;
  border-radius: var(--r);
  object-fit: cover;
  border: 1px solid var(--bord2);
  background: var(--bg2);
}

/* Notifications List */
.notification-item {
  display: flex;
  gap: 1.5rem;
  padding: 1.5rem;
  border-bottom: 1px solid var(--bord2);
  transition: background 0.3s;
}
.notification-item:hover {
  background: rgba(255,255,255,0.02);
}
.notification-item.unread {
  background: var(--gold4);
  border-left: 3px solid var(--gold);
}
.notif-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  flex-shrink: 0;
}
.notif-content h4 {
  font-family: 'Inter', sans-serif;
  font-size: 1rem;
  color: var(--text);
  margin-bottom: 0.3rem;
}
.notif-content p {
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 0.5rem;
}
.notif-time {
  font-size: 0.75rem;
  color: var(--gold);
}

/* Responsive Styles */
@media (max-width: 768px) {
  /* Sidebar Overlay */
  .sidebar { 
    position: fixed; 
    height: 100vh; 
    transform: translateX(-100%); 
    z-index: 1000; 
  }
  .sidebar.open { transform: translateX(0); box-shadow: 4px 0 20px rgba(0,0,0,0.8); }
  .menu-toggle { display: block; z-index: 1001; }
  
  /* Main Wrapper fixes */
  .main-wrapper { 
    width: 100vw; 
    max-width: 100%; 
  }
  
  /* Header padding */
  .top-header { 
    padding: 0 1rem; 
  }
  .page-title {
    font-size: 1.2rem;
  }
  
  /* Content padding */
  .page-content {
    padding: 1rem;
  }
  
  /* Grids */
  .kpi-grid,
  .stats-grid,
  .form-grid-2,
  .inv-hero-grid,
  .market-cards,
  .pricing-grid { 
    grid-template-columns: 1fr; 
  }
  .inv-hero-grid { gap: 1.5rem; }
  
  /* Modals */
  .modal-content { 
    padding: 1.5rem; 
    margin: 1rem; 
    width: calc(100% - 2rem); 
    max-height: 90vh;
    overflow-y: auto;
  }
  
  /* Tables */
  .table-container { 
    overflow-x: auto; 
    -webkit-overflow-scrolling: touch; 
    border-radius: var(--r);
  }
  .data-table th, .data-table td { 
    padding: 0.8rem; 
    font-size: 0.85rem; 
  }
  
  /* Section Header */
  .section-header { 
    flex-direction: column; 
    align-items: flex-start; 
    gap: 1rem; 
  }
  .section-header > div { 
    width: 100%; 
    display: flex; 
    flex-direction: column; 
  }
  .section-header .btn { 
    width: 100%; 
    justify-content: center; 
  }
  
  /* Notifications */
  .notification-item { 
    flex-direction: column; 
    gap: 0.8rem; 
  }
}

/* Login Page Styles */
.login-body {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at center, rgba(30,82,56,0.3) 0%, var(--bg) 70%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border);
  border-radius: var(--rL);
  padding: 3rem 2rem;
  box-shadow: var(--shadow-glow);
  text-align: center;
}

.login-logo {
  font-family: 'Cormorant Garamond', serif;
  font-size: 2.2rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: 2px;
  margin-bottom: 0.5rem;
}
.login-logo sup { color: var(--gold); font-family: 'Inter', sans-serif; font-size: 1rem; font-weight: normal; }

.login-subtitle {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 2.5rem;
}

.login-form {
  text-align: left;
}
.login-form .form-group {
  margin-bottom: 1.5rem;
}
.login-btn {
  width: 100%;
  padding: 0.65rem 1.2rem;
  font-size: 0.85rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  margin-top: 1rem;
  justify-content: center;
}
/* Toast Notifications */
#toastContainer {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.toast {
  min-width: 300px;
  padding: 1rem 1.5rem;
  border-radius: var(--r);
  background: var(--bg2);
  border-left: 4px solid var(--gold);
  color: var(--text);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  gap: 1rem;
  animation: slideIn 0.3s ease-out forwards;
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.warning { border-left-color: var(--warning); }

.toast i { font-size: 1.2rem; }
.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }
.toast.warning i { color: var(--warning); }

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.toast.fade-out {
  animation: fadeOut 0.3s ease-in forwards;
}

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