/* =====================================================
   Rentas Admin – Estilos principales
   Paleta: Navy #1E3A5F | Azul #2563EB | Ámbar #F59E0B
   ===================================================== */

:root {
  --navy:     #1E3A5F;
  --navy-2:   #16304f;
  --blue:     #2563EB;
  --blue-lt:  #EFF6FF;
  --amber:    #F59E0B;
  --green:    #10B981;
  --red:      #EF4444;
  --gray-50:  #F8FAFC;
  --gray-100: #F1F5F9;
  --gray-200: #E2E8F0;
  --gray-400: #94A3B8;
  --gray-600: #475569;
  --gray-800: #1E293B;
  --sidebar-w: 250px;
  --sidebar-w-collapsed: 70px;
  --topbar-h: 60px;
  --radius:   10px;
  --shadow:   0 1px 3px rgba(0,0,0,.08), 0 4px 16px rgba(0,0,0,.06);
}

/* ---- Reset ---- */
* { box-sizing: border-box; }
body {
  font-family: 'Inter', sans-serif;
  background: var(--gray-100);
  color: var(--gray-800);
  margin: 0;
  font-size: 14px;
}

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

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

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

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: #fff;
  font-weight: 700;
  font-size: 18px;
  white-space: nowrap;
}

.sidebar-toggle {
  color: rgba(255,255,255,.6);
  border: none;
  background: transparent;
  padding: 4px 8px;
  cursor: pointer;
  display: none;
}

.sidebar-menu {
  flex: 1;
  padding: 16px 8px;
  overflow-y: auto;
}

.sidebar-menu .nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  color: rgba(255,255,255,.65);
  padding: 10px 12px;
  border-radius: var(--radius);
  font-weight: 500;
  transition: all .2s;
  white-space: nowrap;
}

.sidebar-menu .nav-link:hover,
.sidebar-menu .nav-link.active {
  color: #fff;
  background: rgba(255,255,255,.12);
}

.sidebar-menu .nav-link.active {
  background: var(--blue);
}

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

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.user-avatar i {
  font-size: 28px;
  color: rgba(255,255,255,.5);
}

.user-details {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.user-name {
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  color: rgba(255,255,255,.45);
  font-size: 11px;
}

.btn-logout {
  color: rgba(255,255,255,.5);
  font-size: 18px;
  text-decoration: none;
  transition: color .2s;
  flex-shrink: 0;
}
.btn-logout:hover { color: var(--amber); }

/* ---- Main Content ---- */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  display: flex;
  flex-direction: column;
  transition: margin-left .25s ease;
  min-width: 0;
}

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

/* ---- Topbar ---- */
.topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.topbar-title { flex: 1; }
.topbar-title h5 { font-weight: 600; color: var(--gray-800); }
.topbar-toggle { border: none; background: transparent; color: var(--gray-600); }

/* =====================================================
   Cards & Widgets
   ===================================================== */
.card {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

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

.card-body { padding: 20px; }

/* Stat cards */
.stat-card {
  background: #fff;
  border-radius: var(--radius);
  padding: 20px;
  border: 1px solid var(--gray-200);
  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: #EFF6FF; color: var(--blue); }
.stat-icon.green  { background: #ECFDF5; color: var(--green); }
.stat-icon.amber  { background: #FFFBEB; color: var(--amber); }
.stat-icon.red    { background: #FEF2F2; color: var(--red); }
.stat-icon.navy   { background: #EEF2FF; color: var(--navy); }

.stat-value {
  font-size: 24px;
  font-weight: 700;
  color: var(--gray-800);
  line-height: 1;
}

.stat-label {
  font-size: 12px;
  color: var(--gray-400);
  margin-top: 4px;
}

/* =====================================================
   Tables
   ===================================================== */
.table {
  font-size: 14px;
}

.table thead th {
  background: var(--gray-50);
  color: var(--gray-600);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .04em;
  border-bottom: 1px solid var(--gray-200);
  padding: 10px 16px;
}

.table td {
  padding: 12px 16px;
  vertical-align: middle;
  border-color: var(--gray-200);
  color: var(--gray-800);
}

.table tbody tr:hover { background: var(--gray-50); }

/* =====================================================
   Badges & Status
   ===================================================== */
.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.badge-available  { background: #ECFDF5; color: #059669; }
.badge-rented     { background: #EFF6FF; color: #2563EB; }
.badge-maintenance{ background: #FFFBEB; color: #D97706; }
.badge-active     { background: #ECFDF5; color: #059669; }
.badge-finished   { background: #F1F5F9; color: #64748B; }
.badge-cancelled  { background: #FEF2F2; color: #EF4444; }
.badge-paid       { background: #ECFDF5; color: #059669; }
.badge-unpaid     { background: #FFF7ED; color: #EA580C; }
.badge-overdue    { background: #FEF2F2; color: #EF4444; }

/* =====================================================
   Forms
   ===================================================== */
.form-label {
  font-weight: 500;
  color: var(--gray-600);
  font-size: 13px;
  margin-bottom: 5px;
}

.form-control, .form-select {
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 14px;
  transition: border-color .2s, box-shadow .2s;
}

.form-control:focus, .form-select:focus {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
  outline: none;
}

.form-control.is-invalid { border-color: var(--red); }
.invalid-feedback { font-size: 12px; color: var(--red); }

/* Checkboxes */
.form-check-input:checked {
  background-color: var(--blue);
  border-color: var(--blue);
}

/* =====================================================
   Buttons
   ===================================================== */
.btn {
  font-weight: 500;
  font-size: 14px;
  border-radius: 8px;
  padding: 8px 16px;
  transition: all .2s;
}

.btn-primary {
  background: var(--blue);
  border-color: var(--blue);
}
.btn-primary:hover { background: #1d4ed8; border-color: #1d4ed8; }

.btn-success {
  background: var(--green);
  border-color: var(--green);
}

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

.btn-outline-secondary {
  border-color: var(--gray-200);
  color: var(--gray-600);
}
.btn-outline-secondary:hover { background: var(--gray-100); border-color: var(--gray-400); }

.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-xs { padding: 3px 8px;  font-size: 11px; }

/* Botón pagar */
.btn-pay {
  background: var(--green);
  color: #fff;
  border: none;
  padding: 5px 12px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: background .2s;
}
.btn-pay:hover { background: #059669; }

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

.page-header h4 {
  font-weight: 700;
  margin: 0;
  color: var(--gray-800);
}

/* =====================================================
   Flash alerts
   ===================================================== */
.flash-alert {
  position: fixed;
  top: 80px;
  right: 24px;
  z-index: 9999;
  min-width: 300px;
  max-width: 420px;
  border-radius: 10px;
  box-shadow: 0 4px 24px rgba(0,0,0,.12);
  animation: slideIn .3s ease;
}

@keyframes slideIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

/* =====================================================
   Photo / Document upload preview
   ===================================================== */
.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap: 8px;
  margin-top: 8px;
}

.photo-thumb {
  position: relative;
  border-radius: 8px;
  overflow: hidden;
  aspect-ratio: 1;
  border: 1px solid var(--gray-200);
}

.photo-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.photo-thumb .delete-photo {
  position: absolute;
  top: 4px; right: 4px;
  background: rgba(239,68,68,.85);
  color: #fff;
  border: none;
  width: 22px; height: 22px;
  border-radius: 50%;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity .2s;
}
.photo-thumb:hover .delete-photo { opacity: 1; }

/* =====================================================
   Dashboard specific
   ===================================================== */
.overdue-table .overdue-days {
  font-weight: 700;
  color: var(--red);
}

.balance-positive { color: var(--green); }
.balance-negative { color: var(--red); }

/* Month selector */
.month-filter {
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

/* =====================================================
   Login page
   ===================================================== */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, #2563EB 100%);
  padding: 20px;
}

.login-card {
  background: #fff;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 20px 60px rgba(0,0,0,.2);
}

.login-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 32px;
}

.login-logo svg { flex-shrink: 0; }
.login-logo h2 { margin: 0; font-weight: 700; color: var(--navy); }

/* =====================================================
   Property / Tenant detail
   ===================================================== */
.detail-row {
  display: flex;
  gap: 8px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
}
.detail-row:last-child { border-bottom: none; }
.detail-label { width: 160px; flex-shrink: 0; color: var(--gray-400); font-size: 13px; }
.detail-value { font-weight: 500; color: var(--gray-800); }

/* =====================================================
   Payments timeline
   ===================================================== */
.payment-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--gray-100);
}
.payment-item:last-child { border-bottom: none; }

.payment-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.payment-dot.paid    { background: var(--green); }
.payment-dot.pending { background: var(--amber); }
.payment-dot.overdue { background: var(--red); }

/* =====================================================
   Responsive
   ===================================================== */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-w);
  }

  .sidebar.open { transform: translateX(0); }

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

  .main-content { margin-left: 0; }

  .page-content { padding: 16px; }

  .stat-card { padding: 16px; }
  .stat-value { font-size: 20px; }
}

@media (min-width: 769px) {
  .topbar-toggle { display: none; }
}

/* =====================================================
   Notification badge (sidebar)
   ===================================================== */
.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 6px;
  border-radius: 999px;
  min-width: 18px;
  text-align: center;
  line-height: 16px;
}

/* =====================================================
   Notification cards (panel)
   ===================================================== */
.notif-card {
  border-left: 4px solid var(--gray-200);
  border-radius: var(--radius);
  background: #fff;
  padding: 14px 18px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.notif-card.danger  { border-color: var(--red); }
.notif-card.warning { border-color: var(--amber); }
.notif-card.info    { border-color: #0ea5e9; }
.notif-card.success { border-color: var(--green); }

.notif-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.notif-icon.danger  { background: #FEF2F2; color: var(--red); }
.notif-icon.warning { background: #FFFBEB; color: var(--amber); }
.notif-icon.info    { background: #F0F9FF; color: #0ea5e9; }
.notif-icon.success { background: #ECFDF5; color: var(--green); }

.notif-body { flex: 1; min-width: 0; }
.notif-title { font-weight: 600; color: var(--gray-800); font-size: 14px; }
.notif-msg   { color: var(--gray-600); font-size: 13px; margin-top: 2px; }
.notif-date  { color: var(--gray-400); font-size: 11px; margin-top: 4px; }

/* =====================================================
   Scrollbar
   ===================================================== */
.sidebar-menu::-webkit-scrollbar { width: 4px; }
.sidebar-menu::-webkit-scrollbar-track { background: transparent; }
.sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 4px; }
