/* Sertsan B2B Customer Portal – Custom Styles */

/* ── Base ──────────────────────────────────────────────────────────────────*/
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: "Inter", system-ui, sans-serif;
  background: #f8fafc;
  color: #1e293b;
  margin: 0;
}

/* ── Sidebar Layout ────────────────────────────────────────────────────────*/
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 240px;
  flex-shrink: 0;
  background: #0f172a;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 50;
}

.sidebar-logo {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-logo img { height: 32px; }
.sidebar-logo .portal-badge {
  font-size: 10px;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 4px;
}

.sidebar nav { flex: 1; padding: 12px 8px; overflow-y: auto; }

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #94a3b8;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
  margin-bottom: 2px;
}

.sidebar nav a:hover { background: rgba(255,255,255,0.06); color: #e2e8f0; }
.sidebar nav a.nav-active { background: #1d4ed8; color: #fff; }
.sidebar nav a .nav-icon { width: 18px; flex-shrink: 0; opacity: 0.8; }

.sidebar-footer {
  padding: 12px 8px;
  border-top: 1px solid rgba(255,255,255,0.08);
}

.sidebar-footer a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: #64748b;
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s;
}
.sidebar-footer a:hover { background: rgba(255,255,255,0.05); color: #94a3b8; }

/* ── Main Content ──────────────────────────────────────────────────────────*/
.main-content {
  margin-left: 240px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ── Top Bar ───────────────────────────────────────────────────────────────*/
.topbar {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 0 24px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 40;
}

.topbar-title { font-size: 18px; font-weight: 600; color: #0f172a; }

.topbar-right { display: flex; align-items: center; gap: 16px; }

.lang-btn {
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  padding: 4px 10px;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  background: none;
  letter-spacing: 0.04em;
  transition: all 0.15s;
}
.lang-btn:hover { background: #f1f5f9; color: #1e293b; }

.user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  background: #f1f5f9;
  border-radius: 20px;
  font-size: 13px;
  color: #475569;
}

.user-pill .avatar {
  width: 28px; height: 28px;
  background: #1d4ed8;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

.notif-btn {
  position: relative;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: #64748b;
  border-radius: 8px;
  transition: background 0.15s;
}
.notif-btn:hover { background: #f1f5f9; }
.notif-badge {
  position: absolute;
  top: 2px; right: 2px;
  background: #ef4444;
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 2px;
}

/* ── Page Body ─────────────────────────────────────────────────────────────*/
.page-body { padding: 24px; flex: 1; }

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

.page-header h1 {
  font-size: 22px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

/* ── Cards ─────────────────────────────────────────────────────────────────*/
.card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 20px;
}

.kpi-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.kpi-card {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.kpi-card .kpi-label { font-size: 12px; color: #64748b; font-weight: 500; }
.kpi-card .kpi-value { font-size: 26px; font-weight: 700; color: #0f172a; }
.kpi-card .kpi-sub { font-size: 12px; color: #94a3b8; }
.kpi-card .kpi-icon { font-size: 22px; margin-bottom: 4px; }

/* ── Tables ────────────────────────────────────────────────────────────────*/
.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
  background: #fff;
}

table.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

table.data-table thead tr { background: #f8fafc; }
table.data-table th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: #475569;
  border-bottom: 1px solid #e2e8f0;
  white-space: nowrap;
}

table.data-table td {
  padding: 10px 14px;
  border-bottom: 1px solid #f1f5f9;
  color: #334155;
  vertical-align: middle;
}

table.data-table tbody tr:last-child td { border-bottom: none; }
table.data-table tbody tr:hover { background: #f8fafc; cursor: pointer; }
table.data-table tbody tr.no-hover:hover { background: none; cursor: default; }

/* ── Badges ────────────────────────────────────────────────────────────────*/
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.badge-green { background: #dcfce7; color: #166534; }
.badge-yellow { background: #fef9c3; color: #854d0e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-blue { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f1f5f9; color: #475569; }
.badge-purple { background: #f3e8ff; color: #6b21a8; }

/* ── Buttons ───────────────────────────────────────────────────────────────*/
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: #1d4ed8; color: #fff; }
.btn-primary:hover:not(:disabled) { background: #1e40af; }
.btn-secondary { background: #f1f5f9; color: #475569; border: 1px solid #e2e8f0; }
.btn-secondary:hover:not(:disabled) { background: #e2e8f0; }
.btn-danger { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.btn-danger:hover:not(:disabled) { background: #fee2e2; }
.btn-success { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.btn-success:hover:not(:disabled) { background: #dcfce7; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-icon {
  background: none;
  border: none;
  cursor: pointer;
  padding: 5px;
  border-radius: 6px;
  color: #64748b;
  transition: background 0.15s, color 0.15s;
  display: inline-flex;
  align-items: center;
}
.btn-icon:hover { background: #f1f5f9; color: #0f172a; }
.btn-icon.danger:hover { background: #fef2f2; color: #dc2626; }

/* ── Form Elements ─────────────────────────────────────────────────────────*/
.form-group { display: flex; flex-direction: column; gap: 4px; margin-bottom: 14px; }
.form-label { font-size: 13px; font-weight: 600; color: #374151; }
.form-label.required::after { content: " *"; color: #ef4444; }

.form-input, .form-select, .form-textarea {
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  font-size: 14px;
  font-family: inherit;
  background: #fff;
  color: #0f172a;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: #1d4ed8;
  box-shadow: 0 0 0 3px rgba(29,78,216,0.1);
}

.form-input::placeholder { color: #9ca3af; }
.form-textarea { resize: vertical; min-height: 80px; }

.form-row { display: flex; gap: 14px; }
.form-row .form-group { flex: 1; }

/* ── Filter Bar ────────────────────────────────────────────────────────────*/
.filter-bar {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 12px 16px;
}

.filter-bar .form-input, .filter-bar .form-select {
  flex: 1;
  min-width: 140px;
  max-width: 220px;
  margin-bottom: 0;
}

/* ── Drawer / Modal ────────────────────────────────────────────────────────*/
.overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,0.4);
  z-index: 100;
  backdrop-filter: blur(1px);
}
.overlay.active { display: flex; align-items: flex-start; justify-content: flex-end; }
.overlay.center { align-items: center; justify-content: center; }

.drawer {
  background: #fff;
  width: 640px;
  max-width: 96vw;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  box-shadow: -8px 0 32px rgba(0,0,0,0.12);
}

.modal {
  background: #fff;
  border-radius: 14px;
  width: 520px;
  max-width: 95vw;
  max-height: 92vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
}

.drawer-header, .modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 24px;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 10;
}

.drawer-header h2, .modal-header h2 {
  font-size: 16px;
  font-weight: 700;
  color: #0f172a;
  margin: 0;
}

.drawer-body, .modal-body { padding: 24px; flex: 1; }
.modal-footer { padding: 16px 24px; border-top: 1px solid #e2e8f0; display: flex; gap: 10px; justify-content: flex-end; }
.btn-close { background: none; border: none; cursor: pointer; padding: 4px; color: #64748b; border-radius: 6px; font-size: 18px; }
.btn-close:hover { background: #f1f5f9; }

/* ── Tabs ──────────────────────────────────────────────────────────────────*/
.tabs { display: flex; gap: 4px; border-bottom: 2px solid #e2e8f0; margin-bottom: 20px; }
.tab-btn {
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  color: #64748b;
  cursor: pointer;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.15s;
}
.tab-btn:hover { color: #0f172a; }
.tab-btn.active { color: #1d4ed8; border-bottom-color: #1d4ed8; }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Order Create Table ────────────────────────────────────────────────────*/
.order-table-wrap { overflow-x: auto; }
table.order-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
  min-width: 900px;
}
table.order-table th {
  background: #f8fafc;
  padding: 8px 8px;
  border: 1px solid #e2e8f0;
  font-weight: 600;
  color: #475569;
  white-space: nowrap;
  text-align: left;
}
table.order-table td {
  border: 1px solid #e2e8f0;
  padding: 4px 5px;
  vertical-align: middle;
}
table.order-table td input, table.order-table td select {
  border: none;
  background: transparent;
  padding: 5px 6px;
  font-family: inherit;
  font-size: 12.5px;
  width: 100%;
  color: #0f172a;
  outline: none;
}
table.order-table td input:focus { background: #f0f9ff; }
table.order-table tfoot td {
  padding: 8px;
  font-weight: 600;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
}

/* ── Timeline ──────────────────────────────────────────────────────────────*/
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-step { display: flex; gap: 14px; padding-bottom: 20px; position: relative; }
.timeline-step:last-child { padding-bottom: 0; }
.timeline-line {
  display: flex; flex-direction: column; align-items: center;
}
.timeline-dot {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #1d4ed8;
  flex-shrink: 0;
  margin-top: 2px;
}
.timeline-dot.done { background: #16a34a; }
.timeline-dot.pending { background: #d1d5db; }
.timeline-connector {
  flex: 1;
  width: 2px;
  background: #e2e8f0;
  margin-top: 4px;
}
.timeline-content { flex: 1; }
.timeline-content .tl-title { font-size: 13px; font-weight: 600; color: #0f172a; }
.timeline-content .tl-date { font-size: 12px; color: #64748b; margin-top: 2px; }
.timeline-content .tl-note { font-size: 12px; color: #94a3b8; margin-top: 2px; }

/* ── Progress Bar ──────────────────────────────────────────────────────────*/
.progress-bar-wrap { background: #e2e8f0; border-radius: 8px; height: 8px; overflow: hidden; }
.progress-bar-fill { height: 100%; background: #1d4ed8; border-radius: 8px; transition: width 0.3s; }
.progress-bar-fill.done { background: #16a34a; }

/* ── Search Dropdown ───────────────────────────────────────────────────────*/
.search-dropdown {
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  z-index: 200;
  max-height: 220px;
  overflow-y: auto;
}
.search-dropdown-item {
  padding: 8px 12px;
  cursor: pointer;
  border-bottom: 1px solid #f1f5f9;
  transition: background 0.1s;
}
.search-dropdown-item:hover { background: #f0f7ff; }
.search-dropdown-item:last-child { border-bottom: none; }
.search-dropdown-item .prod-code { font-weight: 600; color: #0f172a; font-size: 13px; }
.search-dropdown-item .prod-name { font-size: 12px; color: #64748b; }

/* ── Login Page ────────────────────────────────────────────────────────────*/
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 36px 40px;
  width: 400px;
  max-width: 100%;
  box-shadow: 0 24px 60px rgba(0,0,0,0.25);
}

.login-logo { text-align: center; margin-bottom: 24px; }
.login-logo img { height: 40px; }
.login-logo .sub { font-size: 12px; color: #64748b; margin-top: 6px; letter-spacing: 0.06em; text-transform: uppercase; font-weight: 600; }

.login-title { font-size: 20px; font-weight: 700; color: #0f172a; margin: 0 0 4px; }
.login-subtitle { font-size: 13px; color: #64748b; margin: 0 0 24px; }

.alert {
  padding: 10px 14px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 14px;
}
.alert-error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.alert-success { background: #f0fdf4; color: #16a34a; border: 1px solid #bbf7d0; }
.alert-info { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }

/* ── Toast ─────────────────────────────────────────────────────────────────*/
.toast {
  position: fixed;
  bottom: 24px; right: 24px;
  background: #0f172a;
  color: #fff;
  padding: 12px 20px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.25s, transform 0.25s;
  z-index: 9999;
  max-width: 360px;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.toast-error { background: #dc2626; }
.toast.toast-success { background: #16a34a; }

/* ── Misc ──────────────────────────────────────────────────────────────────*/
.divider { height: 1px; background: #e2e8f0; margin: 16px 0; }
.empty-state { text-align: center; padding: 40px 20px; color: #94a3b8; font-size: 14px; }
.empty-state .empty-icon { font-size: 40px; margin-bottom: 10px; }
.loading { text-align: center; padding: 32px; color: #94a3b8; font-size: 24px; }

.section-title { font-size: 14px; font-weight: 700; color: #0f172a; margin: 0 0 14px; }

.info-row { display: flex; gap: 8px; margin-bottom: 8px; font-size: 13px; }
.info-row .info-lbl { color: #64748b; font-weight: 500; min-width: 160px; flex-shrink: 0; }
.info-row .info-val { color: #0f172a; font-weight: 600; }

/* Responsive */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-240px); transition: transform 0.25s; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .kpi-grid { grid-template-columns: 1fr 1fr; }
}

@media print {
  .sidebar, .topbar, .filter-bar, .btn { display: none !important; }
  .main-content { margin-left: 0; }
}
