/* ==========================================================
   Tenant Systems - Custom Styles (Bootstrap 5.3)
   ========================================================== */

/* --- Variables Overrides --- */
:root {
  --sidebar-width: 250px;
  --topbar-height: 56px;
  --app-primary: #4f46e5;
  --app-primary-dark: #3730a3;
  --app-success: #059669;
  --app-danger: #dc2626;
  --app-warning: #d97706;
  --app-info: #0284c7;
  --sidebar-bg: #1e293b;
  --sidebar-hover: #334155;
  --sidebar-active: #4f46e5;
  --card-radius: 0.75rem;
}

/* --- Base Body --- */
body {
  background-color: #f1f5f9;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
  overflow-x: hidden;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--sidebar-bg) !important;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1040;
  transition: transform 0.3s ease;
  overflow-y: auto;
}

.sidebar .sidebar-link {
  color: #94a3b8;
  padding: 0.6rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.9rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
}

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

.sidebar .sidebar-link.active {
  background: var(--sidebar-active);
  color: #fff;
  font-weight: 500;
}

/* --- Main Content --- */
.main-content {
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

/* --- Topbar --- */
.topbar {
  min-height: var(--topbar-height);
  background: #fff !important;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.topbar .breadcrumb a {
  color: #64748b;
}

/* --- Cards --- */
.card {
  border: none;
  border-radius: var(--card-radius);
  box-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  transition: box-shadow 0.2s;
}

.card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.08), 0 2px 4px rgba(0,0,0,0.04);
}

.card-header {
  background: transparent;
  border-bottom: 1px solid #e9ecef;
  font-weight: 600;
  padding: 1rem 1.25rem;
}

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

.table thead th {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #64748b;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 0.75rem 1rem;
}

.table tbody td {
  padding: 0.75rem 1rem;
  vertical-align: middle;
}

.table-hover tbody tr:hover {
  background-color: #f1f5f9;
}

/* --- Badges (Status) --- */
.badge {
  font-weight: 500;
  padding: 0.35em 0.75em;
  border-radius: 100px;
  --bs-badge-color: #000;
  color: #000 !important;
}

.badge-active, .badge-active_lease, .badge-active_booking,
.badge-completed, .badge-success, .bg-success {
  background: #dcfce7 !important;
}

.badge-pending, .bg-warning, .badge-pending_payment {
  background: #fef3c7 !important;
}

.badge-expired, .badge-expired_lease, .badge-cancelled,
.badge-failed, .bg-danger {
  background: #fee2e2 !important;
}

.badge-draft, .badge-available, .bg-info {
  background: #e0f2fe !important;
}

.badge-occupied, .badge-booked {
  background: #fce7f3 !important;
}

.badge-confirmed {
  background: #dcfce7 !important;
}

.badge-checked_in {
  background: #dbeafe !important;
}

.badge-checked_out {
  background: #e0f2fe !important;
}

.badge-maintenance {
  background: #f3e8ff !important;
}

/* --- Buttons --- */
.btn-primary {
  background-color: var(--app-primary);
  border-color: var(--app-primary);
}

.btn-primary:hover, .btn-primary:active {
  background-color: var(--app-primary-dark) !important;
  border-color: var(--app-primary-dark) !important;
}

.btn-outline-primary {
  color: var(--app-primary);
  border-color: var(--app-primary);
}

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

/* --- Forms --- */
.form-control, .form-select {
  border-radius: 0.5rem;
  border-color: #d1d5db;
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.form-control:focus, .form-select:focus {
  border-color: var(--app-primary);
  box-shadow: 0 0 0 0.2rem rgba(79, 70, 229, 0.15);
}

.form-label {
  font-weight: 500;
  font-size: 0.85rem;
  color: #374151;
  margin-bottom: 0.35rem;
}

.form-check-input:checked {
  background-color: var(--app-primary);
  border-color: var(--app-primary);
}

/* --- Alerts --- */
.alert {
  border: none;
  border-radius: var(--card-radius);
}

/* --- Footer --- */
.footer {
  background: #fff;
  color: #94a3b8;
}

/* --- Sidebar Overlay (mobile) --- */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1030;
}

.sidebar-overlay.show {
  display: block;
}

/* ==========================================================
   Dashboard Stat Cards – Modern Glassmorphism Design
   ========================================================== */
.stat-card {
  position: relative;
  border: none;
  border-radius: 1rem;
  padding: 1.5rem;
  overflow: hidden;
  transition: all 0.3s ease;
  cursor: default;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  opacity: 0.08;
  background: radial-gradient(circle at 20% 50%, rgba(255,255,255,0.8) 0%, transparent 60%);
  pointer-events: none;
}

.stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px rgba(0,0,0,0.12);
}

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

.stat-card .stat-label {
  font-size: 0.8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  opacity: 0.85;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.02em;
}

.stat-card .stat-footer {
  font-size: 0.8rem;
  opacity: 0.8;
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

/* Individual stat card color variants */
.stat-card.stat-properties {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
}
.stat-card.stat-properties .stat-icon {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

.stat-card.stat-tenants {
  background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%);
  color: #fff;
}
.stat-card.stat-tenants .stat-icon {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

.stat-card.stat-leases {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: #fff;
}
.stat-card.stat-leases .stat-icon {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

.stat-card.stat-revenue {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: #fff;
}
.stat-card.stat-revenue .stat-icon {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

.stat-card.stat-bookings {
  background: linear-gradient(135deg, #fa709a 0%, #fee140 100%);
  color: #fff;
}
.stat-card.stat-bookings .stat-icon {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

.stat-card.stat-occupancy {
  background: linear-gradient(135deg, #a18cd1 0%, #fbc2eb 100%);
  color: #fff;
}
.stat-card.stat-occupancy .stat-icon {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

.stat-card.stat-guests {
  background: linear-gradient(135deg, #ffecd2 0%, #fcb69f 100%);
  color: #5a3e2b;
}
.stat-card.stat-guests .stat-icon {
  background: rgba(0,0,0,0.1);
  color: #5a3e2b;
}

.stat-card.stat-units {
  background: linear-gradient(135deg, #89f7fe 0%, #66a6ff 100%);
  color: #1a365d;
}
.stat-card.stat-units .stat-icon {
  background: rgba(0,0,0,0.1);
  color: #1a365d;
}

/* --- Notification Alerts (Dashboard) --- */
.alert-notification {
  background: #fff;
  border: none;
  border-radius: 0.75rem;
  padding: 1rem 1.25rem;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  border-left: 4px solid #d1d5db;
  transition: all 0.2s;
}
.alert-notification:hover {
  transform: translateX(4px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}
.alert-notification .alert-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.alert-notification.alert-expiring {
  background: #fff7ed;
  border-left-color: #f97316;
}
.alert-notification.alert-expiring .alert-icon {
  background: #ffedd5;
  color: #ea580c;
}
.alert-notification.alert-expiring .days-badge {
  background: #fed7aa;
  color: #9a3412;
}
.alert-notification.alert-checkout {
  background: #f0fdf4;
  border-left-color: #22c55e;
}
.alert-notification.alert-checkout .alert-icon {
  background: #dcfce7;
  color: #16a34a;
}
.alert-notification.alert-checkout .days-badge {
  background: #bbf7d0;
  color: #166534;
}
.alert-notification.alert-pending {
  background: #eff6ff;
  border-left-color: #3b82f6;
}
.alert-notification.alert-pending .alert-icon {
  background: #dbeafe;
  color: #2563eb;
}
.alert-notification.alert-pending .days-badge {
  background: #bfdbfe;
  color: #1e40af;
}
.alert-notification .days-badge {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* --- Dropdown status color classes (for quick-status menu items) --- */
.color-pending { color: #92400e !important; }
.color-pending .bi-circle-fill { color: #92400e !important; }
.color-confirmed { color: #166534 !important; }
.color-confirmed .bi-circle-fill { color: #166534 !important; }
.color-checked_in { color: #1e40af !important; }
.color-checked_in .bi-circle-fill { color: #1e40af !important; }
.color-checked_out { color: #075985 !important; }
.color-checked_out .bi-circle-fill { color: #075985 !important; }
.color-cancelled { color: #991b1b !important; }
.color-cancelled .bi-circle-fill { color: #991b1b !important; }

/* --- Responsive --- */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.show {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
}

@media (min-width: 992px) {
  .sidebar-overlay {
    display: none !important;
  }
}

/* --- Empty State --- */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
}

.empty-state i {
  font-size: 3rem;
  color: #cbd5e1;
  margin-bottom: 1rem;
  display: block;
}

/* --- Smooth Scrollbar --- */
::-webkit-scrollbar {
  width: 6px;
}

::-webkit-scrollbar-track {
  background: #e2e8f0;
}

::-webkit-scrollbar-thumb {
  background: #94a3b8;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #64748b;
}

/* --- Login Page --- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
  width: 100%;
  max-width: 420px;
  border: none;
  border-radius: 1rem;
  box-shadow: 0 20px 60px rgba(0,0,0,0.15);
}

/* --- Dashboard SMS Quick Send Card --- */
#dashboardSmsForm .input-group .dropdown-menu a.quick-sms-template {
  font-size: 0.85rem;
  padding: 0.4rem 1rem;
}
#dashboardSmsForm .input-group .dropdown-menu a.quick-sms-template:hover {
  background-color: var(--app-primary);
  color: #fff;
}

/* --- SMS Settings Page --- */
#manualSmsForm .quick-template {
  font-size: 0.78rem;
  white-space: nowrap;
}
#smsResult.alert, #dashSmsResult.alert {
  margin-bottom: 0;
}
