/* ===== INSTALLMENT BUSINESS - CUSTOM THEME ===== */
:root {
  --sidebar-bg: #0f172a;
  --sidebar-hover: #1e293b;
  --sidebar-active: #f59e0b;
  --sidebar-text: #94a3b8;
  --sidebar-text-hover: #ffffff;
  --sidebar-width: 250px;

  --primary: #f59e0b;
  --primary-dark: #d97706;
  --secondary: #14b8a6;
  --success: #10b981;
  --info: #06b6d4;
  --warning: #f59e0b;
  --danger: #ef4444;

  --body-bg: #f1f5f9;
  --card-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --topbar-height: 60px;
}

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--body-bg);
  overflow-x: hidden;
}

/* ===== LAYOUT ===== */
#wrapper {
  display: flex;
  width: 100%;
  min-height: 100vh;
}

#content-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-width: 0;
  margin-left: var(--sidebar-width);
  transition: margin-left 0.3s ease;
}

.sidebar.collapsed + #content-wrapper {
  margin-left: 70px;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--sidebar-bg);
  min-height: 100vh;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 1030;
  transition: width 0.3s ease, min-width 0.3s ease;
  display: flex;
  flex-direction: column;
}

/* Collapsed state */
.sidebar.collapsed {
  width: 70px;
  min-width: 70px;
}

.sidebar.collapsed .sidebar-brand-text,
.sidebar.collapsed .nav-link span:not(.icon),
.sidebar.collapsed .sidebar-heading,
.sidebar.collapsed .collapse,
.sidebar.collapsed .arrow,
.sidebar.collapsed .sidebar-divider {
  display: none;
}

.sidebar.collapsed .sidebar-brand {
  justify-content: center;
  padding: 1rem 0;
}

.sidebar.collapsed .sidebar-brand-icon {
  margin: 0;
}

.sidebar.collapsed .nav-link {
  justify-content: center;
  padding: 0.8rem 0;
}

.sidebar.collapsed .nav-link i {
  margin: 0;
  font-size: 1.2rem;
}


/* Collapsed hover - temporarily expand */
.sidebar.collapsed:hover {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  z-index: 1031;
  box-shadow: 4px 0 20px rgba(0,0,0,0.3);
}

.sidebar.collapsed:hover .sidebar-brand-text,
.sidebar.collapsed:hover .nav-link span:not(.icon),
.sidebar.collapsed:hover .sidebar-heading,
.sidebar.collapsed:hover .collapse,
.sidebar.collapsed:hover .arrow,
.sidebar.collapsed:hover .sidebar-divider {
  display: revert;
}

.sidebar.collapsed:hover .sidebar-brand {
  justify-content: flex-start;
  padding: 1rem 1.25rem;
}

.sidebar.collapsed:hover .nav-link {
  justify-content: flex-start;
  padding: 0.7rem 1.25rem;
}

.sidebar.collapsed:hover .nav-link i {
  font-size: 1rem;
}

/* Sidebar brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  color: #fff;
  text-decoration: none;
  font-size: 0.95rem;
  font-weight: 700;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  transition: padding 0.3s;
}

.sidebar-brand:hover { color: var(--sidebar-active); text-decoration: none; }

.sidebar-brand-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-brand-icon {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--sidebar-active);
  border-radius: 8px;
  color: #fff;
  font-size: 1.1rem;
  flex-shrink: 0;
}

.sidebar-divider {
  border-top: 1px solid rgba(255,255,255,0.06);
  margin: 0.5rem 1rem;
}

.sidebar-heading {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--sidebar-text);
  padding: 0.75rem 1.25rem 0.5rem;
  font-weight: 700;
  opacity: 0.5;
  white-space: nowrap;
}

/* Nav items */
.nav-item { position: relative; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.7rem 1.25rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 0.88rem;
  transition: all 0.2s;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
  border-right: 3px solid transparent;
}

.nav-link i {
  width: 20px;
  text-align: center;
  font-size: 1rem;
  flex-shrink: 0;
}

.nav-link:hover {
  background: var(--sidebar-hover);
  color: var(--sidebar-text-hover);
  text-decoration: none;
}

.nav-item.active > .nav-link,
.nav-link.active {
  color: var(--sidebar-active);
  background: rgba(245, 158, 11, 0.08);
  border-right-color: var(--sidebar-active);
}

.nav-link .arrow {
  margin-left: auto;
  transition: transform 0.3s;
  font-size: 0.7rem;
}

.nav-link .arrow i.fa-chevron-down {
  transform: rotate(90deg);
}

/* Submenu */
.collapse-inner {
  background: rgba(0,0,0,0.2);
  padding: 0.25rem 0;
}

.collapse-header {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--sidebar-text);
  padding: 0.5rem 1.25rem 0.25rem 3rem;
  font-weight: 600;
  opacity: 0.5;
  letter-spacing: 0.03em;
}

.collapse-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 1.25rem 0.45rem 3rem;
  color: var(--sidebar-text);
  font-size: 0.84rem;
  text-decoration: none;
  transition: all 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.nav-link > span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.collapse-item i { font-size: 0.8rem; width: 16px; }

.collapse-item:hover {
  background: rgba(255,255,255,0.04);
  color: var(--sidebar-text-hover);
  text-decoration: none;
}

.collapse-item.active { color: var(--sidebar-active); }

/* Sidebar toggle button */
.sidebar-toggle-area {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  margin-top: auto;
}

#sidebarToggle {
  width: 100%;
  height: 36px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.04);
  color: var(--sidebar-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  transition: all 0.2s;
  padding: 0 0.75rem;
}

#sidebarToggle:hover {
  background: var(--sidebar-hover);
  color: #fff;
  border-color: rgba(255,255,255,0.2);
}

#sidebarToggle i {
  font-size: 0.8rem;
  transition: transform 0.3s ease;
}

.sidebar.collapsed #sidebarToggle {
  gap: 0;
  padding: 0;
}

.sidebar.collapsed #sidebarToggle .toggle-label {
  display: none;
}

/* ===== TOPBAR ===== */
.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  display: flex;
  align-items: center;
  padding: 0 1.25rem;
  position: sticky;
  top: 0;
  z-index: 1020;
}

.topbar .sidebar-toggle-btn {
  background: none;
  border: none;
  font-size: 1.3rem;
  color: #64748b;
  cursor: pointer;
  margin-right: 1rem;
  display: none;
}

.topbar .page-title {
  font-weight: 600;
  color: #0f172a;
  font-size: 1rem;
}

.topbar .user-area {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ===== CONTENT ===== */
.content {
  padding: 1.25rem;
  flex: 1;
  width: 100%;
}

/* ===== CARDS ===== */
.card {
  border: none;
  box-shadow: var(--card-shadow);
  border-radius: 0.5rem;
}

.card-header {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.9rem 1.25rem;
  font-weight: 600;
  border-radius: 0.5rem 0.5rem 0 0 !important;
}

.card-header h6 { font-size: 0.9rem; margin: 0; }

.border-left-primary { border-left: 4px solid var(--primary) !important; }
.border-left-success { border-left: 4px solid var(--success) !important; }
.border-left-info { border-left: 4px solid var(--info) !important; }
.border-left-warning { border-left: 4px solid var(--warning) !important; }
.border-left-danger { border-left: 4px solid var(--danger) !important; }
.border-left-secondary { border-left: 4px solid var(--secondary) !important; }

.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-info { color: var(--info) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }
.text-secondary { color: var(--secondary) !important; }

.bg-primary { background-color: var(--primary) !important; }
.bg-success { background-color: var(--success) !important; }
.bg-info { background-color: var(--info) !important; }
.bg-warning { background-color: var(--warning) !important; }
.bg-danger { background-color: var(--danger) !important; }
.bg-secondary { background-color: var(--secondary) !important; }

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

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

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

.badge-primary { background: var(--primary); color: #fff; }
.badge-success { background: var(--success); color: #fff; }
.badge-info { background: var(--info); color: #fff; }
.badge-warning { background: var(--warning); color: #fff; }
.badge-danger { background: var(--danger); color: #fff; }
.badge-secondary { background: #64748b; color: #fff; }

/* ===== TABLES ===== */
.table { margin-bottom: 0; }

.table th {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #64748b;
  border-top: none;
  white-space: nowrap;
  padding: 0.75rem 0.5rem;
}

.table td {
  vertical-align: middle;
  font-size: 0.88rem;
  padding: 0.65rem 0.5rem;
}

.table-bordered th, .table-bordered td { border-color: #e2e8f0; }

.table-hover tbody tr:hover { background: rgba(245, 158, 11, 0.04); }

/* ===== FORMS ===== */
.form-label {
  font-weight: 600;
  font-size: 0.82rem;
  color: #475569;
  margin-bottom: 0.25rem;
}

.form-control, .form-select {
  border-radius: 0.375rem;
  border-color: #d1d5db;
  font-size: 0.9rem;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.2rem rgba(245, 158, 11, 0.15);
}

/* ===== FOOTER ===== */
.sticky-footer {
  background: #fff;
  border-top: 1px solid #e2e8f0;
  padding: 0.8rem 0;
  flex-shrink: 0;
}

.sticky-footer .copyright {
  font-size: 0.82rem;
  color: #94a3b8;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 991.98px) {
  #content-wrapper {
    margin-left: 0 !important;
  }

  .sidebar {
    left: calc(-1 * var(--sidebar-width));
    transition: left 0.3s ease;
    box-shadow: none;
  }

  .sidebar.show {
    left: 0;
    box-shadow: 4px 0 20px rgba(0,0,0,0.3);
  }

  .topbar .sidebar-toggle-btn {
    display: block;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 1025;
  }
  .sidebar-backdrop.show { display: block; }
}

@media (max-width: 576px) {
  .content { padding: 0.75rem; }
  .topbar { padding: 0 0.75rem; }
  .table th, .table td { font-size: 0.75rem; padding: 0.5rem 0.35rem; }
}

/* ===== UTILITY ===== */
.text-xs { font-size: 0.75rem; }
.text-gray-300 { color: #d1d5db; }
.text-gray-500 { color: #6b7280; }
.text-gray-800 { color: #1f2937; }
.font-weight-bold { font-weight: 600 !important; }

.shadow { box-shadow: var(--card-shadow); }

.btn-block { display: block; width: 100%; }
.btn-circle { border-radius: 50% !important; width: 32px; height: 32px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }

.no-gutters { margin-right: 0; margin-left: 0; }
.no-gutters > .col, .no-gutters > [class*="col-"] { padding-right: 0; padding-left: 0; }

/* ===== SCROLL TO TOP ===== */
.scroll-to-top {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  width: 40px;
  height: 40px;
  background: var(--primary);
  color: #fff;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  opacity: 0;
  transition: opacity 0.3s;
  z-index: 1050;
  cursor: pointer;
}

.scroll-to-top.show { opacity: 1; }
.scroll-to-top:hover { color: #fff; background: var(--primary-dark); }

/* ===== LOGIN PAGE ===== */
.bg-gradient-custom {
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #0f172a 100%);
}

/* ===== PRINT ===== */
@media print {
  .sidebar, .topbar, .no-print, .scroll-to-top, .sidebar-backdrop { display: none !important; }
  #content-wrapper { margin-left: 0 !important; }
}
