/* assets/css/main.css — Edificio Kados */

@import url('https://fonts.googleapis.com/css2?family=DM+Serif+Display:ital@0;1&family=DM+Sans:wght@300;400;500;600&display=swap');

/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
  --navy:       #1a3a5c;
  --navy-dark:  #0f2540;
  --navy-light: #2a5080;
  --gold:       #c8a96e;
  --gold-light: #e8d4a8;
  --cream:      #faf8f4;
  --white:      #ffffff;
  --gray-50:    #f8f9fa;
  --gray-100:   #f0f2f5;
  --gray-200:   #e5e9ef;
  --gray-400:   #9aa5b4;
  --gray-600:   #4a5568;
  --gray-800:   #1a202c;
  --green:      #2d7a4f;
  --green-bg:   #edf7f2;
  --red:        #c0392b;
  --red-bg:     #fdf0ee;
  --amber:      #d97706;
  --amber-bg:   #fffbeb;
  --radius:     10px;
  --shadow:     0 2px 12px rgba(0,0,0,.08);
  --shadow-lg:  0 8px 32px rgba(0,0,0,.12);
  --transition: .2s ease;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'DM Sans', sans-serif;
  background: var(--cream);
  color: var(--gray-800);
  min-height: 100vh;
  line-height: 1.6;
}

/* ── Typography ─────────────────────────────────────────────────────────── */
h1,h2,h3,h4 { font-family: 'DM Serif Display', serif; line-height: 1.2; }
h1 { font-size: 2rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.2rem; }
p  { color: var(--gray-600); }
a  { color: var(--navy); text-decoration: none; }
a:hover { color: var(--gold); }

/* ── Login page ─────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #0d0d0d;
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle at 20% 80%, rgba(200,169,110,.15) 0%, transparent 50%),
                    radial-gradient(circle at 80% 20%, rgba(200,169,110,.1) 0%, transparent 50%);
}
.login-box {
  background: #141414;
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 40px rgba(0,0,0,.6);
  border: 1px solid #222;
  position: relative;
  z-index: 1;
}
.login-logo {
  text-align: center;
  margin-bottom: 32px;
}
.login-logo .building-icon {
  width: 56px;
  height: 56px;
  background: var(--navy);
  border-radius: 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}
.login-logo h1 {
  color: var(--navy);
  font-size: 1.6rem;
  margin-bottom: 4px;
}
.login-logo p {
  font-size: 13px;
  color: var(--gray-400);
}

/* ── Layout: Sidebar + Main ─────────────────────────────────────────────── */
.app-layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: var(--navy-dark);
  color: var(--white);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  transition: transform var(--transition);
}

.sidebar-header {
  padding: 28px 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-header .app-name {
  font-family: 'DM Serif Display', serif;
  font-size: 1.3rem;
  color: var(--white);
  display: block;
}
.sidebar-header .app-sub {
  font-size: 11px;
  color: var(--gold-light);
  letter-spacing: .5px;
  text-transform: uppercase;
}

.sidebar-user {
  padding: 16px 24px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  display: flex;
  align-items: center;
  gap: 12px;
}
.sidebar-avatar {
  width: 38px;
  height: 38px;
  background: var(--gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 15px;
  color: var(--navy-dark);
  flex-shrink: 0;
}
.sidebar-user-info { flex: 1; min-width: 0; }
.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--white);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sidebar-user-role {
  font-size: 11px;
  color: var(--gold-light);
  text-transform: uppercase;
  letter-spacing: .5px;
}

.sidebar-nav { padding: 16px 12px; flex: 1; }
.nav-section-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,.3);
  padding: 12px 12px 6px;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 8px;
  color: rgba(255,255,255,.75);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
  cursor: pointer;
  text-decoration: none;
  margin-bottom: 2px;
}
.nav-item:hover, .nav-item.active {
  background: rgba(255,255,255,.1);
  color: var(--white);
}
.nav-item.active {
  background: rgba(200,169,110,.2);
  color: var(--gold-light);
}
.nav-icon { font-size: 18px; width: 22px; text-align: center; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--red);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 6px;
  border-radius: 10px;
}

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

/* ── Main content ───────────────────────────────────────────────────────── */
.main-content {
  margin-left: 260px;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  padding: 16px 32px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-title { font-family: 'DM Serif Display', serif; font-size: 1.3rem; color: var(--navy); }
.topbar-actions { display: flex; align-items: center; gap: 12px; }

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

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-family: 'DM Serif Display', serif; font-size: 1.1rem; color: var(--navy); }
.card-body { padding: 24px; }
.card-footer {
  padding: 16px 24px;
  background: var(--gray-50);
  border-top: 1px solid var(--gray-100);
}

/* ── Stat cards ─────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 28px;
}
.stat-card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 22px 24px;
  box-shadow: var(--shadow);
  border-left: 4px solid var(--navy);
  display: flex;
  align-items: center;
  gap: 16px;
}
.stat-card.green  { border-color: var(--green); }
.stat-card.amber  { border-color: var(--amber); }
.stat-card.red    { border-color: var(--red); }
.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}
.stat-card.green .stat-icon { background: var(--green-bg); }
.stat-card.amber .stat-icon { background: var(--amber-bg); }
.stat-card.red   .stat-icon { background: var(--red-bg); }
.stat-label { font-size: 12px; color: var(--gray-400); text-transform: uppercase; letter-spacing: .5px; }
.stat-value { font-family: 'DM Serif Display', serif; font-size: 1.5rem; color: var(--navy); line-height: 1.1; }

/* ── Forms ──────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 18px; }
.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--gray-600);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: 14px;
  font-family: 'DM Sans', sans-serif;
  color: var(--gray-800);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus {
  border-color: var(--navy);
  box-shadow: 0 0 0 3px rgba(26,58,92,.1);
}
.form-control.error { border-color: var(--red); }
.form-hint { font-size: 12px; color: var(--gray-400); margin-top: 4px; }
.form-error { font-size: 12px; color: var(--red); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  font-family: 'DM Sans', sans-serif;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  text-decoration: none;
  line-height: 1;
}
.btn-primary {
  background: var(--navy);
  color: var(--white);
}
.btn-primary:hover { background: var(--navy-light); color: var(--white); }
.btn-gold {
  background: var(--gold);
  color: var(--navy-dark);
}
.btn-gold:hover { background: #b8995e; color: var(--navy-dark); }
.btn-success { background: var(--green); color: #fff; }
.btn-success:hover { background: #226040; }
.btn-danger  { background: var(--red); color: #fff; }
.btn-danger:hover  { background: #a32a1f; }
.btn-outline {
  background: transparent;
  border: 1.5px solid var(--gray-200);
  color: var(--gray-600);
}
.btn-outline:hover { border-color: var(--navy); color: var(--navy); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-full { width: 100%; justify-content: center; }

/* ── Tables ─────────────────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead th {
  background: var(--gray-50);
  padding: 12px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--gray-400);
  border-bottom: 1px solid var(--gray-200);
}
tbody td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--gray-100);
  color: var(--gray-600);
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--gray-50); }

/* ── Badges / Status ────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}
.badge-success { background: var(--green-bg); color: var(--green); }
.badge-warning { background: var(--amber-bg); color: var(--amber); }
.badge-danger  { background: var(--red-bg);   color: var(--red); }
.badge-info    { background: #e8f0fe;          color: #1a73e8; }

/* ── Flash messages ─────────────────────────────────────────────────────── */
.flash {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 20px;
}
.flash-success { background: var(--green-bg); color: var(--green); }
.flash-error   { background: var(--red-bg);   color: var(--red); }
.flash-icon { font-weight: 700; font-size: 16px; }

/* ── Upload zone ────────────────────────────────────────────────────────── */
.upload-zone {
  border: 2px dashed var(--gray-200);
  border-radius: 10px;
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition);
}
.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--navy);
  background: rgba(26,58,92,.03);
}
.upload-zone .upload-icon { font-size: 36px; margin-bottom: 10px; }
.upload-zone p { font-size: 14px; color: var(--gray-400); margin: 0; }
.upload-zone strong { color: var(--navy); }

/* ── Modal ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }
.modal {
  background: var(--white);
  border-radius: 14px;
  width: 100%;
  max-width: 520px;
  box-shadow: var(--shadow-lg);
  transform: translateY(20px);
  transition: transform var(--transition);
}
.modal-overlay.open .modal { transform: translateY(0); }
.modal-header {
  padding: 20px 24px 16px;
  border-bottom: 1px solid var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-family: 'DM Serif Display', serif; font-size: 1.1rem; color: var(--navy); }
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: var(--gray-400);
  line-height: 1;
  padding: 2px 6px;
}
.modal-close:hover { color: var(--gray-800); }
.modal-body { padding: 24px; }
.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--gray-100);
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ── Balance card (residente) ───────────────────────────────────────────── */
.balance-hero {
  background: linear-gradient(135deg, var(--navy-dark), var(--navy));
  border-radius: 14px;
  padding: 32px;
  color: var(--white);
  position: relative;
  overflow: hidden;
  margin-bottom: 24px;
}
.balance-hero::before {
  content: '';
  position: absolute;
  right: -40px;
  top: -40px;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  background: rgba(200,169,110,.15);
}
.balance-hero .apt-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--gold-light);
  margin-bottom: 8px;
}
.balance-hero .balance-amount {
  font-family: 'DM Serif Display', serif;
  font-size: 2.5rem;
  color: var(--white);
  margin-bottom: 4px;
}
.balance-hero .balance-sub { font-size: 13px; color: rgba(255,255,255,.6); }

/* ── Responsive ─────────────────────────────────────────────────────────── */
.menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: var(--navy);
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0;
  }
  .menu-toggle { display: block; }
  .page-content { padding: 20px 16px; }
  .form-row { grid-template-columns: 1fr; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
}

/* ── Apartment grid (admin summary) ─────────────────────────────────────── */
.apt-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 14px;
}
.apt-card {
  background: var(--white);
  border: 2px solid var(--gray-200);
  border-radius: 10px;
  padding: 16px;
  text-align: center;
  transition: all var(--transition);
  position: relative;
}
.apt-card:hover { border-color: var(--navy); box-shadow: var(--shadow); }
.apt-card.has-debt { border-color: var(--amber); }
.apt-card.no-debt  { border-color: var(--green); }
.apt-number {
  font-family: 'DM Serif Display', serif;
  font-size: 1.4rem;
  color: var(--navy);
  display: block;
  margin-bottom: 4px;
}
.apt-balance {
  font-size: 13px;
  font-weight: 600;
}
.apt-balance.debt  { color: var(--amber); }
.apt-balance.clear { color: var(--green); }
