/* ══════════════════════════════════════════════════════════════
   OPEN PROCURE — Platform Theme
   ══════════════════════════════════════════════════════════════ */

:root {
  --primary: #1a56db;
  --primary-dark: #1e40af;
  --primary-light: #dbeafe;
  --secondary: #059669;
  --secondary-light: #d1fae5;
  --accent: #f59e0b;
  --accent-light: #fef3c7;
  --danger: #dc2626;
  --danger-light: #fee2e2;
  --text: #1f2937;
  --text-light: #6b7280;
  --text-muted: #9ca3af;
  --bg: #f9fafb;
  --bg-white: #ffffff;
  --border: #e5e7eb;
  --border-dark: #d1d5db;
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --radius: 8px;
  --radius-lg: 12px;
  --transition: all 0.2s ease;
}

[data-theme="dark"] {
  --primary: #3b82f6;
  --primary-dark: #2563eb;
  --primary-light: #1e3a5f;
  --text: #f3f4f6;
  --text-light: #d1d5db;
  --text-muted: #9ca3af;
  --bg: #111827;
  --bg-white: #1f2937;
  --border: #374151;
  --border-dark: #4b5563;
  --shadow: 0 1px 3px rgba(0,0,0,0.3);
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ── Navigation ── */
.nav {
  background: var(--bg-white);
  border-bottom: 1px solid var(--border);
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow);
}

.nav-brand {
  font-size: 20px;
  font-weight: 700;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-brand span { color: var(--text); }

.nav-links {
  display: flex;
  align-items: center;
  gap: 6px;
  list-style: none;
}

.nav-links a {
  padding: 8px 14px;
  border-radius: var(--radius);
  color: var(--text-light);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
}

.nav-links a:hover, .nav-links a.active {
  background: var(--primary-light);
  color: var(--primary);
  text-decoration: none;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--text);
}

.nav-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; color: white; }
.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover { background: #047857; }
.btn-outline { background: transparent; border-color: var(--border-dark); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; }
.btn-ghost { background: transparent; color: var(--text-light); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-sm { padding: 4px 10px; font-size: 13px; }
.btn-lg { padding: 12px 24px; font-size: 16px; }
.btn-block { width: 100%; justify-content: center; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Cards ── */
.card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  box-shadow: var(--shadow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.card-title { font-size: 16px; font-weight: 600; }

/* ── Forms ── */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-light);
  margin-bottom: 4px;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border-dark);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  background: var(--bg-white);
  transition: var(--transition);
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,0.1);
}

.form-textarea { min-height: 80px; resize: vertical; }

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

/* ── Tables ── */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

th {
  text-align: left;
  padding: 10px 12px;
  background: var(--bg);
  border-bottom: 2px solid var(--border);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-light);
  white-space: nowrap;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

tr:hover td { background: rgba(26,86,219,0.02); }

/* ── Badges ── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 500;
}

.badge-primary { background: var(--primary-light); color: var(--primary); }
.badge-success { background: var(--secondary-light); color: var(--secondary); }
.badge-warning { background: var(--accent-light); color: #92400e; }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-gray { background: #f3f4f6; color: var(--text-light); }

/* ── Status Badges ── */
.status { padding: 3px 10px; border-radius: 9999px; font-size: 12px; font-weight: 500; }
.status-pending { background: #fef3c7; color: #92400e; }
.status-quoted, .status-negotiating { background: #dbeafe; color: #1e40af; }
.status-accepted, .status-po_issued { background: #d1fae5; color: #065f46; }
.status-advance_paid, .status-in_progress { background: #e0e7ff; color: #3730a3; }
.status-invoiced, .status-dispatched { background: #fce7f3; color: #9d174d; }
.status-delivered, .status-qc_approved { background: #d1fae5; color: #065f46; }
.status-completed { background: #065f46; color: white; }
.status-cancelled { background: #f3f4f6; color: #6b7280; }
.status-disputed, .status-payment_disputed { background: #fee2e2; color: #991b1b; }
.status-verified { background: #d1fae5; color: #065f46; }
.status-unverified { background: #f3f4f6; color: #6b7280; }
.status-pending_review { background: #fef3c7; color: #92400e; }

/* RFQ Status Badges */
.status-draft { background: #f3f4f6; color: #6b7280; }
.status-published { background: #dbeafe; color: #1e40af; }
.status-quoting { background: #fef3c7; color: #92400e; }
.status-evaluation { background: #e0e7ff; color: #3730a3; }
.status-awarded { background: #d1fae5; color: #065f46; }
.status-closed { background: #f3f4f6; color: #6b7280; }

/* RFQ Invitation Status */
.status-invited { background: #dbeafe; color: #1e40af; }
.status-viewed { background: #fef3c7; color: #92400e; }
.status-responded { background: #d1fae5; color: #065f46; }
.status-declined { background: #fee2e2; color: #991b1b; }
.status-submitted { background: #dbeafe; color: #1e40af; }
.status-shortlisted { background: #e0e7ff; color: #3730a3; }
.status-rejected { background: #fee2e2; color: #991b1b; }

/* Quote Comparison Table */
.compare-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.compare-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.compare-table th { background: var(--bg); padding: 12px; border-bottom: 2px solid var(--border); font-size: 13px; }
.compare-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); }
.compare-table tr:hover td { background: rgba(26,86,219,0.02); }

/* Supplier Chips */
.supplier-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 9999px;
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
}

/* ── Layout ── */
.container { max-width: 1200px; margin: 0 auto; padding: 24px; }
.container-lg { max-width: 1400px; margin: 0 auto; padding: 24px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-gap { gap: 12px; }

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 13px; }
.text-lg { font-size: 18px; }
.text-xl { font-size: 24px; font-weight: 700; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }

/* ── Stats ── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  text-align: center;
}

.stat-value { font-size: 28px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--text-light); margin-top: 4px; }

/* ── Dashboard Layout ── */
.dashboard {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: calc(100vh - 64px);
}

.sidebar {
  background: var(--bg-white);
  border-right: 1px solid var(--border);
  padding: 16px 0;
}

.sidebar-nav { list-style: none; }

.sidebar-nav li a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--text-light);
  font-size: 14px;
  font-weight: 500;
  transition: var(--transition);
  border-left: 3px solid transparent;
}

.sidebar-nav li a:hover, .sidebar-nav li a.active {
  background: var(--primary-light);
  color: var(--primary);
  border-left-color: var(--primary);
  text-decoration: none;
}

.dash-content { padding: 24px; overflow-y: auto; }

/* ── Modal ── */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 20px;
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--bg-white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

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

.modal-title { font-size: 18px; font-weight: 600; }
.modal-close { background: none; border: none; font-size: 24px; cursor: pointer; color: var(--text-light); padding: 4px; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ── Toast ── */
.toast-container {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  animation: slideIn 0.3s ease;
  max-width: 400px;
}

.toast-success { background: #065f46; color: white; }
.toast-error { background: var(--danger); color: white; }
.toast-info { background: var(--primary); color: white; }

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

/* ── Tabs ── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
}

.tab {
  padding: 10px 20px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-light);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: var(--transition);
}

.tab:hover { color: var(--text); }
.tab.active { color: var(--primary); border-bottom-color: var(--primary); }

/* ── Product Cards ── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.product-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: var(--transition);
}

.product-card:hover { box-shadow: var(--shadow-md); transform: translateY(-2px); }

.product-card-img {
  width: 100%;
  height: 180px;
  object-fit: cover;
  display: block;
}

.product-card-placeholder {
  width: 100%;
  height: 180px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary-light) 0%, #e0e7ff 100%);
  font-size: 48px;
  font-weight: 700;
  color: var(--primary);
  user-select: none;
}

.product-detail-img {
  width: 100%;
  max-height: 300px;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 16px;
}

.product-card-body { padding: 16px; }
.product-card-name { font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.product-card-supplier { font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.product-card-price { font-size: 16px; font-weight: 700; color: var(--primary); }
.product-card-specs { font-size: 13px; color: var(--text-light); margin: 8px 0; }
.product-card-footer { display: flex; justify-content: space-between; align-items: center; margin-top: 12px; }

/* ── Supplier Cards ── */
.supplier-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  transition: var(--transition);
}

.supplier-card:hover { box-shadow: var(--shadow-md); }

.supplier-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }

.supplier-logo {
  width: 48px; height: 48px;
  border-radius: var(--radius);
  background: var(--primary-light);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: var(--primary);
}

.supplier-card-name { font-size: 16px; font-weight: 600; }
.supplier-card-meta { font-size: 12px; color: var(--text-muted); }

.rating-stars { color: var(--accent); font-size: 14px; }

/* ── Pagination ── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 24px;
}

.pagination button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--bg-white);
  border-radius: var(--radius);
  font-size: 13px;
  cursor: pointer;
}

.pagination button.active { background: var(--primary); color: white; border-color: var(--primary); }
.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Message Thread ── */
.message-thread { max-height: 400px; overflow-y: auto; padding: 12px 0; }

.message {
  padding: 12px 16px;
  margin-bottom: 8px;
  border-radius: var(--radius);
  font-size: 14px;
}

.message-buyer { background: var(--primary-light); margin-right: 40px; }
.message-supplier { background: #f3f4f6; margin-left: 40px; }
.message-system { background: var(--accent-light); text-align: center; font-size: 13px; }

.message-header { display: flex; justify-content: space-between; margin-bottom: 4px; }
.message-sender { font-weight: 600; font-size: 13px; }
.message-time { font-size: 11px; color: var(--text-muted); }
.message-price { font-weight: 700; color: var(--primary); font-size: 16px; margin: 4px 0; }

/* ── Filters Bar ── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 20px;
  padding: 12px 16px;
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.filters-bar .form-input, .filters-bar .form-select {
  width: auto;
  min-width: 160px;
}

/* ── Hero Section ── */
.hero {
  background: linear-gradient(135deg, #1e40af 0%, #1a56db 50%, #3b82f6 100%);
  color: white;
  padding: 80px 24px;
  text-align: center;
}

.hero h1 { font-size: 42px; font-weight: 800; margin-bottom: 16px; }
.hero p { font-size: 18px; opacity: 0.9; max-width: 600px; margin: 0 auto 32px; }

.hero-stats {
  display: flex;
  justify-content: center;
  gap: 48px;
  margin-top: 48px;
}

.hero-stat-value { font-size: 32px; font-weight: 700; }
.hero-stat-label { font-size: 14px; opacity: 0.8; }

/* ── Section ── */
.section { padding: 64px 24px; }
.section-title { font-size: 28px; font-weight: 700; text-align: center; margin-bottom: 12px; }
.section-subtitle { font-size: 16px; color: var(--text-light); text-align: center; margin-bottom: 40px; }

/* ── Categories Grid ── */
.categories-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
  max-width: 900px;
  margin: 0 auto;
}

.category-card {
  background: var(--bg-white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px 16px;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
}

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

.category-icon { font-size: 32px; margin-bottom: 8px; }
.category-name { font-size: 14px; font-weight: 600; }

/* ── Footer ── */
.footer {
  background: var(--text);
  color: white;
  padding: 40px 24px;
  font-size: 14px;
}
.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 32px;
  max-width: 960px;
  margin: 0 auto;
}
.footer-grid h4 { font-size: 15px; margin-bottom: 12px; opacity: 0.95; }
.footer-grid p, .footer-grid li { opacity: 0.7; line-height: 1.8; }
.footer-grid ul { list-style: none; padding: 0; margin: 0; }
.footer a { color: var(--primary-light); text-decoration: none; }
.footer a:hover { text-decoration: underline; }
.footer-bottom {
  text-align: center;
  margin-top: 28px;
  padding-top: 20px;
  border-top: 1px solid rgba(255,255,255,0.15);
  opacity: 0.5;
  font-size: 12px;
}
@media (max-width: 640px) {
  .footer-grid { grid-template-columns: 1fr; gap: 24px; }
}

/* ── Notification Bell ── */
.notif-bell {
  position: relative;
  cursor: pointer;
  font-size: 20px;
  color: var(--text-light);
}

.notif-count {
  position: absolute;
  top: -6px; right: -8px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 9999px;
  min-width: 16px;
  text-align: center;
}

/* ── Profile Completion ── */
.progress-bar {
  width: 100%;
  height: 8px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 4px;
  transition: width 0.3s ease;
}

/* ── Responsive ── */
@media (max-width: 768px) {
  .nav { padding: 0 12px; }
  .nav-links { display: none; }
  .dashboard { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .grid-2, .grid-3, .grid-4 { grid-template-columns: 1fr; }
  .hero h1 { font-size: 28px; }
  .hero-stats { flex-direction: column; gap: 16px; }
  .form-row { grid-template-columns: 1fr; }
  .filters-bar { flex-direction: column; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .modal { max-width: 100%; margin: 10px; }
}
