/* backend/assets/styles/console.css */
/* Procurement console layout — sidebar + main */

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

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  height: 100%;
}

a { color: var(--primary); }
a:hover { color: var(--primary-hover); }

/* ── App shell ──────────────────────────────────────────────── */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────── */
.sidebar {
  width: 220px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

.sidebar-brand {
  padding: 20px 20px 12px;
  font-size: 16px;
  font-weight: 700;
  color: var(--primary);
  text-decoration: none;
  display: block;
  border-bottom: 1px solid var(--sidebar-border);
  margin-bottom: 8px;
}

.sidebar-section {
  padding: 8px 12px 4px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
}

.sidebar .nav-link {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  text-decoration: none;
  color: var(--text);
  font-size: 13px;
  border-radius: 4px;
  margin: 1px 8px;
  transition: background .15s, color .15s;
}

.sidebar .nav-link:hover,
.sidebar .nav-link.active {
  background: var(--nav-active-bg);
  color: var(--nav-active-text);
}

.sidebar .nav-link .icon { font-size: 15px; width: 18px; text-align: center; }
.sidebar .nav-count {
  margin-left: auto;
  background: var(--primary);
  color: #fff;
  font-size: 10px;
  border-radius: 10px;
  padding: 1px 6px;
}

.sidebar-footer {
  margin-top: auto;
  padding: 12px;
  border-top: 1px solid var(--sidebar-border);
}

.sidebar-user {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user strong { display: block; color: var(--text); }

/* ── Main content ───────────────────────────────────────────── */
.console-main {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.console-header {
  background: var(--card);
  border-bottom: 1px solid var(--border);
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-shrink: 0;
  position: sticky; top: 0; z-index: 3000;
}

.console-header h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.notify-wrap { position: relative; margin-right: 10px; }
.notify-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  cursor: pointer;
  color: var(--text);
  font-size: 17px;
}
.notify-btn:hover { color: var(--primary); }
.notify-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #dc3545;
  color: #fff;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  font-weight: 700;
}
.notify-popover {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  width: 360px;
  max-width: calc(100vw - 32px);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 12px 28px rgba(0, 0, 0, .18);
  z-index: 3100;
}
.notify-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
}
.notify-list {
  max-height: 420px;
  overflow: auto;
}
.notify-item {
  display: block;
  padding: 10px 12px;
  text-decoration: none;
  color: var(--text);
  background: #f2f4f7;
  border-bottom: 1px solid var(--border);
}
.notify-item:last-child { border-bottom: none; }
.notify-item:hover { background: var(--table-row-hover); }
.notify-item.unread { background: #fff; }
.notify-item-title { font-weight: 600; font-size: 13px; margin-bottom: 3px; }
.notify-item-summary { font-size: 12px; color: var(--text-muted); margin-bottom: 3px; }
.notify-item-time { font-size: 11px; color: var(--text-muted); }

.console-body {
  padding: 24px;
  flex: 1;
}

/* ── Reuse from app.css ─────────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

.card-header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-body { padding: 20px; }

.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  transition: background .15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary { background: var(--primary); color: var(--primary-contrast); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); }
.btn-outline { background: transparent; color: var(--primary); border-color: var(--primary); }
.btn-outline:hover { background: var(--nav-active-bg); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-danger { background: #dc3545; color: #fff; border-color: #dc3545; }
.btn-secondary { background: #6c757d; color: #fff; border-color: #6c757d; }
.btn-success { background: #198754; color: #fff; border-color: #198754; }
.btn-warning { background: #ffc107; color: #000; border-color: #ffc107; }

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

.data-table th,
.data-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table thead th {
  background: var(--table-header-bg);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .4px;
  position: sticky; top: 0;
}

.data-table tbody tr:hover { background: var(--table-row-hover); }
.data-table td.wrap { white-space: normal; }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.badge-Draft       { background: #6c757d22; color: #6c757d; }
.badge-Submitted   { background: #0d6efd22; color: #0d6efd; }
.badge-Approved    { background: #19875422; color: #198754; }
.badge-Rejected    { background: #dc354522; color: #dc3545; }
.badge-Split       { background: #0dcaf022; color: #0077a0; }
.badge-InProgress  { background: #fd7e1422; color: #c95400; }
.badge-Completed   { background: #19875422; color: #198754; }
.badge-Cancelled   { background: #adb5bd22; color: #6c757d; }
.badge-Exception   { background: #dc354522; color: #dc3545; }
.badge-Open        { background: #0d6efd22; color: #0d6efd; }
.badge-Sourcing    { background: #6f42c122; color: #6f42c1; }
.badge-Quoted      { background: #20c99722; color: #0e7a5a; }
.badge-Purchased   { background: #fd7e1422; color: #c95400; }
.badge-Paid        { background: #19875422; color: #198754; }
.badge-Exporting   { background: #0dcaf022; color: #0077a0; }
.badge-InTransit   { background: #0d6efd22; color: #0d6efd; }
.badge-Arrived     { background: #19875422; color: #198754; }
.badge-Received    { background: #19875422; color: #198754; }
.badge-Closed      { background: #adb5bd22; color: #6c757d; }
.badge-active      { background: #19875422; color: #198754; }
.badge-disabled    { background: #dc354522; color: #dc3545; }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; margin-bottom: 4px; }
.form-control {
  width: 100%;
  padding: 7px 11px;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--bg-2);
  color: var(--text);
  transition: border-color .15s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(13,110,253,.15); }

.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 16px;
}
.filter-bar .form-control { width: auto; min-width: 140px; }

.pagination {
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 16px;
}
.page-btn {
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: var(--card);
  color: var(--text);
  cursor: pointer;
  font-size: 13px;
}
.page-btn:hover { background: var(--table-row-hover); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: .4; cursor: default; }

#toast-container {
  position: fixed; top: 16px; right: 16px; z-index: 9999;
  display: flex; flex-direction: column; gap: 8px; max-width: 360px;
}
.toast {
  background: #f8f9fa; border: 1px solid transparent; border-radius: .5rem;
  padding: 12px 16px; box-shadow: 0 .5rem 1rem rgba(0,0,0,.12);
  font-size: 13px; display: flex; align-items: flex-start; gap: 10px;
  animation: slide-in .2s ease;
}
.toast-success { color:#0f5132; background:#d1e7dd; border-color:#badbcc; }
.toast-error   { color:#842029; background:#f8d7da; border-color:#f5c2c7; }
.toast-info    { color:#055160; background:#cff4fc; border-color:#b6effb; }
.toast-warning { color:#664d03; background:#fff3cd; border-color:#ffecb5; }
@keyframes slide-in { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }

.spinner {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }

.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45);
  display: flex; align-items: center; justify-content: center; z-index: 3200; padding: 16px;
}
.modal-box {
  background: var(--card); border-radius: 8px;
  box-shadow: 0 4px 24px rgba(0,0,0,.2); width: 100%;
  max-width: 520px; max-height: 90vh; overflow-y: auto;
}
.modal-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; justify-content: space-between; align-items: center; font-weight: 600; }
.modal-body { padding: 20px; }
.modal-footer { padding: 12px 20px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }
.btn-close-modal { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); }

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px 24px; margin-bottom: 20px;
}
.detail-label { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: var(--text-muted); margin-bottom: 2px; }
.detail-value { font-size: 14px; font-weight: 500; }

.timeline { list-style: none; padding: 0; margin: 0; }
.timeline-item { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--border); }
.timeline-item:last-child { border-bottom: none; }
.timeline-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--nav-active-bg); color: var(--nav-active-text); display: flex; align-items: center; justify-content: center; font-size: 12px; font-weight: 700; flex-shrink: 0; }
.timeline-body .author { font-weight: 600; font-size: 13px; }
.timeline-body .time { font-size: 11px; color: var(--text-muted); margin-left: 8px; }
.timeline-body .content { font-size: 13px; }

/* ── Sub-order layout ───────────────────────────────────────── */
.suborder-layout {
  display: grid;
  grid-template-columns: 1fr 1.2fr;
  gap: 20px;
}

/* ── Security page ─────────────────────────────────────────── */
.security-map-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}
.security-map {
  width: 100%;
  height: 420px;
}
.security-country-picker {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  background: var(--bg-2);
}
.security-country-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}
.security-country-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 30px;
  margin-bottom: 8px;
}
.security-blocked-input {
  min-height: 64px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 6px;
  padding-top: 8px;
  padding-bottom: 8px;
}
.security-country-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #b91c1c;
  border-radius: 999px;
  font-size: 12px;
}
.security-country-tag button {
  border: none;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
}
.security-country-options {
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
}
.security-country-option {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
}
.security-country-option:last-child {
  border-bottom: none;
}

@media (max-width: 1200px) {
  .security-map-grid {
    grid-template-columns: 1fr;
  }
  .security-map {
    height: 360px;
  }
  .security-country-controls {
    flex-direction: column;
  }
}

@media (max-width: 900px) {
  .app-shell { flex-direction: column; }
  .sidebar { width: 100%; flex-direction: row; flex-wrap: wrap; }
  .suborder-layout { grid-template-columns: 1fr; }
  .console-body { padding: 16px; }
}
