/* ========================================
   AgroBill Mandi — Shared Styles
   Agriculture Green + Harvest Gold Theme
   ======================================== */

:root {
  --primary: #1B5E20;
  --primary-light: #2E7D32;
  --primary-dark: #0a3d0a;
  --primary-hover: #388E3C;
  --gold: #F57F17;
  --gold-light: #FFF8E1;
  --gold-dark: #E65100;
  --success: #2E7D32;
  --danger: #C62828;
  --warning: #F57F17;
  --info: #0277BD;
  --sidebar-bg: #0D2B0D;
  --sidebar-text: #C8E6C9;
  --sidebar-hover: rgba(255,255,255,0.1);
  --sidebar-active: rgba(76,175,80,0.25);
  --sidebar-width: 260px;
  --bg: #F1F5F0;
  --card-bg: #FFFFFF;
  --text-primary: #1A1A1A;
  --text-muted: #5A5A5A;
  --border: #D8E4D8;
  --shadow: 0 2px 8px rgba(27,94,32,0.08);
  --shadow-hover: 0 4px 16px rgba(27,94,32,0.14);
  --radius: 10px;
}

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

body {
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.5;
}

/* ========= SIDEBAR ========= */
.sidebar {
  background: var(--sidebar-bg);
  width: var(--sidebar-width);
  min-height: 100vh;
  max-height: 100vh;
  position: fixed;
  left: 0; top: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 3px 0 15px rgba(0,0,0,0.25);
  transition: width 0.25s ease;
}

.sidebar-brand {
  padding: 18px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0,0,0,0.2);
}

.sidebar-brand-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--gold), #ff8f00);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0;
}

.sidebar-brand-text {
  color: #fff;
  font-weight: 700;
  font-size: 15px;
  line-height: 1.2;
}

.sidebar-brand-text small {
  display: block;
  color: var(--sidebar-text);
  font-size: 11px;
  font-weight: 400;
  opacity: 0.8;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 12px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.1) transparent;
}

.nav-section-title {
  color: rgba(255,255,255,0.35);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  padding: 12px 20px 4px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 20px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  border-radius: 0;
  transition: background 0.18s, color 0.18s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.nav-link i {
  font-size: 17px;
  width: 22px;
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
}

.nav-link.active {
  background: var(--sidebar-active);
  color: #81C784;
  border-right: 3px solid #4CAF50;
}

.nav-link.active i { opacity: 1; }

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

.user-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  background: rgba(255,255,255,0.05);
}

.user-avatar {
  width: 34px; height: 34px;
  background: var(--primary-light);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: 14px; flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }
.user-name { color: #fff; font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { color: var(--sidebar-text); font-size: 11px; opacity: 0.7; }

.btn-logout {
  color: rgba(255,255,255,0.5);
  background: none; border: none;
  cursor: pointer; padding: 4px;
  font-size: 16px;
  transition: color 0.2s;
}
.btn-logout:hover { color: #ef5350; }

/* ========= MAIN CONTENT ========= */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-header {
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  padding: 16px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  position: sticky; top: 0; z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.page-title { font-size: 20px; font-weight: 700; color: var(--primary); }
.page-subtitle { font-size: 13px; color: var(--text-muted); }

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

/* ========= CARDS ========= */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 15px;
  color: var(--primary);
  background: #FAFDF9;
  border-radius: var(--radius) var(--radius) 0 0;
}

.card-body { padding: 20px; }

/* Stat Cards */
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  transition: box-shadow 0.2s, transform 0.2s;
}
.stat-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-2px); }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--primary);
  line-height: 1.1;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

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

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; }

.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: #EF6C00; color: #fff; }

.btn-success { background: #2E7D32; color: #fff; }
.btn-success:hover { background: #1B5E20; }

.btn-danger { background: #C62828; color: #fff; }
.btn-danger:hover { background: #B71C1C; }

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--primary);
  color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: #fff; }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-lg { padding: 12px 24px; font-size: 15px; }

.btn i { font-size: 15px; }

/* ========= FORMS ========= */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 5px;
}

.form-label .hindi {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 400;
  margin-left: 4px;
}

.form-control, .form-select {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid #C8D8C8;
  border-radius: 7px;
  font-size: 14px;
  color: var(--text-primary);
  background: #fff;
  transition: border 0.18s, box-shadow 0.18s;
  outline: none;
  font-family: inherit;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 0 3px rgba(46,125,50,0.12);
}

.form-control.is-invalid { border-color: var(--danger); }
.invalid-feedback { color: var(--danger); font-size: 12px; margin-top: 3px; }

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

/* ========= TABLE ========= */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
}

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

thead th {
  background: #EBF3EB;
  color: var(--primary);
  font-weight: 700;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 11px 14px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid #EEF5EE;
  transition: background 0.15s;
}
tbody tr:hover { background: #F5FAF5; }
tbody td { padding: 11px 14px; vertical-align: middle; }
tbody tr:last-child { border-bottom: none; }

/* ========= BADGES ========= */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

.badge-arrived { background: #E3F2FD; color: #0D47A1; }
.badge-weighed { background: #FFF9C4; color: #827717; }
.badge-auctioned { background: #E8F5E9; color: #1B5E20; }
.badge-settled { background: #E8EAF6; color: #283593; }
.badge-cancelled { background: #FFEBEE; color: #B71C1C; }
.badge-active { background: #E8F5E9; color: #1B5E20; }
.badge-inactive { background: #F5F5F5; color: #757575; }
.badge-blacklisted { background: #FFEBEE; color: #B71C1C; }
.badge-paid { background: #E8F5E9; color: #1B5E20; }
.badge-partial { background: #FFF8E1; color: #E65100; }
.badge-issued { background: #E3F2FD; color: #0D47A1; }
.badge-draft { background: #F3E5F5; color: #4A148C; }
.badge-finalized { background: #E0F2F1; color: #004D40; }

/* ========= SEARCH BAR ========= */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #fff;
  border: 1.5px solid #C8D8C8;
  border-radius: 7px;
  padding: 7px 12px;
}
.search-bar i { color: var(--text-muted); }
.search-bar input {
  border: none; outline: none; background: transparent;
  font-size: 14px; width: 220px;
}

/* ========= MODAL ========= */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.45);
  z-index: 9998;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s;
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }

.modal-box {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  transform: translateY(-20px);
  transition: transform 0.2s;
}
.modal-overlay.show .modal-box { transform: translateY(0); }
.modal-box.lg { max-width: 800px; }
.modal-box.sm { max-width: 420px; }

.modal-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  background: #FAFDF9;
  border-radius: 12px 12px 0 0;
}
.modal-title { font-size: 16px; font-weight: 700; color: var(--primary); }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--text-muted); line-height: 1; }
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: flex-end; gap: 10px;
  background: #FAFDF9;
  border-radius: 0 0 12px 12px;
}

/* ========= TOAST ========= */
#toast-container {
  position: fixed; top: 20px; right: 20px; z-index: 99999;
  display: flex; flex-direction: column; gap: 8px;
}

.toast {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  border-left: 4px solid var(--primary);
  min-width: 280px; max-width: 380px;
  animation: slideInRight 0.25s ease;
  font-size: 14px;
}
.toast.success { border-color: var(--success); }
.toast.error { border-color: var(--danger); }
.toast.warning { border-color: var(--warning); }
.toast i { font-size: 18px; }
.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }
.toast.warning i { color: var(--warning); }
.toast-msg { flex: 1; }

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

/* ========= UTILITY ========= */
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.gap-4 { gap: 16px; }

.row { display: flex; flex-wrap: wrap; gap: 20px; }
.col { flex: 1; min-width: 200px; }
.col-2 { flex: 0 0 calc(50% - 10px); }
.col-3 { flex: 0 0 calc(33.333% - 14px); }
.col-4 { flex: 0 0 calc(25% - 15px); }

.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-gold { color: var(--gold); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fw-bold { font-weight: 700; }
.fw-600 { font-weight: 600; }

.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }

.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 56px; opacity: 0.2; display: block; margin-bottom: 16px; }
.empty-state p { font-size: 15px; }

.divider { height: 1px; background: var(--border); margin: 20px 0; }

/* ========= SETTLEMENT BREAKDOWN ========= */
.settlement-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 0;
  border-bottom: 1px dashed #E0E8E0;
  font-size: 14px;
}
.settlement-row:last-child { border-bottom: none; }
.settlement-row.deduction { color: var(--danger); }
.settlement-row.total {
  font-size: 17px; font-weight: 700;
  border-top: 2px solid var(--primary);
  border-bottom: none; margin-top: 8px;
  padding-top: 12px; color: var(--primary);
}

/* ========= PRINT ========= */
@media print {
  .sidebar, .page-header .btn, .no-print { display: none !important; }
  .main-content { margin-left: 0; }
  body { background: white; font-size: 12px; }
  .card { box-shadow: none; border: 1px solid #ccc; }
}

/* ========= SCROLLBAR ========= */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(27,94,32,0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(27,94,32,0.4); }

/* ========= LOADING ========= */
.spinner {
  display: inline-block; width: 20px; height: 20px;
  border: 2.5px solid rgba(27,94,32,0.15);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.page-loading {
  display: flex; align-items: center; justify-content: center;
  min-height: 300px; flex-direction: column; gap: 14px;
  color: var(--text-muted);
}

/* ========= INPUT GROUP ========= */
.input-group { display: flex; }
.input-group .form-control { border-radius: 7px 0 0 7px; flex: 1; }
.input-group .btn { border-radius: 0 7px 7px 0; }

/* ========= AMOUNT ========= */
.amount { font-family: 'Consolas', 'Courier New', monospace; font-weight: 600; }
.amount-lg { font-size: 22px; font-weight: 700; color: var(--primary); }

/* ========= SYNC BAR (Electron sidebar) ========= */
.sync-bar {
  margin-top: 8px;
  padding: 7px 10px 5px;
  border-top: 1px solid rgba(255,255,255,0.07);
}
.sync-bar-row {
  display: flex; align-items: center; gap: 7px;
}
.sync-dot {
  width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0;
}
.sync-online   { background: #4CAF50; box-shadow: 0 0 0 3px rgba(76,175,80,0.25); }
.sync-offline  { background: #616161; }
.sync-syncing  { background: #2196F3; animation: sync-pulse 1s ease-in-out infinite; }
.sync-pending  { background: #FFC107; }
.sync-disabled { background: #424242; }
@keyframes sync-pulse { 0%,100% { opacity:1; } 50% { opacity:0.35; } }
.sync-label {
  flex: 1; font-size: 11px; color: rgba(255,255,255,0.55); white-space: nowrap;
}
.sync-btn {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.15);
  color: rgba(255,255,255,0.5);
  border-radius: 4px; padding: 2px 6px;
  font-size: 12px; cursor: pointer; line-height: 1.6;
  transition: background 0.15s;
}
.sync-btn:hover:not(:disabled) { background: rgba(255,255,255,0.15); color: #fff; }
.sync-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.sync-meta {
  font-size: 10px; color: rgba(255,255,255,0.32); margin-top: 2px; padding-left: 14px;
}
