/* ============================================================
   TenantPro - Main Stylesheet
   ============================================================ */

:root {
  --sidebar-width: 260px;
  --sidebar-collapsed: 70px;
  --topbar-height: 64px;

  /* Brand Colors */
  --primary: #1a56db;
  --primary-dark: #1245b0;
  --primary-light: #e8effd;
  --accent: #0ea5e9;
  --success: #16a34a;
  --warning: #d97706;
  --danger: #dc2626;
  --info: #0891b2;

  /* Neutrals */
  --bg-app: #f1f5f9;
  --bg-card: #ffffff;
  --border: #e2e8f0;
  --text-primary: #0f172a;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;

  /* Sidebar */
  --sidebar-bg: #0f172a;
  --sidebar-text: #94a3b8;
  --sidebar-active-bg: rgba(26, 86, 219, 0.2);
  --sidebar-active-text: #60a5fa;
  --sidebar-hover: rgba(255,255,255,0.06);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08), 0 2px 6px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.12);

  /* Radius */
  --radius: 10px;
  --radius-lg: 16px;
  --radius-sm: 6px;

  /* Font */
  --font: 'Plus Jakarta Sans', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
}

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

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

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

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s ease;
}

.main-content.expanded {
  margin-left: var(--sidebar-collapsed);
}

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

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

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(26,86,219,0.4);
}

.brand-name {
  font-size: 16px;
  font-weight: 800;
  color: white;
  letter-spacing: -0.3px;
  display: block;
  line-height: 1.2;
}

.brand-tagline {
  font-size: 10px;
  color: var(--sidebar-text);
  display: block;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.sidebar-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 12px;
}

.sidebar-body::-webkit-scrollbar { width: 4px; }
.sidebar-body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 4px; }

.sidebar-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  color: rgba(148,163,184,0.5);
  padding: 0 10px 8px;
  text-transform: uppercase;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  color: var(--sidebar-text);
  border-radius: var(--radius-sm);
  text-decoration: none;
  font-weight: 500;
  font-size: 13.5px;
  transition: all 0.2s ease;
  white-space: nowrap;
  position: relative;
}

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

.sidebar-nav .nav-link.active {
  background: var(--sidebar-active-bg);
  color: var(--sidebar-active-text);
  font-weight: 600;
}

.nav-icon {
  font-size: 17px;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.nav-badge {
  margin-left: auto;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 20px;
  min-width: 18px;
  text-align: center;
  display: none;
}
.nav-badge.show { display: inline-block; }

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

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background 0.2s;
}
.sidebar-user:hover { background: var(--sidebar-hover); }

.sidebar-user-info .fw-600 { color: white; font-size: 13px; }
.sidebar-user-info .text-xs { font-size: 11px; }

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

/* Collapsed sidebar */
.sidebar.collapsed {
  width: var(--sidebar-collapsed);
}
.sidebar.collapsed .brand-text,
.sidebar.collapsed .sidebar-label,
.sidebar.collapsed .nav-link span,
.sidebar.collapsed .sidebar-user-info,
.sidebar.collapsed .nav-badge { display: none; }
.sidebar.collapsed .nav-link { justify-content: center; padding: 12px 0; }
.sidebar.collapsed .sidebar-footer .sidebar-user { justify-content: center; }
.sidebar.collapsed .sidebar-header { padding: 20px 16px 16px; justify-content: center; }

/* ============================================================
   Topbar
   ============================================================ */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 1020;
  box-shadow: var(--shadow-sm);
}

.btn-icon {
  width: 38px;
  height: 38px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all 0.2s;
}
.btn-icon:hover { background: var(--bg-app); color: var(--text-primary); }

.notif-badge {
  font-size: 9px;
  padding: 2px 4px;
  min-width: 16px;
  border-radius: 20px;
  border: 2px solid white;
  line-height: 1;
  display: none;
}
.notif-badge.show { display: block; }

.user-menu-btn {
  width: auto;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-primary);
}
.user-menu-btn:hover { background: var(--bg-app); }

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

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border);
  padding: 16px 20px;
  font-weight: 600;
}

.card-body { padding: 20px; }

/* Stat Cards */
.stat-card {
  padding: 20px;
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  transition: all 0.25s ease;
  position: relative;
  overflow: hidden;
}
.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.stat-card::after {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  opacity: 0.06;
  transform: translate(20px, -20px);
}
.stat-card.blue::after { background: var(--primary); }
.stat-card.green::after { background: var(--success); }
.stat-card.orange::after { background: var(--warning); }
.stat-card.red::after { background: var(--danger); }
.stat-card.cyan::after { background: var(--info); }

.stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  margin-bottom: 16px;
}
.stat-icon.blue { background: #dbeafe; color: var(--primary); }
.stat-icon.green { background: #dcfce7; color: var(--success); }
.stat-icon.orange { background: #fef3c7; color: var(--warning); }
.stat-icon.red { background: #fee2e2; color: var(--danger); }
.stat-icon.cyan { background: #cffafe; color: var(--info); }

.stat-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.2;
  color: var(--text-primary);
  letter-spacing: -0.5px;
}
.stat-label {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  margin-top: 4px;
}
.stat-trend {
  font-size: 11px;
  font-weight: 600;
  margin-top: 8px;
}
.stat-trend.up { color: var(--success); }
.stat-trend.down { color: var(--danger); }

/* ============================================================
   Tables
   ============================================================ */
.table {
  font-size: 13.5px;
  --bs-table-striped-bg: #f8fafc;
}

.table > thead > tr > th {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.7px;
  color: var(--text-secondary);
  background: #f8fafc;
  border-bottom: 2px solid var(--border);
  padding: 10px 14px;
  white-space: nowrap;
}

.table > tbody > tr > td {
  padding: 12px 14px;
  vertical-align: middle;
  border-bottom: 1px solid #f1f5f9;
}
.table > tbody > tr:last-child > td { border-bottom: none; }
.table > tbody > tr:hover > td { background: #f8fafc; }

/* ============================================================
   Forms
   ============================================================ */
.form-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.form-control, .form-select {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  font-family: var(--font);
  font-size: 14px;
  color: var(--text-primary);
  transition: border-color 0.2s, box-shadow 0.2s;
  background: white;
}
.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,86,219,0.1);
  outline: none;
}

.form-control.is-invalid { border-color: var(--danger); }

/* ============================================================
   Buttons
   ============================================================ */
.btn {
  font-family: var(--font);
  font-weight: 600;
  font-size: 13.5px;
  border-radius: var(--radius-sm);
  padding: 8px 18px;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 2px 8px rgba(26,86,219,0.3);
}
.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  box-shadow: 0 4px 14px rgba(26,86,219,0.4);
  transform: translateY(-1px);
}

.btn-outline-primary {
  border-color: var(--primary);
  color: var(--primary);
}
.btn-outline-primary:hover {
  background: var(--primary);
  transform: translateY(-1px);
}

.btn-sm { padding: 5px 12px; font-size: 12.5px; }

/* ============================================================
   Badges
   ============================================================ */
.badge {
  font-size: 11px;
  font-weight: 600;
  padding: 4px 9px;
  border-radius: 20px;
  letter-spacing: 0.3px;
}

/* ============================================================
   Page Header
   ============================================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}

.page-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-primary);
  line-height: 1.2;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 3px;
}

/* ============================================================
   Avatar
   ============================================================ */
.avatar-circle {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  font-weight: 700;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.avatar-circle.sm { width: 32px; height: 32px; font-size: 11px; }
.avatar-circle.lg { width: 56px; height: 56px; font-size: 20px; }
.avatar-circle.xl { width: 80px; height: 80px; font-size: 28px; }

/* ============================================================
   Modals
   ============================================================ */
.modal-content {
  border: none;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}
.modal-header {
  border-bottom: 1px solid var(--border);
  padding: 20px 24px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.modal-title { font-weight: 700; font-size: 17px; }
.modal-body { padding: 24px; }
.modal-footer { padding: 16px 24px; border-top: 1px solid var(--border); }

/* ============================================================
   DataTables Overrides
   ============================================================ */
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
  font-size: 12.5px;
  margin-top: 12px;
}

.dataTables_wrapper .dataTables_filter input {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-family: var(--font);
}

/* ============================================================
   Dashboard Progress Bars
   ============================================================ */
.progress {
  height: 6px;
  border-radius: 20px;
  background: #f1f5f9;
}
.progress-bar {
  border-radius: 20px;
}

/* ============================================================
   Timeline
   ============================================================ */
.timeline {
  position: relative;
  padding-left: 30px;
}
.timeline::before {
  content: '';
  position: absolute;
  left: 10px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}
.timeline-item {
  position: relative;
  padding-bottom: 16px;
}
.timeline-item:last-child { padding-bottom: 0; }
.timeline-dot {
  position: absolute;
  left: -24px;
  top: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--primary);
  border: 2px solid white;
  box-shadow: 0 0 0 2px var(--primary);
}

/* ============================================================
   Profile Page
   ============================================================ */
.profile-cover {
  height: 180px;
  background: linear-gradient(135deg, #0f172a 0%, #1a56db 50%, #0ea5e9 100%);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  position: relative;
}
.profile-avatar-wrap {
  position: absolute;
  bottom: -40px;
  left: 28px;
}
.profile-avatar-wrap .avatar-circle {
  border: 4px solid white;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

/* ============================================================
   Login Page
   ============================================================ */
.login-page {
  min-height: 100vh;
  background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 40%, #0f172a 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.login-page::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(26,86,219,0.15) 0%, transparent 70%);
  top: -200px;
  right: -200px;
  border-radius: 50%;
}

.login-card {
  background: rgba(255,255,255,0.05);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: var(--radius-lg);
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 25px 60px rgba(0,0,0,0.3);
}

.login-card .form-control {
  background: rgba(255,255,255,0.08);
  border-color: rgba(255,255,255,0.15);
  color: white;
}
.login-card .form-control:focus {
  background: rgba(255,255,255,0.12);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(14,165,233,0.2);
}
.login-card .form-control::placeholder { color: rgba(255,255,255,0.4); }
.login-card .form-label { color: rgba(255,255,255,0.7); }

/* ============================================================
   Charts
   ============================================================ */
.chart-container { position: relative; }

/* ============================================================
   Utilities
   ============================================================ */
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.fw-700 { font-weight: 700; }
.fw-800 { font-weight: 800; }
.text-xs { font-size: 11px; }
.text-sm { font-size: 12.5px; }
.gap-10 { gap: 10px; }
.rounded-pill-sm { border-radius: 20px; }
.hover-shadow:hover { box-shadow: var(--shadow-md); transition: box-shadow 0.2s; }

.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.cursor-pointer { cursor: pointer; }

/* DataTable search bar clean */
div.dataTables_wrapper div.dataTables_filter label { display: flex; align-items: center; gap: 8px; }

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width) !important;
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .main-content { margin-left: 0 !important; }
  .sidebar-close { display: flex !important; }
  .page-content { padding: 16px; }
}

@media (max-width: 576px) {
  .stat-card { padding: 16px; }
  .stat-value { font-size: 20px; }
  .page-title { font-size: 18px; }
}

/* ============================================================
   Animations
   ============================================================ */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fadeInUp 0.3s ease forwards;
}

.stat-card:nth-child(1) { animation: fadeInUp 0.3s ease 0.05s both; }
.stat-card:nth-child(2) { animation: fadeInUp 0.3s ease 0.1s both; }
.stat-card:nth-child(3) { animation: fadeInUp 0.3s ease 0.15s both; }
.stat-card:nth-child(4) { animation: fadeInUp 0.3s ease 0.2s both; }
.stat-card:nth-child(5) { animation: fadeInUp 0.3s ease 0.25s both; }

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
