/* Desi Finan - Main App Stylesheet */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;600;700;900&display=swap');

:root {
  --primary: #1B4FD8;
  --primary-dark: #1e40af;
  --primary-light: #dbeafe;
  --accent: #F97316;
  --accent-dark: #ea580c;
  --dark: #0F172A;
  --gray: #6b7280;
  --light-gray: #f3f4f6;
  --bg: #F8FAFF;
  --white: #ffffff;
  --success: #10B981;
  --danger: #EF4444;
  --warning: #F59E0B;
  --info: #3B82F6;
  --border: #e5e7eb;
  --shadow: 0 1px 3px rgba(0,0,0,0.1);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
  --radius: 10px;
  --radius-lg: 16px;
  --sidebar-width: 240px;
  --header-height: 60px;
  --font: 'Roboto', sans-serif;
}

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--dark);
  font-size: 14px;
  line-height: 1.6;
}

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: var(--light-gray); }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }

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

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  background: var(--dark);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  transition: all 0.3s;
}

.sidebar-brand {
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.brand-logo {
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
  text-decoration: none;
  display: block;
}

.brand-logo span { color: var(--accent); }

.brand-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.4);
  margin-top: 2px;
}

.sidebar-section {
  padding: 16px 12px 8px;
  font-size: 10px;
  font-weight: 700;
  color: rgba(255,255,255,0.3);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

.sidebar-menu { list-style: none; padding: 0 8px; }

.sidebar-menu li { margin-bottom: 2px; }

.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,0.65);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all 0.2s;
}

.sidebar-menu a:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.sidebar-menu a.active {
  background: var(--primary);
  color: #fff;
}

.sidebar-menu a .icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-menu .submenu { list-style: none; padding-left: 32px; margin-top: 2px; display: none; }
.sidebar-menu .submenu.open { display: block; }
.sidebar-menu .submenu li { margin-bottom: 1px; }
.sidebar-menu .submenu a {
  font-size: 12.5px;
  padding: 7px 10px;
  color: rgba(255,255,255,0.65) !important;
  text-decoration: none !important;
  display: block;
  border-radius: 6px;
  transition: all 0.2s;
}
.sidebar-menu .submenu a:hover {
  background: rgba(255,255,255,0.08);
  color: #fff !important;
}

.has-sub > a::after {
  content: '›';
  margin-left: auto;
  font-size: 16px;
  transition: transform 0.2s;
}

.has-sub.open > a::after { transform: rotate(90deg); }

/* Premium Badge */
.premium-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 20px;
  margin-left: auto;
}

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

/* ===== TOPBAR ===== */
.topbar {
  height: var(--header-height);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}

.topbar-left { display: flex; align-items: center; gap: 16px; }

.page-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--dark);
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--gray);
}

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

.topbar-right { display: flex; align-items: center; gap: 12px; }

.topbar-btn {
  width: 36px; height: 36px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--white);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  font-size: 16px;
  color: var(--gray);
  transition: all 0.2s;
  text-decoration: none;
}

.topbar-btn:hover { background: var(--bg); color: var(--primary); }

.user-menu {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  position: relative;
}

.user-menu:hover { background: var(--bg); }

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 13px;
}

.user-info { line-height: 1.2; }
.user-name { font-size: 13px; font-weight: 600; color: var(--dark); }
.user-role { font-size: 11px; color: var(--gray); }

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  min-width: 180px;
  display: none;
  z-index: 200;
  overflow: hidden;
}

.dropdown-menu.show { display: block; }

.dropdown-menu a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  font-size: 13px;
  color: var(--dark);
  text-decoration: none;
  transition: background 0.15s;
}

.dropdown-menu a:hover { background: var(--bg); }
.dropdown-menu a.danger { color: var(--danger); }
.dropdown-menu .divider { height: 1px; background: var(--border); margin: 4px 0; }

/* Plan Indicator */
.plan-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.plan-free { background: #f3f4f6; color: var(--gray); }
.plan-premium { background: linear-gradient(135deg, #fef3c7, #fde68a); color: #92400e; }

/* ===== PAGE CONTENT ===== */
.page-content { padding: 24px; }

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

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--white);
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--dark);
}

.card-body { padding: 20px; }
.card-footer { padding: 14px 20px; border-top: 1px solid var(--border); background: var(--bg); }

/* ===== STAT CARDS ===== */
.stat-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }

.stat-card {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 20px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-icon {
  width: 52px; height: 52px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-icon.blue { background: var(--primary-light); }
.stat-icon.orange { background: #fff7ed; }
.stat-icon.green { background: #d1fae5; }
.stat-icon.red { background: #fee2e2; }

.stat-info { flex: 1; }
.stat-label { font-size: 12px; color: var(--gray); font-weight: 500; margin-bottom: 4px; }
.stat-value { font-size: 20px; font-weight: 800; color: var(--dark); }
.stat-change { font-size: 11px; margin-top: 3px; }
.stat-change.up { color: var(--success); }
.stat-change.down { color: var(--danger); }

/* ===== TABLES ===== */
.table-responsive { overflow-x: auto; }

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

.df-table th {
  padding: 11px 14px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--gray);
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.df-table td {
  padding: 12px 14px;
  border-bottom: 1px solid #f3f4f6;
  color: var(--dark);
  vertical-align: middle;
}

.df-table tr:last-child td { border-bottom: none; }
.df-table tbody tr:hover { background: var(--bg); }
.df-table .text-right { text-align: right; }
.df-table .text-center { text-align: center; }

.df-table .amount { font-weight: 600; font-family: 'Roboto', monospace; }
.df-table .amount.positive { color: var(--success); }
.df-table .amount.negative { color: var(--danger); }

/* ===== FORMS ===== */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; color: #374151; margin-bottom: 6px; }
.form-label .req { color: var(--danger); margin-left: 2px; }

.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  font-family: var(--font);
  color: var(--dark);
  background: var(--white);
  transition: border-color 0.2s;
  outline: none;
}

.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(27,79,216,0.1); }
.form-control.is-invalid { border-color: var(--danger); }
.form-control[readonly] { background: var(--bg); color: var(--gray); }

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

.form-row { display: grid; gap: 16px; }
.form-row.col-2 { grid-template-columns: 1fr 1fr; }
.form-row.col-3 { grid-template-columns: 1fr 1fr 1fr; }
.form-row.col-4 { grid-template-columns: 1fr 1fr 1fr 1fr; }

.form-text { font-size: 12px; color: var(--gray); margin-top: 4px; }
.invalid-feedback { font-size: 12px; color: var(--danger); margin-top: 4px; }

/* Input Group */
.input-group { display: flex; }
.input-group .form-control { border-radius: 8px 0 0 8px; }
.input-group-text {
  padding: 10px 14px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-left: none;
  border-radius: 0 8px 8px 0;
  font-size: 13px;
  color: var(--gray);
  font-weight: 500;
  white-space: nowrap;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 20px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: var(--font);
  transition: all 0.2s;
  text-decoration: none;
  white-space: nowrap;
}

.btn:hover { transform: translateY(-1px); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(27,79,216,0.3); }

.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-dark); box-shadow: 0 4px 12px rgba(249,115,22,0.3); }

.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }

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

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

.btn-sm { padding: 6px 14px; font-size: 12px; }
.btn-lg { padding: 13px 28px; font-size: 15px; }
.btn-icon { padding: 8px; width: 34px; height: 34px; justify-content: center; }
.btn-block { width: 100%; justify-content: center; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info { background: #dbeafe; color: #1e40af; }
.badge-gray { background: #f3f4f6; color: #4b5563; }
.badge-primary { background: var(--primary-light); color: var(--primary); }

/* ===== ALERTS ===== */
.alert {
  padding: 13px 16px;
  border-radius: 10px;
  font-size: 14px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.alert-danger { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-warning { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.alert-info { background: #dbeafe; color: #1e40af; border: 1px solid #bfdbfe; }

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  justify-content: flex-end;
  padding: 16px 20px;
}

.page-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--white);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  text-decoration: none;
  color: var(--dark);
  transition: all 0.15s;
}

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

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
  display: none;
  align-items: center;
  justify-content: center;
}

.modal-overlay.show { display: flex; }

.modal-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

/* Modal alias */
.modal {
  background: var(--white);
  border-radius: 16px;
  width: 100%;
  max-width: 560px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  padding: 0;
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { background: none; border: none; font-size: 20px; cursor: pointer; color: var(--gray); }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); display: flex; gap: 10px; justify-content: flex-end; }

/* ===== TABS ===== */
.tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 20px; gap: 4px; }
.tab-btn {
  padding: 10px 20px;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s;
}
.tab-btn.active { color: var(--primary); border-bottom-color: var(--primary); }
.tab-btn:hover { color: var(--primary); }
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ===== SEARCH & FILTER BAR ===== */
.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.search-input {
  position: relative;
  flex: 1;
  min-width: 200px;
}

.search-input input {
  width: 100%;
  padding: 9px 14px 9px 38px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.2s;
}

.search-input input:focus { border-color: var(--primary); }
.search-input .search-icon {
  position: absolute;
  left: 12px; top: 50%;
  transform: translateY(-50%);
  color: var(--gray);
  font-size: 14px;
}

/* ===== PREMIUM BLOCK ===== */
.premium-block {
  background: linear-gradient(135deg, #fef3c7, #fff7ed);
  border: 1.5px solid #fde68a;
  border-radius: var(--radius-lg);
  padding: 40px;
  text-align: center;
}

.premium-block .lock-icon { font-size: 48px; margin-bottom: 12px; }
.premium-block h3 { font-size: 20px; font-weight: 800; color: #92400e; margin-bottom: 8px; }
.premium-block p { color: #78350f; font-size: 14px; margin-bottom: 20px; }

/* ===== PRINT STYLES ===== */
@media print {
  .sidebar, .topbar, .no-print,
  .filter-bar, .btn, button,
  .card-header .btn, .page-header { display: none !important; }
  .main-content { margin-left: 0 !important; }
  .page-content { padding: 0 !important; }
  .card { box-shadow: none !important; border: 1px solid #ddd !important; }
  body { background: #fff !important; }
  #printArea { display: block !important; }
  .page-break { page-break-before: always; }
  @page { margin: 1cm; }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .stat-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row.col-3, .form-row.col-4 { grid-template-columns: 1fr; }
  .form-row.col-2 { grid-template-columns: 1fr; }
  .page-content { padding: 16px; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
}

/* ===== UTILITIES ===== */
.text-primary { color: var(--primary); }
.text-accent { color: var(--accent); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-gray { color: var(--gray); }
.text-dark { color: var(--dark); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.text-bold { font-weight: 700; }
.text-sm { font-size: 12px; }
.text-lg { font-size: 16px; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex-1 { flex: 1; }
.w-100 { width: 100%; }
.hidden { display: none; }
