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

:root {
  --primary-gradient: linear-gradient(135deg, #00b4db, #0083b0);
  --primary-color: #0083b0;
  --secondary-color: #00b4db;
  --bg-color: #f0f4f8;
  --text-color: #1e293b;
  --border-color: #e2e8f0;
  --card-bg: #ffffff;
  --danger-color: #ef4444;
  --success-color: #10b981;
  --font-family: 'Outfit', 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  --shadow-soft: 0 10px 25px -5px rgba(0,0,0,0.05), 0 8px 10px -6px rgba(0,0,0,0.01);
  --shadow-hover: 0 20px 25px -5px rgba(0,0,0,0.1), 0 10px 10px -5px rgba(0,0,0,0.04);
}

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

body {
  background-color: var(--bg-color);
  color: var(--text-color);
  display: flex;
  height: 100vh;
  overflow-x: hidden;
}

/* Auth Pages */
.auth-container {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  width: 100%;
  background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
}

.auth-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  padding: 40px;
  border-radius: 20px;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
  width: 400px;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.2);
}

.auth-card h2 {
  margin-bottom: 25px;
  color: var(--text-color);
  font-size: 28px;
  font-weight: 700;
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.form-group {
  margin-bottom: 20px;
  text-align: left;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 14px;
  color: #475569;
}

.form-control {
  width: 100%;
  padding: 12px 15px;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  font-size: 15px;
  background-color: #f8fafc;
  transition: all 0.3s ease;
}

.form-control:focus {
  background-color: #ffffff;
  border-color: var(--secondary-color);
  box-shadow: 0 0 0 4px rgba(0, 180, 219, 0.15);
  outline: none;
}

.btn {
  display: inline-block;
  padding: 12px 20px;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  transition: all 0.3s ease;
  color: white;
  letter-spacing: 0.3px;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1);
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0,0,0,0.15);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary { background: var(--primary-gradient); width: 100%; }
.btn-success { background: linear-gradient(135deg, #10b981, #059669); }
.btn-danger { background: linear-gradient(135deg, #ef4444, #dc2626); }

/* Layout */
.sidebar {
  width: 260px;
  background: linear-gradient(180deg, #0f172a 0%, #1e293b 100%);
  color: white;
  display: flex;
  flex-direction: column;
  box-shadow: 4px 0 25px rgba(0,0,0,0.1);
  z-index: 100;
}

.sidebar-header {
  padding: 25px 20px;
  text-align: center;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  font-weight: 700;
  font-size: 22px;
  color: #38bdf8;
  letter-spacing: 0.5px;
}

.nav-menu {
  flex: 1;
  padding: 20px 10px;
}

.nav-item {
  padding: 15px 20px;
  margin-bottom: 8px;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  color: #94a3b8;
  font-weight: 500;
}

.nav-item:hover {
  background: rgba(255,255,255,0.05);
  color: #ffffff;
  transform: translateX(5px);
}

.nav-item.active {
  background: var(--primary-gradient);
  color: white;
  box-shadow: 0 4px 15px rgba(0, 180, 219, 0.4);
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  background: rgba(255, 255, 255, 0.85);
  backdrop-filter: blur(12px);
  padding: 15px 30px;
  border-bottom: 1px solid rgba(0,0,0,0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 50;
}

#page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-color);
}

.page-container {
  padding: 30px;
  overflow-y: auto;
  flex: 1;
}

.card {
  background: var(--card-bg);
  border-radius: 20px;
  padding: 30px;
  box-shadow: var(--shadow-soft);
  margin-bottom: 30px;
  border: none;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 25px;
}

/* Tables */
.table-responsive {
  overflow-x: auto;
  width: 100%;
  border-radius: 12px;
}

table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

table th, table td {
  padding: 16px 15px;
  text-align: left;
  border-bottom: 1px solid #f1f5f9;
}

table th {
  background: #f8fafc;
  font-weight: 700;
  color: #64748b;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

table th:first-child { border-top-left-radius: 12px; border-bottom-left-radius: 12px; }
table th:last-child { border-top-right-radius: 12px; border-bottom-right-radius: 12px; }

table tbody tr {
  transition: all 0.2s ease;
}

table tbody tr:hover {
  background: #f8fafc;
  transform: scale(1.005);
  box-shadow: 0 2px 10px rgba(0,0,0,0.02);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.modal-overlay.show {
  opacity: 1;
}

.modal-content {
  background: white;
  width: 550px;
  border-radius: 20px;
  overflow: hidden;
  max-width: 90%;
  box-shadow: 0 25px 50px -12px rgba(0,0,0,0.5);
  transform: scale(0.9);
  transition: transform 0.3s ease;
}

.modal-overlay.show .modal-content {
  transform: scale(1);
}

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

.modal-header h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-color);
}

.modal-body {
  padding: 30px 25px;
  max-height: 70vh;
  overflow-y: auto;
}

.modal-footer {
  padding: 20px 25px;
  border-top: 1px solid var(--border-color);
  text-align: right;
  background: #f8fafc;
}

/* Utils */
.d-none { display: none !important; }
.text-right { text-align: right; }
.mb-3 { margin-bottom: 20px; }
.d-flex { display: flex; }
.gap-2 { gap: 15px; }

/* Notification Toast */
#toast-container {
  position: fixed;
  bottom: 30px;
  right: 30px;
  z-index: 1100;
}

.toast {
  background: #1e293b;
  color: white;
  padding: 16px 30px;
  border-radius: 12px;
  margin-top: 15px;
  box-shadow: 0 10px 25px -5px rgba(0,0,0,0.2);
  transition: opacity 0.3s ease, transform 0.3s ease;
  font-weight: 500;
  display: flex;
  align-items: center;
  transform: translateX(100%);
  opacity: 0;
  animation: slideIn 0.3s forwards;
}

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

/* Quote Layout */
.quote-layout {
  display: flex;
  gap: 30px;
  height: calc(100vh - 120px);
}

.quote-sidebar {
  width: 380px;
  background: transparent;
  overflow-y: auto;
  padding-right: 10px;
}

.quote-sidebar::-webkit-scrollbar { width: 6px; }
.quote-sidebar::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.quote-sidebar-box {
  background: #ffffff;
  border: 1px solid #f1f5f9;
  border-radius: 16px;
  padding: 25px;
  margin-bottom: 25px;
  box-shadow: 0 4px 6px -1px rgba(0,0,0,0.02);
}

.quote-sidebar-box h4 {
  margin-top: 0;
  margin-bottom: 20px;
  font-size: 15px;
  color: var(--primary-color);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  border-bottom: 2px solid #f1f5f9;
  padding-bottom: 12px;
}

.quote-preview {
  flex: 1;
  background: #ffffff;
  border-radius: 20px;
  padding: 30px;
  box-shadow: var(--shadow-soft);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.quote-toolbar {
  width: 100%;
  max-width: 800px;
  display: flex;
  gap: 15px;
  margin-bottom: 30px;
  background: #f8fafc;
  padding: 15px;
  border-radius: 16px;
  justify-content: flex-end;
  flex-wrap: wrap;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}

.a4-sheet {
  background: white;
  width: 210mm;
  min-height: 297mm;
  padding: 20mm;
  box-shadow: 0 10px 40px rgba(0,0,0,0.08);
  border: 1px solid #e2e8f0;
  margin-bottom: 20px;
  font-family: "Times New Roman", Times, serif;
  color: #000;
  box-sizing: border-box;
}

.a4-header {
  border-bottom: 2px solid #0056b3;
  padding-bottom: 15px;
  margin-bottom: 25px;
  display: flex;
  align-items: center;
}

.a4-header-info { flex: 1; }
.a4-header-info h2 { margin: 0 0 8px 0; color: red; font-size: 26px; }
.a4-header-info p { margin: 3px 0; font-size: 14px; }

.a4-title { text-align: center; margin: 35px 0; }
.a4-title h1 { margin: 0 0 10px 0; color: #0099ff; font-size: 30px; }
.a4-title p { margin: 0; font-size: 15px; color: #555; }

.a4-customer-info {
  background: #f9f9f9;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 25px;
  font-size: 15px;
  border: 1px solid #eee;
}
.a4-customer-info div { margin-bottom: 8px; display: flex; }
.a4-customer-info div strong { width: 120px; }

.a4-table { width: 100%; border-collapse: collapse; margin-bottom: 25px; font-size: 15px; }
.a4-table th, .a4-table td { border: 1px solid #ddd; padding: 10px; }
.a4-table th { background: #f2f2f2; text-align: center; font-weight: bold; }

.a4-total { text-align: right; font-size: 17px; margin-top: 25px; }
.a4-total strong { color: red; font-size: 22px; }

@media print {
  @page { margin: 10mm; size: auto; }
  html, body {
    height: auto !important;
    min-height: auto !important;
    display: block !important;
    margin: 0 !important;
    padding: 0 !important;
    background: white !important;
    overflow: visible !important;
  }
  .a4-sheet {
    width: 100% !important;
    min-height: 0 !important;
    height: auto !important;
    padding: 0 !important;
    margin: 0 !important;
    box-shadow: none !important;
    border: none !important;
    overflow: hidden !important;
  }
  .a4-header { border-bottom: 2px solid #0056b3; }
}

/* RESPONSIVE MOBILE */
.mobile-menu-btn { display: none; }
.sidebar-overlay { display: none; }
.btn-sm { padding: 8px 12px; font-size: 13px; }

@media (max-width: 768px) {
  .mobile-menu-btn {
    display: inline-block;
    font-size: 28px;
    background: none;
    border: none;
    cursor: pointer;
    margin-right: 15px;
    color: #1e293b;
  }
  .sidebar {
    position: fixed;
    top: 0; left: -280px;
    height: 100vh; width: 280px;
    z-index: 1050;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  }
  .sidebar.show { left: 0; }
  .sidebar-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1040;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
  }
  .sidebar-overlay.show { display: block; opacity: 1; }
  .topbar { flex-direction: column; align-items: flex-start; padding: 15px; }
  .topbar-right {
    width: 100%; display: flex; flex-wrap: wrap; gap: 10px; justify-content: flex-start; margin-top: 15px;
  }
  .quote-layout { flex-direction: column; height: auto; }
  .quote-sidebar, .quote-preview { width: 100%; padding: 0; }
  .quote-preview { display: block; padding: 15px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .a4-sheet { margin: 15px auto; }
  .quote-toolbar { flex-wrap: wrap; justify-content: center; background: transparent; padding: 0; box-shadow: none; margin-bottom: 15px; }
  .quote-toolbar .btn { flex: 1; min-width: 45%; text-align: center; }
  .table-responsive { overflow-x: auto; width: 100%; }
  
  /* Mobile Stacked Table */
  table.mobile-stacked { border: 0; }
  table.mobile-stacked thead { display: none; }
  table.mobile-stacked tr {
    display: block;
    margin-bottom: 15px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
    background: #fff;
    padding: 10px;
  }
  table.mobile-stacked td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f1f5f9;
    padding: 10px 5px;
    text-align: right;
  }
  table.mobile-stacked td:last-child { border-bottom: 0; }
  table.mobile-stacked td::before {
    content: attr(data-label);
    font-weight: bold;
    color: #64748b;
    text-align: left;
    margin-right: 15px;
    flex-shrink: 0;
  }
  
  .card-header { flex-direction: column; gap: 15px; align-items: flex-start; }
  .modal-content { width: 95%; margin: 20px; padding: 0; }
  .page-container { padding: 15px; }
  .card { padding: 20px; }
}
