/* assets/css/style.css — Mirip Manager.io */
:root {
  --manager-bg: #f8f9fa;
  --sidebar-bg: #ffffff;
  --sidebar-active: #eef4ff;
  --border: #e9ecef;
  --text: #212529;
  --muted: #6c757d;
  --primary: #0d6efd;
  --primary-hover: #0b5ed7;
  --success: #198754;
  --danger: #dc3545;
  --info: #0dcaf0;
  --warning: #ffc107;
  --card-bg: #ffffff;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.05);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--manager-bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.875rem;
  overflow-x: hidden;
}

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

/* ---------- Layout ---------- */
.app {
  display: flex;
  min-height: 100vh;
}

/* ---------- Sidebar (full height, no topbar) ---------- */
.sidebar {
  width: 250px;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  flex-shrink: 0;
  transition: transform 0.25s ease;
}

/* Company header in sidebar */
.sidebar-brand {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}
.sidebar-brand .brand-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  color: #fff; border-radius: 0.6rem;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.4rem;
}
.sidebar-brand .brand-info .brand-name {
  font-weight: 700; font-size: 0.95rem; color: var(--text);
  line-height: 1.2;
}
.sidebar-brand .brand-info .brand-currency {
  font-size: 0.72rem; color: var(--muted);
}

/* Search bar */
.sidebar-search {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: #f8f9fa;
}
.sidebar-search input {
  width: 100%; padding: 0.55rem 0.9rem; border: 1px solid var(--border);
  border-radius: 0.5rem; font-size: 0.82rem; background: #fff;
  transition: border-color 0.15s;
}
.sidebar-search input:focus {
  border-color: var(--primary); outline: none;
}

/* Nav */
.sidebar nav { flex: 1; overflow-y: auto; padding: 0.5rem 0; }
.sidebar .nav-section {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); font-weight: 700; padding: 0.75rem 1.25rem 0.35rem;
}
.sidebar .nav-list { list-style: none; margin: 0; padding: 0; }
.sidebar .nav-item { margin: 0; }
.sidebar .nav-link {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.6rem 1.25rem; color: var(--text);
  font-size: 0.85rem; font-weight: 500;
  border-radius: 0; transition: all 0.15s;
  white-space: nowrap;
}
.sidebar .nav-link i {
  width: 1.15rem; text-align: center; font-size: 0.95rem; color: var(--muted);
  flex-shrink: 0;
}
.sidebar .nav-link:hover {
  background: #f1f3f5; color: var(--primary);
}
.sidebar .nav-link:hover i { color: var(--primary); }
.sidebar .nav-link.active {
  background: var(--sidebar-active); color: var(--primary);
  border-right: 3px solid var(--primary);
  padding-right: 1.22rem;
}
.sidebar .nav-link.active i { color: var(--primary); }

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
  font-size: 0.7rem; color: var(--muted);
  text-align: center;
}

/* ---------- Main Content ---------- */
.main {
  margin-left: 250px;
  width: calc(100% - 250px);
  min-height: 100vh;
  transition: margin-left 0.25s ease, width 0.25s ease;
}

.main-inner {
  padding: 1.5rem 2rem;
  max-width: none;
  width: 100%;
}

/* ---------- Page Header ---------- */
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 1.5rem;
}
.page-title-box h1 {
  font-size: 1.6rem; font-weight: 700; color: var(--text); margin: 0 0 0.2rem;
  letter-spacing: -0.3px;
}
.page-title-box p {
  margin: 0; font-size: 0.85rem; color: var(--muted);
}
.page-actions { display: flex; gap: 0.6rem; }

/* ---------- Alerts ---------- */
.alert {
  padding: 0.85rem 1.1rem; border-radius: 0.6rem;
  margin-bottom: 1.2rem; font-size: 0.85rem; border: 1px solid transparent;
  animation: slideDown 0.3s ease;
}
@keyframes slideDown { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: translateY(0); } }
.alert-success { background: #d1e7dd; color: #0f5132; border-color: #badbcc; }
.alert-danger { background: #f8d7da; color: #842029; border-color: #f5c2c7; }
.alert-info { background: #cff4fc; color: #055160; border-color: #b6effb; }
.alert-dismissible .btn-close { font-size: 1.2rem; }

/* ---------- Stat Cards ---------- */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.stat-card {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 0.9rem; padding: 1.1rem 1.25rem;
  display: flex; align-items: center; gap: 1rem;
  box-shadow: var(--shadow);
}
.stat-icon {
  width: 44px; height: 44px; border-radius: 0.8rem; display: flex;
  align-items: center; justify-content: center; font-size: 1.5rem; color: #fff;
  flex-shrink: 0;
}
.stat-icon.bg-primary { background: var(--primary); }
.stat-icon.bg-success { background: var(--success); }
.stat-icon.bg-info { background: var(--info); color: #000; }
.stat-icon.bg-danger { background: var(--danger); }
.stat-icon.bg-warning { background: var(--warning); color: #000; }
.stat-info h3 { margin: 0; font-size: 1.35rem; font-weight: 700; color: var(--text); }
.stat-info p { margin: 3px 0 0; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.03em; font-weight: 600; }

/* ---------- Section wrapper ---------- */
.section {
  background: var(--card-bg); border: 1px solid var(--border);
  border-radius: 0.9rem; box-shadow: var(--shadow);
  margin-bottom: 1.5rem; overflow: hidden;
}
.section-header {
  background: #f8f9fa; border-bottom: 1px solid var(--border);
  padding: 0.9rem 1.25rem; font-weight: 600; font-size: 0.9rem;
  color: var(--text); display: flex; align-items: center; gap: 0.55rem;
}
.section-header i { color: var(--primary); font-size: 1rem; }
.section-body { padding: 1.25rem; }

/* ---------- Tables ---------- */
.table-responsive { overflow-x: auto; }
table.data-table {
  width: 100%; border-collapse: collapse; font-size: 0.85rem;
}
table.data-table thead {
  background: #f8f9fa;
}
table.data-table th {
  padding: 0.8rem 1rem; font-weight: 600; font-size: 0.78rem;
  text-transform: uppercase; letter-spacing: 0.03em; border-bottom: 2px solid var(--border);
  text-align: left; color: var(--muted); white-space: nowrap;
}
table.data-table td {
  padding: 0.8rem 1rem; border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
table.data-table tbody tr:hover { background: #f8f9fa; }
table.data-table tbody tr:last-child td { border-bottom: none; }

.amount-col { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.text-debit { color: var(--success); font-weight: 600; }
.text-credit { color: var(--danger); font-weight: 600; }
.type-badge {
  display: inline-block; padding: 0.25rem 0.6rem; border-radius: 0.4rem;
  font-size: 0.72rem; font-weight: 700; background: #e9ecef; color: var(--muted);
}

/* Badges */
.badge {
  display: inline-block; padding: 0.3rem 0.65rem; border-radius: 1rem;
  font-size: 0.72rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em;
}
.badge-draft { background: #e2e3e5; color: #383d41; }
.badge-sent { background: #cfe2ff; color: #084298; }
.badge-paid { background: #d1e7dd; color: #0f5132; }
.badge-overdue { background: #f8d7da; color: #842029; }
.badge-voided { background: #e2e3e5; color: #6c757d; text-decoration: line-through; }
.badge-approved { background: #d1e7dd; color: #0f5132; }
.badge-submitted { background: #ffe5d0; color: #994700; }
.badge-rejected { background: #f8d7da; color: #842029; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 0.45rem;
  padding: 0.55rem 1.15rem; border: 1px solid transparent; border-radius: 0.6rem;
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: all 0.15s; white-space: nowrap;
}
.btn i { font-size: 0.85rem; }
.btn:disabled { opacity: 0.65; cursor: not-allowed; }
.btn-primary { background: var(--primary); color: #fff; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn-outline {
  background: #fff; color: var(--text); border-color: var(--border);
}
.btn-outline:hover { background: #f8f9fa; border-color: #adb5bd; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; }

/* ---------- Forms ---------- */
.form-label { display: block; font-size: 0.8rem; font-weight: 600;
  color: var(--text); margin-bottom: 0.35rem; }
.form-control {
  width: 100%; padding: 0.55rem 0.9rem; border: 1px solid var(--border);
  border-radius: 0.5rem; font-size: 0.85rem; background: #fff;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.form-control:focus {
  border-color: var(--primary); outline: none;
  box-shadow: 0 0 0 3px rgba(13,110,253,0.12);
}
.form-select { appearance: none; background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='%236c757d' d='M7.247 11.14 2.514 5.521A.5.5 0 0 1 3 5.27l4 4a.5.5 0 0 0 .707 0l4-4a.5.5 0 0 1 .707 0l1 1.15a.5.5 0 0 1-.707.707L8.5 9.793l-2.854 2.853a.5.5 0 0 1-.707 0z'/%3e%3c/svg%3e");
  background-repeat: no-repeat; background-position: right 0.75rem center; background-size: 11px;
}
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 1rem; }
.form-col-2 { grid-column: span 2; }
.form-row { display: flex; gap: 1rem; align-items: flex-end; }
.form-col { flex: 1; }

/* ---------- Modal ---------- */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45); display: flex; align-items: center;
  justify-content: center; z-index: 1100; padding: 1rem;
  opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }
.modal {
  background: #fff; border-radius: 0.8rem; width: 100%; max-width: 720px;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  transform: translateY(20px); transition: transform 0.25s;
}
.modal-overlay.show .modal { transform: translateY(0); }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1rem 1.25rem; border-bottom: 1px solid var(--border);
  background: #f8f9fa; border-top-left-radius: 0.8rem; border-top-right-radius: 0.8rem;
}
.modal-title { font-weight: 700; font-size: 1.05rem; margin: 0; color: var(--text); }
.modal-close { background: none; border: none; font-size: 1.5rem; color: var(--muted); cursor: pointer; line-height: 1; }
.modal-body { padding: 1.25rem; }
.modal-footer {
  display: flex; justify-content: flex-end; gap: 0.6rem;
  padding: 0.9rem 1.25rem; border-top: 1px solid var(--border);
  background: #f8f9fa; border-bottom-right-radius: 0.8rem; border-bottom-left-radius: 0.8rem;
}

/* ---------- Utilities ---------- */
.text-right { text-align: right; }
.text-center { text-align: center; }
.fw-bold { font-weight: 700; }
.fw-semibold { font-weight: 600; }
.mt-2 { margin-top: 0.5rem !important; }
.mb-2 { margin-bottom: 0.5rem !important; }
.mt-3 { margin-top: 1rem !important; }
.mb-3 { margin-bottom: 1rem !important; }
.d-flex { display: flex; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.w-auto { width: auto; }
.border-top { border-top: 1px solid var(--border); }

.empty-state {
  text-align: center; padding: 3rem 1rem; color: var(--muted);
}
.empty-state i { font-size: 3rem; color: #ced4da; margin-bottom: 1rem; display: block; }
.empty-state h3 { margin: 0 0 0.5rem; color: var(--text); }

/* ---------- AI Chat Widget ---------- */
.ai-fab {
  position: fixed; bottom: 22px; right: 22px; z-index: 1150;
  width: 54px; height: 54px; border-radius: 50%; background: var(--primary);
  color: #fff; display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(13,110,253,0.4); border: none; cursor: pointer;
  font-size: 1.4rem; transition: transform 0.2s, background 0.2s, box-shadow 0.2s;
}
.ai-fab:hover { background: var(--primary-hover); transform: scale(1.08); box-shadow: 0 6px 18px rgba(13,110,253,0.5); }
.ai-fab:active { transform: scale(0.95); }
.ai-badge {
  position: absolute; top: -6px; right: -6px; background: var(--danger); color: #fff;
  font-size: 0.65rem; width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; line-height: 1;
}

.ai-chat-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4); display: flex; align-items: flex-end; justify-content: flex-end;
  z-index: 1160; padding: 16px; opacity: 0; pointer-events: none; transition: opacity 0.25s;
}
.ai-chat-overlay.show { opacity: 1; pointer-events: auto; }
.ai-chat-panel {
  background: #fff; border-radius: 1rem 1rem 0 0; width: 100%; max-width: 420px;
  height: 72vh; max-height: 760px; display: flex; flex-direction: column;
  box-shadow: 0 -8px 24px rgba(0,0,0,0.15); transform: translateY(100%); transition: transform 0.25s;
  border: 1px solid var(--border); border-bottom: none;
}
.ai-chat-overlay.show .ai-chat-panel { transform: translateY(0); }
.ai-chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.9rem 1.2rem; border-bottom: 1px solid var(--border);
  background: #f8f9fa; border-top-left-radius: 1rem; border-top-right-radius: 1rem;
}
.ai-chat-header .ai-chat-title {
  display: flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 0.95rem; color: var(--text);
}
.ai-chat-header .ai-chat-title i { color: var(--primary); font-size: 1rem; }
.ai-chat-status {
  font-size: 0.7rem; padding: 0.15rem 0.5rem; border-radius: 1rem; background: #e9ecef; color: var(--muted);
  font-weight: 600;
}
.ai-chat-status.ok { background: #d1e7dd; color: #0f5132; }
.ai-chat-status.off { background: #f8d7da; color: #842029; }

.ai-chat-body { flex: 1; overflow-y: auto; padding: 1rem 1.2rem; display: flex; flex-direction: column; gap: 0.75rem; background: #fbfcfd; }
.ai-msg { display: flex; gap: 0.7rem; max-width: 85%; }
.ai-msg.ai-user { flex-direction: row-reverse; margin-left: auto; }
.ai-bubble {
  padding: 0.65rem 0.9rem; border-radius: 0.8rem; font-size: 0.85rem; line-height: 1.45;
  word-wrap: break-word; white-space: pre-wrap;
}
.ai-msg.ai-user .ai-bubble { background: var(--primary); color: #fff; border-bottom-right-radius: 0.25rem; }
.ai-msg.ai-ai .ai-bubble { background: #fff; border: 1px solid var(--border); color: var(--text); border-bottom-left-radius: 0.25rem; }
.ai-msg .ai-meta { font-size: 0.68rem; color: var(--muted); margin-top: 0.2rem; }
.ai-msg.ai-user .ai-meta { margin-left: auto; text-align: right; }

.ai-chat-footer {
  border-top: 1px solid var(--border); padding: 0.7rem 1.2rem; background: #fff;
  display: flex; gap: 0.5rem; border-bottom-left-radius: 1rem; border-bottom-right-radius: 1rem;
}
.ai-chat-footer input {
  flex: 1; padding: 0.6rem 0.9rem; border: 1px solid var(--border); border-radius: 0.6rem;
  font-size: 0.85rem; outline: none;
}
.ai-chat-footer input:focus { border-color: var(--primary); }
.ai-chat-footer button {
  background: var(--primary); color: #fff; border: none; border-radius: 0.6rem;
  width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1rem; transition: background 0.15s;
}
.ai-chat-footer button:hover { background: var(--primary-hover); }
.ai-chat-footer button:disabled { opacity: 0.6; cursor: not-allowed; }
.ai-empty {
  margin-top: auto; text-align: center; color: var(--muted); font-size: 0.85rem; padding-bottom: 1rem;
}
.ai-empty i { font-size: 2rem; color: #ced4da; margin-bottom: 0.5rem; display: block; opacity: 0.6; }

/* ---------- Mobile ---------- */
@media (max-width: 991px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.show { transform: translateX(0); }
  .main { margin-left: 0; width: 100%; }
  .main-inner { padding: 1.2rem 1rem; }
  .page-header { flex-direction: column; align-items: flex-start; gap: 0.9rem; }
  .page-actions { width: 100%; justify-content: flex-end; }
  .stat-grid { grid-template-columns: 1fr; }
  .modal { max-width: 95vw; }
  .form-grid { grid-template-columns: 1fr; }
  .form-col-2 { grid-column: span 1; }
}

.sidebar-backdrop {
  display: none; position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4); z-index: 150; opacity: 0;
  transition: opacity 0.25s; pointer-events: none;
}
.sidebar-backdrop.show { opacity: 1; pointer-events: auto; }
