/* Movira AP – Custom Styles */
:root {
  --brand-600: #2563eb;
  --brand-700: #1d4ed8;
  --brand-50: #eff6ff;
}

* { box-sizing: border-box; }

body { font-family: 'Inter', system-ui, -apple-system, sans-serif; }

/* ── Layout ───────────────────────────────────────── */
#app { min-height: 100vh; }

.sidebar {
  width: 240px;
  min-height: 100vh;
  background: #0f172a;
  color: #e2e8f0;
  flex-shrink: 0;
  transition: width 0.2s;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 40;
  overflow-y: auto;
}

.main-content {
  margin-left: 240px;
  min-height: 100vh;
  transition: margin-left 0.2s;
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); width: 240px; }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
}

.sidebar-logo {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #1e293b;
  display: flex; align-items: center; gap: 0.75rem;
}

.sidebar-logo .logo-icon {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; color: white; font-size: 14px;
}

.sidebar-logo .logo-text { font-size: 1.1rem; font-weight: 700; color: white; }
.sidebar-logo .logo-sub { font-size: 0.65rem; color: #64748b; text-transform: uppercase; letter-spacing: 0.05em; }

.sidebar-nav { padding: 0.75rem 0.75rem; }

.nav-section-label {
  font-size: 0.65rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: #475569; padding: 0.5rem 0.75rem 0.25rem; font-weight: 600;
}

.nav-item {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.55rem 0.75rem; border-radius: 6px;
  cursor: pointer; color: #94a3b8;
  font-size: 0.875rem; font-weight: 500;
  transition: all 0.15s; margin-bottom: 2px;
  text-decoration: none;
  user-select: none;
}

.nav-item:hover { background: #1e293b; color: #e2e8f0; }
.nav-item.active { background: #1e40af; color: white; }
.nav-item .nav-icon { width: 16px; text-align: center; }

.nav-badge {
  margin-left: auto;
  background: #ef4444; color: white;
  font-size: 0.65rem; font-weight: 700;
  padding: 1px 6px; border-radius: 10px;
  min-width: 18px; text-align: center;
}

/* ── Status Pills ──────────────────────────────────── */
.status-pill {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: 20px;
  font-size: 0.75rem; font-weight: 600; white-space: nowrap;
}

.status-draft        { background: #f1f5f9; color: #475569; }
.status-needs_review { background: #fef9c3; color: #854d0e; }
.status-pending_approval { background: #dbeafe; color: #1e40af; }
.status-approved     { background: #d1fae5; color: #065f46; }
.status-scheduled    { background: #e0e7ff; color: #3730a3; }
.status-in_transit   { background: #fef3c7; color: #92400e; }
.status-paid         { background: #bbf7d0; color: #14532d; }
.status-reconciled   { background: #d1d5db; color: #374151; }
.status-rejected     { background: #fee2e2; color: #991b1b; }
.status-failed       { background: #fee2e2; color: #991b1b; }
.status-active       { background: #d1fae5; color: #065f46; }
.status-pending_bank_setup { background: #fef9c3; color: #854d0e; }
.status-on_hold      { background: #fee2e2; color: #991b1b; }
.status-invited      { background: #dbeafe; color: #1e40af; }
.status-completed    { background: #bbf7d0; color: #14532d; }
.status-in_transit   { background: #fef3c7; color: #92400e; }

/* ── Cards ─────────────────────────────────────────── */
.card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.stat-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
  transition: box-shadow 0.15s;
}

.stat-card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.08); }

.stat-card .stat-label {
  font-size: 0.75rem; color: #6b7280; font-weight: 500; text-transform: uppercase; letter-spacing: 0.04em;
}

.stat-card .stat-value {
  font-size: 1.75rem; font-weight: 700; color: #111827; margin-top: 4px; line-height: 1.2;
}

.stat-card .stat-sub { font-size: 0.8rem; color: #6b7280; margin-top: 4px; }

/* ── Buttons ────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 0.45rem 1rem; border-radius: 8px;
  font-size: 0.875rem; font-weight: 600; cursor: pointer;
  transition: all 0.15s; border: none; white-space: nowrap;
  text-decoration: none; line-height: 1.4;
}

.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary  { background: #2563eb; color: white; }
.btn-primary:hover:not(:disabled)  { background: #1d4ed8; }
.btn-success  { background: #16a34a; color: white; }
.btn-success:hover:not(:disabled)  { background: #15803d; }
.btn-danger   { background: #dc2626; color: white; }
.btn-danger:hover:not(:disabled)   { background: #b91c1c; }
.btn-warning  { background: #d97706; color: white; }
.btn-warning:hover:not(:disabled)  { background: #b45309; }
.btn-outline  { background: white; color: #374151; border: 1px solid #d1d5db; }
.btn-outline:hover:not(:disabled)  { background: #f9fafb; border-color: #9ca3af; }
.btn-ghost    { background: transparent; color: #6b7280; }
.btn-ghost:hover:not(:disabled)    { background: #f3f4f6; color: #111827; }
.btn-sm       { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
.btn-lg       { padding: 0.65rem 1.4rem; font-size: 1rem; }

/* ── Tables ─────────────────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left; padding: 0.65rem 1rem;
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.05em;
  color: #6b7280; font-weight: 600;
  background: #f8fafc; border-bottom: 1px solid #e2e8f0;
}
.data-table td {
  padding: 0.75rem 1rem; border-bottom: 1px solid #f1f5f9;
  font-size: 0.875rem; color: #374151; vertical-align: middle;
}
.data-table tbody tr:hover { background: #f8fafc; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ── Forms ───────────────────────────────────────────── */
.form-group { margin-bottom: 1rem; }
.form-label {
  display: block; font-size: 0.8rem; font-weight: 600;
  color: #374151; margin-bottom: 0.35rem;
}
.form-label .req { color: #ef4444; margin-left: 2px; }

.form-input, .form-select, .form-textarea {
  width: 100%; padding: 0.5rem 0.75rem;
  border: 1px solid #d1d5db; border-radius: 8px;
  font-size: 0.875rem; color: #111827;
  transition: border-color 0.15s, box-shadow 0.15s;
  background: white;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none; border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59,130,246,0.1);
}
.form-input::placeholder { color: #9ca3af; }
.form-textarea { resize: vertical; min-height: 80px; }
.form-hint { font-size: 0.75rem; color: #6b7280; margin-top: 4px; }
.form-error { font-size: 0.75rem; color: #ef4444; margin-top: 4px; }

/* ── Modals ──────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); backdrop-filter: blur(2px);
  z-index: 100; display: flex; align-items: center; justify-content: center;
  padding: 1rem; animation: fadeIn 0.15s ease;
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

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

.modal-lg { max-width: 720px; }
.modal-xl { max-width: 900px; }

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #e2e8f0;
  display: flex; align-items: center; justify-content: space-between;
}

.modal-title { font-size: 1rem; font-weight: 700; color: #111827; }
.modal-body { padding: 1.5rem; }
.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid #e2e8f0;
  display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem;
}

/* ── Header ──────────────────────────────────────────── */
.top-header {
  position: sticky; top: 0;
  background: white; border-bottom: 1px solid #e2e8f0;
  padding: 0.75rem 1.5rem;
  display: flex; align-items: center; gap: 1rem;
  z-index: 30;
}

.breadcrumb { font-size: 0.875rem; color: #6b7280; }
.breadcrumb .current { color: #111827; font-weight: 600; }

/* ── Page Content ───────────────────────────────────── */
.page-content { padding: 1.5rem; }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem; flex-wrap: wrap; gap: 0.75rem;
}
.page-title { font-size: 1.35rem; font-weight: 700; color: #111827; }
.page-subtitle { font-size: 0.875rem; color: #6b7280; margin-top: 2px; }

/* ── Alerts ─────────────────────────────────────────── */
.alert {
  padding: 0.75rem 1rem; border-radius: 8px;
  font-size: 0.875rem; display: flex; align-items: flex-start; gap: 0.5rem;
  margin-bottom: 1rem;
}
.alert-info    { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }

/* ── Tabs ────────────────────────────────────────────── */
.tab-nav {
  display: flex; gap: 0; border-bottom: 2px solid #e2e8f0;
  margin-bottom: 1.25rem; overflow-x: auto;
}
.tab-item {
  padding: 0.65rem 1.1rem; cursor: pointer;
  font-size: 0.875rem; font-weight: 500; color: #6b7280;
  border-bottom: 2px solid transparent; margin-bottom: -2px;
  transition: color 0.15s, border-color 0.15s; white-space: nowrap;
}
.tab-item:hover { color: #374151; }
.tab-item.active { color: #2563eb; border-bottom-color: #2563eb; font-weight: 600; }

/* ── Empty States ────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 3rem 2rem;
  color: #9ca3af;
}
.empty-state .empty-icon { font-size: 2.5rem; margin-bottom: 0.75rem; }
.empty-state .empty-title { font-size: 1rem; font-weight: 600; color: #374151; }
.empty-state .empty-sub { font-size: 0.875rem; margin-top: 4px; }

/* ── Progress / Timeline ─────────────────────────────── */
.timeline { display: flex; flex-direction: column; gap: 0; }
.timeline-item {
  display: flex; gap: 1rem; padding-bottom: 1rem;
  position: relative;
}
.timeline-item:not(:last-child)::before {
  content: ''; position: absolute;
  left: 15px; top: 28px; bottom: 0;
  width: 2px; background: #e2e8f0;
}
.timeline-dot {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-size: 0.75rem;
}
.timeline-dot.done   { background: #d1fae5; color: #059669; }
.timeline-dot.active { background: #dbeafe; color: #2563eb; }
.timeline-dot.pending { background: #f3f4f6; color: #9ca3af; }
.timeline-dot.error  { background: #fee2e2; color: #dc2626; }

/* ── Search ─────────────────────────────────────────── */
.search-wrap { position: relative; }
.search-wrap .search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: #9ca3af; font-size: 0.8rem; }
.search-input { padding-left: 2rem !important; }

/* ── Loading ─────────────────────────────────────────── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid #e2e8f0;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 0.7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

.page-loading {
  display: flex; align-items: center; justify-content: center;
  min-height: 200px;
}

/* ── Amount styling ─────────────────────────────────── */
.amount-positive { color: #059669; font-weight: 600; }
.amount-large    { font-size: 1.1rem; font-weight: 700; color: #111827; }

/* ── Invoice Status Flow ─────────────────────────────── */
.status-flow {
  display: flex; align-items: center; gap: 0; flex-wrap: wrap;
  padding: 0.75rem 0;
}
.flow-step {
  display: flex; align-items: center; gap: 4px;
  font-size: 0.7rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; color: #9ca3af; padding: 0 8px;
}
.flow-step.done   { color: #059669; }
.flow-step.active { color: #2563eb; }
.flow-step.error  { color: #dc2626; }
.flow-arrow { color: #d1d5db; font-size: 0.7rem; }

/* ── Vendor avatar ───────────────────────────────────── */
.vendor-avatar {
  width: 36px; height: 36px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 0.875rem; flex-shrink: 0;
}

/* ── Dropdown ────────────────────────────────────────── */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute; right: 0; top: calc(100% + 4px);
  background: white; border: 1px solid #e2e8f0;
  border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,0.12);
  min-width: 160px; z-index: 50; padding: 4px;
}
.dropdown-item {
  display: flex; align-items: center; gap: 0.5rem;
  padding: 0.5rem 0.75rem; border-radius: 6px; cursor: pointer;
  font-size: 0.875rem; color: #374151; transition: background 0.1s;
}
.dropdown-item:hover { background: #f3f4f6; }
.dropdown-item.danger { color: #dc2626; }
.dropdown-item.danger:hover { background: #fee2e2; }
.dropdown-sep { height: 1px; background: #e2e8f0; margin: 4px 0; }

/* ── Upload zone ─────────────────────────────────────── */
.upload-zone {
  border: 2px dashed #d1d5db; border-radius: 12px;
  padding: 2rem; text-align: center; cursor: pointer;
  transition: all 0.2s; background: #fafafa;
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: #2563eb; background: #eff6ff;
}
.upload-zone .upload-icon { font-size: 2rem; color: #9ca3af; margin-bottom: 0.5rem; }

/* ── Activity feed ───────────────────────────────────── */
.activity-item {
  display: flex; gap: 0.75rem; align-items: flex-start;
  padding: 0.65rem 0; border-bottom: 1px solid #f1f5f9;
}
.activity-item:last-child { border-bottom: none; }
.activity-dot { width: 8px; height: 8px; border-radius: 50%; background: #93c5fd; flex-shrink: 0; margin-top: 6px; }

/* ── Toast notifications ─────────────────────────────── */
#toast-container {
  position: fixed; bottom: 1.5rem; right: 1.5rem; z-index: 200;
  display: flex; flex-direction: column; gap: 0.5rem; pointer-events: none;
}
.toast {
  background: #1e293b; color: white;
  padding: 0.75rem 1.1rem; border-radius: 10px;
  font-size: 0.875rem; display: flex; align-items: center; gap: 0.5rem;
  box-shadow: 0 4px 16px rgba(0,0,0,0.25);
  animation: slideUp 0.25s ease; pointer-events: all; min-width: 220px;
}
.toast.success { background: #14532d; border-left: 3px solid #22c55e; }
.toast.error   { background: #7f1d1d; border-left: 3px solid #ef4444; }
.toast.warning { background: #78350f; border-left: 3px solid #f59e0b; }

/* ── Login Page ──────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e1b4b 50%, #0f172a 100%);
  display: flex; align-items: center; justify-content: center; padding: 1rem;
}
.login-card {
  background: white; border-radius: 16px;
  padding: 2.5rem; width: 100%; max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

/* ── Responsive fixes ────────────────────────────────── */
@media (max-width: 640px) {
  .page-content { padding: 1rem; }
  .stat-card .stat-value { font-size: 1.4rem; }
  .modal { border-radius: 12px 12px 0 0; align-self: flex-end; max-height: 95vh; }
  .modal-backdrop { align-items: flex-end; padding: 0; }
  .data-table th, .data-table td { padding: 0.5rem 0.6rem; }
  .hide-mobile { display: none !important; }
}
