/* server/public/style.css — Elnagar BuildERP Online Modern Styling */

:root {
  --bg-dark: #070d18;
  --bg-card: #0e1726;
  --bg-card-hover: #131f33;
  --bg-input: #0a111d;
  --border-color: #1e293b;
  --border-color-light: #334155;
  
  --primary: #f59e0b;
  --primary-light: #fbbf24;
  --primary-dark: #d97706;
  
  --accent: #38bdf8;
  --emerald: #10b981;
  --emerald-light: #34d399;
  --rose: #f43f5e;
  --amber: #f59e0b;
  --indigo: #6366f1;
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --font-family: 'Cairo', system-ui, -apple-system, sans-serif;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.7);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-family);
}

body {
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  display: flex;
  flex-col: column;
  line-height: 1.5;
  direction: rtl;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */
header {
  background: rgba(14, 23, 38, 0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 40;
}

.header-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0.75rem 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.brand-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-md);
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.3);
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

/* Shouna Selector Badge & Dropdown */
.shouna-selector-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: #0b1322;
  border: 1px solid #1e3a8a;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-md);
  box-shadow: 0 0 12px rgba(59, 130, 246, 0.15);
}

.shouna-icon {
  font-size: 1.1rem;
}

.shouna-current-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--accent);
}

.shouna-dropdown {
  background: var(--bg-card);
  border: 1px solid var(--border-color-light);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
}

.sync-badge {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.75rem;
  font-weight: 700;
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.3);
  color: var(--emerald-light);
}

.sync-dot {
  font-size: 0.65rem;
}

.user-profile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
}

.user-role-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.15rem 0.5rem;
  border-radius: 6px;
}

.user-role-badge.admin {
  background: rgba(245, 158, 11, 0.2);
  color: var(--primary-light);
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.user-role-badge.employee {
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent);
  border: 1px solid rgba(56, 189, 248, 0.4);
}

/* Nav Tabs */
.nav-tabs {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  overflow-x: auto;
}

.nav-container {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 1.25rem;
  display: flex;
  gap: 0.5rem;
}

.nav-tab {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 0.85rem 1.15rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  border-bottom: 3px solid transparent;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.nav-tab:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.02);
}

.nav-tab.active {
  color: var(--primary-light);
  border-bottom-color: var(--primary);
  background: rgba(245, 158, 11, 0.05);
}

.tab-badge {
  background: var(--rose);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 800;
  padding: 0.1rem 0.4rem;
  border-radius: 999px;
}

/* ==========================================================================
   Main Content Views
   ========================================================================== */
main {
  max-width: 1440px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
  flex: 1;
  width: 100%;
}

.view-section {
  display: none;
}

.view-section.active {
  display: block;
  animation: fadeIn 0.25s ease-out;
}

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

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.section-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: #fff;
}

.section-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 0.2rem;
}

/* ==========================================================================
   KPI Cards Grid
   ========================================================================== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1rem;
}

.kpi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  box-shadow: var(--shadow-sm);
}

.kpi-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: var(--border-color-light);
}

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 4px;
}

.kpi-card.steel::before { background: linear-gradient(90deg, #38bdf8, #0284c7); }
.kpi-card.cement::before { background: linear-gradient(90deg, #fbbf24, #d97706); }
.kpi-card.value-card::before { background: linear-gradient(90deg, #10b981, #059669); }
.kpi-card.receivables::before { background: linear-gradient(90deg, #f43f5e, #be123c); }
.kpi-card.sales-card::before { background: linear-gradient(90deg, #818cf8, #4f46e5); }

.kpi-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.kpi-value {
  font-size: 1.8rem;
  font-weight: 900;
  color: #fff;
  display: flex;
  align-items: baseline;
  gap: 0.35rem;
}

.kpi-unit {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-dim);
}

.kpi-sub {
  font-size: 0.75rem;
  color: var(--text-dim);
  margin-top: 0.4rem;
}

/* ==========================================================================
   Cards, Tables, & Lists
   ========================================================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.card-header-flex {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.card-title {
  font-size: 1.05rem;
  font-weight: 800;
  color: #fff;
}

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: right;
  font-size: 0.85rem;
}

th {
  background: #09111e;
  color: var(--text-muted);
  font-weight: 700;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

td {
  padding: 0.8rem 1rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-main);
  white-space: nowrap;
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.55rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 700;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--emerald-light); border: 1px solid rgba(16, 185, 129, 0.3); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--primary-light); border: 1px solid rgba(245, 158, 11, 0.3); }
.badge-danger { background: rgba(244, 63, 94, 0.15); color: var(--rose); border: 1px solid rgba(244, 63, 94, 0.3); }
.badge-info { background: rgba(56, 189, 248, 0.15); color: var(--accent); border: 1px solid rgba(56, 189, 248, 0.3); }

/* ==========================================================================
   Buttons & Form Elements
   ========================================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.15rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.2s ease;
  outline: none;
  font-family: var(--font-family);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #000;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(245, 158, 11, 0.3);
}

.btn-primary:hover {
  filter: brightness(1.1);
  transform: translateY(-1px);
}

.btn-secondary {
  background: #1e293b;
  color: #f8fafc;
  border-color: var(--border-color-light);
}

.btn-secondary:hover {
  background: #334155;
  color: #fff;
}

.btn-warning {
  background: linear-gradient(135deg, #eab308, #ca8a04);
  color: #000;
  font-weight: 800;
}

.btn-success {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
}

.btn-sm {
  padding: 0.35rem 0.75rem;
  font-size: 0.75rem;
}

.btn-block {
  width: 100%;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-muted);
}

.req {
  color: var(--rose);
}

input, select, textarea {
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 0.65rem 0.85rem;
  color: #fff;
  font-size: 0.85rem;
  font-family: var(--font-family);
  outline: none;
  transition: border-color 0.2s ease;
  width: 100%;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.2);
}

/* ==========================================================================
   Modals & Overlays
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color-light);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  animation: zoomIn 0.2s ease-out;
}

@keyframes zoomIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--rose);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color-light);
  border-radius: var(--radius-xl);
  width: 100%;
  max-width: 400px;
  padding: 2rem 1.5rem;
  box-shadow: var(--shadow-lg);
}

.sale-items-box {
  background: #091220;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-top: 0.75rem;
}

.sale-summary-card {
  background: #0b1526;
  border: 1px solid #1e3a8a;
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-top: 0.75rem;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed var(--border-color);
}

/* Printable Receipt */
.receipt-box {
  background: #fff;
  color: #000;
  padding: 1.5rem;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.6;
}

.receipt-header {
  text-align: center;
  border-bottom: 2px solid #000;
  padding-bottom: 0.75rem;
  margin-bottom: 1rem;
}

.receipt-table {
  width: 100%;
  margin: 1rem 0;
  border-collapse: collapse;
}

.receipt-table th, .receipt-table td {
  border: 1px solid #ddd;
  padding: 0.5rem;
  color: #000;
  background: #fff !important;
}

@media print {
  body * {
    visibility: hidden;
  }
  #invoice-print-area, #invoice-print-area * {
    visibility: visible;
  }
  #invoice-print-area {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
  }
  .no-print {
    display: none !important;
  }
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
  .header-container {
    flex-direction: column;
    align-items: stretch;
  }
  .header-actions {
    justify-content: space-between;
  }
  .kpi-grid {
    grid-template-columns: 1fr;
  }
  .form-grid {
    grid-template-columns: 1fr;
  }
}
