/* PrintStock - Custom Styles */
:root {
  --primary: #1e40af;
  --primary-light: #3b82f6;
  --success: #16a34a;
  --danger: #dc2626;
  --warning: #d97706;
  --sidebar-width: 260px;
}

* { box-sizing: border-box; }

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #f1f5f9;
}

[data-lang="en"] body,
[data-lang="en"] * {
  direction: ltr;
  text-align: left;
}

/* ========== LOGIN PAGE ========== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 50%, #2563eb 100%);
}

.login-card {
  background: white;
  border-radius: 16px;
  padding: 2.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 50px rgba(0,0,0,0.25);
}

.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}

.login-logo .logo-icon {
  font-size: 3rem;
  color: #1e40af;
}

/* ========== MAIN LAYOUT ========== */
.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ========== SIDEBAR ========== */
.sidebar {
  width: var(--sidebar-width);
  background: linear-gradient(180deg, #1e3a8a 0%, #1e40af 100%);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  transition: transform 0.3s ease;
  overflow-y: auto;
}

[data-lang="en"] .sidebar {
  right: auto;
  left: 0;
}

.sidebar-header {
  padding: 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  text-align: center;
}

.sidebar-header .brand-name {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 1px;
}

.sidebar-header .brand-sub {
  font-size: 0.75rem;
  opacity: 0.7;
  margin-top: 0.2rem;
}

.sidebar-nav {
  flex: 1;
  padding: 1rem 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 1.5rem;
  cursor: pointer;
  transition: all 0.2s;
  border-radius: 0;
  margin: 0.15rem 0.5rem;
  border-radius: 8px;
  font-size: 0.9rem;
}

.nav-item:hover {
  background: rgba(255,255,255,0.15);
}

.nav-item.active {
  background: rgba(255,255,255,0.2);
  font-weight: 600;
  border-right: 3px solid white;
}

[data-lang="en"] .nav-item.active {
  border-right: none;
  border-left: 3px solid white;
}

.nav-item i { width: 20px; text-align: center; opacity: 0.85; }

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.8rem;
}

/* ========== MAIN CONTENT ========== */
.main-content {
  flex: 1;
  margin-right: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

[data-lang="en"] .main-content {
  margin-right: 0;
  margin-left: var(--sidebar-width);
}

/* ========== TOP BAR ========== */
.topbar {
  background: white;
  padding: 0.75rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: #1e3a8a;
}

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

/* ========== PAGE CONTENT ========== */
.page-content {
  padding: 1.5rem;
  flex: 1;
}

/* ========== CARDS ========== */
.card {
  background: white;
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  overflow: hidden;
}

.card-header {
  padding: 1rem 1.5rem;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #fafbfc;
}

.card-body { padding: 1.5rem; }

/* ========== STATS CARDS ========== */
.stat-card {
  background: white;
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: transform 0.2s;
}

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

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

.stat-value { font-size: 1.75rem; font-weight: 700; line-height: 1; }
.stat-label { font-size: 0.8rem; color: #64748b; margin-top: 0.2rem; }

/* ========== TABLES ========== */
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table thead {
  background: #f8fafc;
}

.data-table th {
  padding: 0.75rem 1rem;
  text-align: right;
  font-weight: 600;
  color: #475569;
  border-bottom: 2px solid #e2e8f0;
  white-space: nowrap;
}

[data-lang="en"] .data-table th { text-align: left; }

.data-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
}

.data-table tbody tr:hover { background: #f8faff; }

.data-table tbody tr:last-child td { border-bottom: none; }

/* ========== BADGES ========== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge-green { background: #dcfce7; color: #16a34a; }
.badge-red { background: #fee2e2; color: #dc2626; }
.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-yellow { background: #fef3c7; color: #d97706; }
.badge-gray { background: #f1f5f9; color: #64748b; }
.badge-purple { background: #ede9fe; color: #7c3aed; }

/* ========== BUTTONS ========== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  outline: none;
  white-space: nowrap;
}

.btn-primary { background: #1e40af; color: white; }
.btn-primary:hover { background: #1e3a8a; }

.btn-success { background: #16a34a; color: white; }
.btn-success:hover { background: #15803d; }

.btn-danger { background: #dc2626; color: white; }
.btn-danger:hover { background: #b91c1c; }

.btn-warning { background: #d97706; color: white; }
.btn-warning:hover { background: #b45309; }

.btn-outline { background: white; border: 1.5px solid #e2e8f0; color: #334155; }
.btn-outline:hover { border-color: #1e40af; color: #1e40af; }

.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-lg { padding: 0.7rem 1.5rem; font-size: 1rem; }

.btn:disabled { opacity: 0.6; cursor: not-allowed; }

/* ========== FORMS ========== */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.875rem; font-weight: 500; color: #374151; margin-bottom: 0.4rem; }
.form-control {
  width: 100%;
  padding: 0.6rem 0.875rem;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  font-size: 0.875rem;
  transition: border-color 0.15s;
  background: white;
  color: #1e293b;
}
.form-control:focus { outline: none; border-color: #1e40af; box-shadow: 0 0 0 3px rgba(30,64,175,0.1); }
.form-control::placeholder { color: #94a3b8; }

select.form-control { cursor: pointer; }

/* ========== MODAL ========== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.15s ease;
}

.modal {
  background: white;
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 25px 60px rgba(0,0,0,0.3);
  animation: slideUp 0.2s ease;
}

.modal-lg { max-width: 800px; }

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #f1f5f9;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  background: white;
  z-index: 1;
}

.modal-title { font-size: 1.05rem; font-weight: 600; color: #1e3a8a; }
.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #f1f5f9;
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* ========== ALERTS ========== */
.alert {
  padding: 0.875rem 1rem;
  border-radius: 8px;
  font-size: 0.875rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
}

.alert-success { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.alert-error { background: #fee2e2; color: #b91c1c; border: 1px solid #fecaca; }
.alert-warning { background: #fef3c7; color: #b45309; border: 1px solid #fde68a; }
.alert-info { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* ========== STOCK INDICATOR ========== */
.stock-bar {
  height: 6px;
  border-radius: 999px;
  background: #e2e8f0;
  overflow: hidden;
  margin-top: 4px;
}
.stock-bar-fill { height: 100%; border-radius: 999px; transition: width 0.3s; }
.stock-good { background: #16a34a; }
.stock-low { background: #d97706; }
.stock-empty { background: #dc2626; }

/* ========== SEARCH BOX ========== */
.search-box {
  position: relative;
}
.search-box input {
  padding-right: 2.5rem;
  padding-left: 0.875rem;
}
[data-lang="en"] .search-box input {
  padding-left: 2.5rem;
  padding-right: 0.875rem;
}
.search-box .search-icon {
  position: absolute;
  right: 0.875rem;
  top: 50%;
  transform: translateY(-50%);
  color: #94a3b8;
}
[data-lang="en"] .search-box .search-icon {
  right: auto;
  left: 0.875rem;
}

/* ========== ANIMATIONS ========== */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid #e2e8f0;
  border-top-color: #1e40af;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ========== LOADING OVERLAY ========== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

/* ========== TOAST NOTIFICATIONS ========== */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  left: 1.5rem;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

[data-lang="en"] .toast-container {
  left: auto;
  right: 1.5rem;
}

.toast {
  padding: 0.875rem 1.25rem;
  border-radius: 10px;
  color: white;
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  animation: slideUp 0.25s ease;
  min-width: 260px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.toast-success { background: #16a34a; }
.toast-error { background: #dc2626; }
.toast-warning { background: #d97706; }
.toast-info { background: #1e40af; }

/* ========== RESPONSIVE ========== */
.sidebar-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.25rem;
  cursor: pointer;
  color: #1e40af;
  padding: 0.25rem;
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(100%);
  }
  [data-lang="en"] .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-right: 0;
    margin-left: 0;
  }
  .sidebar-toggle { display: block; }
  .page-content { padding: 1rem; }
  .stat-value { font-size: 1.4rem; }
  .data-table { font-size: 0.8rem; }
  .data-table th, .data-table td { padding: 0.5rem 0.6rem; }
  .hide-mobile { display: none !important; }
}

/* ========== IMPORT TABLE ========== */
.import-preview {
  max-height: 300px;
  overflow-y: auto;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

/* ========== ARABIC SPECIFIC ========== */
[data-lang="ar"] .nav-item.active {
  border-right: 3px solid white;
  border-left: none;
}

/* Number inputs RTL fix */
input[type="number"] { text-align: right; }
[data-lang="en"] input[type="number"] { text-align: left; }

/* ========== TRANSACTION TYPE COLORS ========== */
.tx-in { color: #16a34a; font-weight: 600; }
.tx-out { color: #dc2626; font-weight: 600; }

/* ========== EMPTY STATE ========== */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: #94a3b8;
}
.empty-state i { font-size: 3rem; margin-bottom: 1rem; opacity: 0.4; }
.empty-state p { font-size: 0.95rem; }
