/* ============================================================
   NIAGAWAN — MAIN STYLESHEET
   CSS Variables at top for easy theming
   ============================================================ */

/* ─── THEME VARIABLES (edit to rebrand) ──────────────────── */
:root {
  --brand:        #1a6cff;
  --brand-hover:  #0f5de0;
  --brand-light:  #e8f0fe;
  --teal:         #0ecad4;
  --sidebar-bg:   #0a1628;
  --sidebar-w:    240px;
  --topbar-h:     64px;

  --white:        #ffffff;
  --bg:           #f4f6fb;
  --card-bg:      #ffffff;
  --border:       #e2e8f0;

  --text:         #1a2540;
  --text-muted:   #6b7a99;
  --text-light:   #a0aec0;

  --green:        #10b981;
  --orange:       #f59e0b;
  --red:          #ef4444;
  --purple:       #8b5cf6;

  --radius-sm:    6px;
  --radius:       10px;
  --radius-lg:    16px;
  --shadow-sm:    0 1px 3px rgba(0,0,0,.07);
  --shadow:       0 4px 16px rgba(0,0,0,.08);
  --shadow-lg:    0 8px 32px rgba(0,0,0,.12);

  --transition:   .2s ease;
  font-size: 14px;
}

/* ─── RESET ───────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Plus Jakarta Sans', sans-serif; background: var(--bg); color: var(--text); line-height: 1.5; }
a { text-decoration: none; color: inherit; }
img { max-width: 100%; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ─── APP LAYOUT ──────────────────────────────────────────── */
.app-wrapper { display: flex; min-height: 100vh; }

/* ─── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: fixed;
  top: 0; left: 0;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
}
.logo-icon {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--brand), var(--teal));
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: .85rem;
}
.logo-text {
  font-size: 1.1rem; font-weight: 800;
  color: #fff; letter-spacing: -.3px;
}
.sidebar-toggle { color: rgba(255,255,255,.4); font-size: .9rem; display: none; }

.sidebar-company {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 20px;
  margin: 8px 12px;
  background: rgba(255,255,255,.05);
  border-radius: var(--radius);
}
.company-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--brand), var(--teal));
  border-radius: 8px;
  color: #fff; font-size: .7rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.company-name { font-size: .78rem; font-weight: 600; color: #fff; line-height: 1.3; }
.company-currency { font-size: .68rem; color: rgba(255,255,255,.4); }

.sidebar-nav { flex: 1; padding: 8px 12px; overflow-y: auto; }
.nav-section { margin-bottom: 4px; }
.nav-label {
  font-size: .62rem; font-weight: 700; letter-spacing: .1em;
  text-transform: uppercase; color: rgba(255,255,255,.3);
  padding: 12px 8px 4px; display: block;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.55); font-size: .82rem; font-weight: 500;
  transition: all var(--transition);
  margin-bottom: 1px;
}
.nav-item i { width: 16px; text-align: center; font-size: .85rem; }
.nav-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-item.active { background: var(--brand); color: #fff; box-shadow: 0 4px 12px rgba(26,108,255,.3); }

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid rgba(255,255,255,.06);
}
.nav-logout:hover { background: rgba(239,68,68,.15); color: #ef4444; }

/* ─── MAIN AREA ───────────────────────────────────────────── */
.main-area {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─── TOPBAR ──────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px; gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.topbar-menu-btn { display: none; color: var(--text-muted); font-size: 1.1rem; }
.topbar-title { font-size: 1rem; font-weight: 700; color: var(--text); flex: 1; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.topbar-user {
  display: flex; align-items: center; gap: 10px;
  cursor: pointer; position: relative; padding: 6px 10px;
  border-radius: var(--radius); transition: background var(--transition);
}
.topbar-user:hover { background: var(--bg); }
.user-avatar {
  width: 34px; height: 34px;
  background: linear-gradient(135deg, var(--brand), var(--teal));
  border-radius: 50%; color: #fff; font-size: .78rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.user-name { font-size: .8rem; font-weight: 600; }
.user-role { font-size: .68rem; color: var(--text-muted); }
.topbar-user > .fa-chevron-down { font-size: .65rem; color: var(--text-muted); }

.user-dropdown {
  position: absolute; top: calc(100% + 8px); right: 0;
  width: 180px;
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 6px;
  display: none;
  z-index: 200;
}
.user-dropdown.open { display: block; }
.user-dropdown a {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: var(--radius-sm);
  font-size: .8rem; color: var(--text);
  transition: background var(--transition);
}
.user-dropdown a:hover { background: var(--bg); }
.user-dropdown hr { border: none; border-top: 1px solid var(--border); margin: 4px 0; }
.dropdown-logout { color: var(--red) !important; }

/* ─── PAGE CONTENT ────────────────────────────────────────── */
.page-content { padding: 24px; flex: 1; }

/* ─── ALERTS ─────────────────────────────────────────────── */
.alert {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; margin: 0 24px 0;
  border-radius: var(--radius); font-size: .85rem; font-weight: 500;
  animation: slideDown .3s ease;
}
@keyframes slideDown { from { opacity:0; transform:translateY(-8px); } to { opacity:1; transform:translateY(0); } }
.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-close { margin-left: auto; font-size: 1.1rem; color: inherit; opacity: .6; }

/* ─── CARDS ───────────────────────────────────────────────── */
.card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.card-header {
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.card-title { font-size: .95rem; font-weight: 700; }
.card-body { padding: 20px; }

/* ─── STAT CARDS ──────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 16px; margin-bottom: 24px;
}
.stat-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
}
.stat-icon {
  width: 48px; height: 48px; border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem; flex-shrink: 0;
}
.stat-icon.blue   { background: var(--brand-light); color: var(--brand); }
.stat-icon.green  { background: #d1fae5; color: var(--green); }
.stat-icon.orange { background: #fef3c7; color: var(--orange); }
.stat-icon.red    { background: #fee2e2; color: var(--red); }
.stat-icon.purple { background: #ede9fe; color: var(--purple); }
.stat-label { font-size: .75rem; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.stat-value { font-size: 1.4rem; font-weight: 800; color: var(--text); }
.stat-sub   { font-size: .72rem; color: var(--text-muted); margin-top: 2px; }

/* ─── TABLES ──────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { border-bottom: 2px solid var(--border); }
th {
  padding: 10px 14px; text-align: left;
  font-size: .72rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: var(--text-muted);
  white-space: nowrap;
}
td {
  padding: 12px 14px; font-size: .83rem;
  border-bottom: 1px solid var(--border);
  color: var(--text);
}
tbody tr:hover { background: var(--bg); }
tbody tr:last-child td { border-bottom: none; }

/* ─── BADGES ──────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center;
  padding: 3px 10px; border-radius: 100px;
  font-size: .68rem; font-weight: 700; letter-spacing: .03em;
  text-transform: uppercase;
}
.badge-gray   { background: #f1f5f9; color: #64748b; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-green  { background: #d1fae5; color: #065f46; }
.badge-orange { background: #fef3c7; color: #92400e; }
.badge-red    { background: #fee2e2; color: #991b1b; }
.badge-dark   { background: #1e293b; color: #94a3b8; }

/* ─── BUTTONS ─────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: var(--radius-sm);
  font-size: .82rem; font-weight: 600;
  transition: all var(--transition); cursor: pointer;
  border: 1px solid transparent;
}
.btn-primary { background: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-hover); box-shadow: 0 4px 12px rgba(26,108,255,.3); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #059669; }
.btn-danger  { background: var(--red); color: #fff; }
.btn-danger:hover  { background: #dc2626; }
.btn-outline { background: transparent; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: var(--bg); }
.btn-sm { padding: 6px 12px; font-size: .76rem; }
.btn-icon { width: 32px; height: 32px; padding: 0; justify-content: center; border-radius: var(--radius-sm); }

/* ─── FORMS ───────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-label {
  display: block; margin-bottom: 6px;
  font-size: .78rem; font-weight: 600; color: var(--text);
}
.form-label .req { color: var(--red); margin-left: 2px; }
.form-control {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: .83rem; color: var(--text); background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(26,108,255,.12);
}
.form-control.is-invalid { border-color: var(--red); }
.form-error { font-size: .72rem; color: var(--red); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; }

/* ─── MODAL ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
  z-index: 500; padding: 20px;
  opacity: 0; visibility: hidden;
  transition: all var(--transition);
}
.modal-overlay.open { opacity: 1; visibility: visible; }
.modal {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  width: 100%; max-width: 520px;
  box-shadow: var(--shadow-lg);
  transform: scale(.95);
  transition: transform var(--transition);
  max-height: 90vh; overflow-y: auto;
}
.modal-overlay.open .modal { transform: scale(1); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.modal-title { font-size: .95rem; font-weight: 700; }
.modal-close { color: var(--text-muted); font-size: 1.1rem; }
.modal-body { padding: 20px; }
.modal-footer {
  padding: 16px 20px; border-top: 1px solid var(--border);
  display: flex; justify-content: flex-end; gap: 10px;
}
.modal-lg { max-width: 800px; }

/* ─── PAGINATION ──────────────────────────────────────────── */
.pagination {
  display: flex; align-items: center; gap: 4px;
  padding: 16px 20px; border-top: 1px solid var(--border);
  justify-content: flex-end;
}
.page-btn {
  min-width: 32px; height: 32px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: .78rem; font-weight: 600; color: var(--text);
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.page-btn:hover { border-color: var(--brand); color: var(--brand); }
.page-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; }

/* ─── EMPTY STATE ─────────────────────────────────────────── */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 3rem; margin-bottom: 16px; opacity: .3; }
.empty-state h3 { font-size: .95rem; font-weight: 600; margin-bottom: 8px; color: var(--text); }
.empty-state p  { font-size: .82rem; }

/* ─── PAGE HEADER ─────────────────────────────────────────── */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px; flex-wrap: wrap; gap: 12px;
}
.page-header-left h1 { font-size: 1.3rem; font-weight: 800; }
.page-header-left p  { font-size: .82rem; color: var(--text-muted); margin-top: 2px; }
.page-header-actions { display: flex; gap: 10px; align-items: center; }

/* ─── GRID LAYOUTS ────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }

/* ─── LOGIN PAGE ──────────────────────────────────────────── */
.login-page { display: flex; min-height: 100vh; }
.login-left {
  flex: 0 0 52%; background: var(--sidebar-bg);
  position: relative; overflow: hidden;
  display: flex; flex-direction: column; padding: 44px 56px;
}
.login-left::before, .login-left::after {
  content: ''; position: absolute; border-radius: 50%;
  filter: blur(90px); opacity: .35;
  animation: drift 12s ease-in-out infinite alternate;
}
.login-left::before {
  width: 500px; height: 500px;
  background: radial-gradient(circle, var(--brand), transparent 70%);
  top: -120px; left: -140px;
}
.login-left::after {
  width: 400px; height: 400px;
  background: radial-gradient(circle, var(--teal), transparent 70%);
  bottom: -100px; right: -120px; animation-delay: -6s;
}
@keyframes drift {
  from { transform: translate(0,0) scale(1); }
  to   { transform: translate(40px,30px) scale(1.08); }
}
.login-brand {
  position: relative; z-index: 2;
  display: flex; align-items: center; gap: 10px; margin-bottom: auto;
}
.login-brand .logo-text { color: #fff; font-size: 1.2rem; }
.login-hero {
  position: relative; z-index: 2;
  padding-top: 60px; padding-bottom: 60px;
}
.login-hero h1 {
  font-size: clamp(2rem, 3.5vw, 3rem); line-height: 1.18;
  color: #fff; margin-bottom: 16px; font-weight: 800;
}
.login-hero h1 span {
  background: linear-gradient(135deg, #3b9eff, var(--teal));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}
.login-hero p { font-size: .9rem; color: rgba(255,255,255,.55); line-height: 1.7; max-width: 380px; }

.login-features { display: flex; flex-direction: column; gap: 10px; margin-top: 32px; max-width: 400px; }
.login-feature {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,.06); border: 1px solid rgba(255,255,255,.08);
  border-radius: var(--radius); padding: 12px 16px;
}
.login-feature-icon {
  width: 34px; height: 34px;
  background: rgba(255,255,255,.08); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  color: var(--teal); font-size: .85rem; flex-shrink: 0;
}
.login-feature-text strong { display: block; font-size: .78rem; font-weight: 600; color: #fff; }
.login-feature-text span   { font-size: .7rem; color: rgba(255,255,255,.45); }

.login-right {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 40px; background: var(--bg);
}
.login-form-box {
  width: 100%; max-width: 400px;
  background: var(--card-bg); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 40px;
}
.login-form-box h2 { font-size: 1.4rem; font-weight: 800; margin-bottom: 4px; }
.login-form-box p  { font-size: .82rem; color: var(--text-muted); margin-bottom: 28px; }
.login-btn { width: 100%; justify-content: center; padding: 11px; font-size: .88rem; }
.login-footer {
  text-align: center; margin-top: 16px;
  font-size: .78rem; color: var(--text-muted);
}
.login-footer a { color: var(--brand); font-weight: 600; }
.pass-wrapper { position: relative; }
.pass-toggle {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  color: var(--text-muted); font-size: .85rem; cursor: pointer;
}

/* ─── RESPONSIVE ──────────────────────────────────────────── */
@media (max-width: 900px) {
  .login-left { display: none; }
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open { transform: translateX(0); }
  .main-area { margin-left: 0; }
  .topbar-menu-btn { display: block; }
  .sidebar-toggle { display: block; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
}

/* ─── INVOICE SPECIFIC ────────────────────────────────────── */
.invoice-items-table th, .invoice-items-table td { padding: 10px 8px; }
.invoice-total-box {
  max-width: 300px; margin-left: auto; margin-top: 16px;
}
.invoice-total-row {
  display: flex; justify-content: space-between;
  padding: 8px 0; font-size: .83rem;
  border-bottom: 1px solid var(--border);
}
.invoice-total-row.grand {
  font-size: 1rem; font-weight: 800; color: var(--brand);
  border-bottom: none; padding-top: 12px;
}

/* ─── CHART CONTAINERS ────────────────────────────────────── */
.chart-container { position: relative; height: 260px; }

/* ─── SCROLLBAR ───────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* ─── SALE SECTION ADDITIONS ─────────────────────────────────── */
.badge-purple { background: #ede9fe; color: #6d28d9; }
.badge-teal   { background: #ccfbf1; color: #0f766e; }

/* Collapsible sidebar nav groups */
.nav-group-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; border-radius: var(--radius-sm);
  color: rgba(255,255,255,.55); font-size: .82rem; font-weight: 600;
  cursor: pointer; transition: all var(--transition);
  margin-bottom: 1px; gap: 8px;
}
.nav-group-header:hover { background: rgba(255,255,255,.08); color: #fff; }
.nav-group-header i.icon { width: 16px; text-align: center; font-size: .85rem; }
.nav-group-header .chevron { font-size: .6rem; margin-left: auto; transition: transform .2s; }
.nav-group-header.open .chevron { transform: rotate(180deg); }
.nav-group-header.active-group { color: #fff; }

.nav-sub {
  display: none; padding-left: 28px; margin-bottom: 2px;
}
.nav-sub.open { display: block; }
.nav-sub .nav-item {
  font-size: .78rem; padding: 7px 10px;
  color: rgba(255,255,255,.45);
}
.nav-sub .nav-item.active {
  color: var(--brand); background: rgba(26,108,255,.15);
  font-weight: 600;
}
.nav-sub .nav-item:hover { color: #fff; background: rgba(255,255,255,.06); }

/* Document form layout */
.doc-form-grid {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 20px;
  align-items: start;
}
.doc-totals-panel {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: sticky;
  top: calc(var(--topbar-h) + 16px);
}
.doc-total-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 0; border-bottom: 1px solid var(--border);
  font-size: .83rem;
}
.doc-total-row:last-child { border-bottom: none; }
.doc-total-row.grand {
  font-size: 1.05rem; font-weight: 800; color: var(--brand);
  padding-top: 12px; margin-top: 4px;
  border-top: 2px solid var(--brand);
}
.doc-total-row input.form-control {
  width: 110px; text-align: right; padding: 5px 8px; font-size: .83rem;
}

/* Items table in doc forms */
.items-table th, .items-table td { padding: 8px 6px; vertical-align: middle; }
.items-table .desc-col { min-width: 200px; }
.items-table .num-col  { width: 90px; }
.items-table .act-col  { width: 40px; }

/* Document view header strip */
.doc-view-header {
  background: linear-gradient(135deg, var(--sidebar-bg), #1a3a6b);
  border-radius: var(--radius-lg);
  padding: 24px 28px;
  color: #fff;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 16px;
  margin-bottom: 20px;
}
.doc-view-header .doc-no { font-size: 1.4rem; font-weight: 800; }
.doc-view-header .doc-type-tag {
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .1em; background: rgba(255,255,255,.12);
  padding: 3px 10px; border-radius: 100px; margin-bottom: 4px;
  display: inline-block;
}
.doc-view-header .doc-amount { font-size: 1.8rem; font-weight: 800; }
.doc-view-header .doc-amount-label { font-size: .72rem; opacity: .6; }

/* Convert button styles */
.btn-convert { background: #7c3aed; color: #fff; }
.btn-convert:hover { background: #6d28d9; }

/* Print styles for sale docs */
@media print {
  .sidebar, .topbar, .page-header-actions, .print-actions, .no-print { display: none !important; }
  .main-area { margin-left: 0 !important; }
  body { background: #fff !important; }
}
