/* ===========================================
   SISTEMA TESORERÍA
   Colegio José Andrés Rázuri
   Promoción Manuel Scorza 1985
=========================================== */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&display=swap');

:root {
  --primary: #7B1128;
  --primary-dark: #5C0C1D;
  --primary-light: #A11D37;

  --gold: #C9A227;

  --success: #16A34A;
  --danger: #DC2626;
  --warning: #F59E0B;
  --info: #2563EB;

  --bg: #F4F6F9;
  --card: #FFFFFF;

  --text: #1F2937;
  --text2: #6B7280;

  --border: #E5E7EB;

  --radius: 16px;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: 'Poppins', sans-serif;
  background: var(--bg);
  color: var(--text);
}

/* ===========================================
   ESTRUCTURA GENERAL Y SIDEBAR FLEXBOX
=========================================== */

.app-container {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 260px;
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  color: white;
  display: flex !important;
  flex-direction: column !important;
  justify-content: space-between !important;
  position: fixed;
  height: 100vh;
  left: 0;
  top: 0;
  z-index: 1000;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 15px;
  padding: 25px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.brand-logo {
  width: 45px;
  height: 45px;
  background: var(--gold);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 22px;
}

.sidebar-brand h5 {
  margin: 0;
  font-weight: 700;
}

.sidebar-brand small {
  opacity: 0.8;
}

/* MENÚ CON SCROLL INTERNO */
.sidebar-menu {
  list-style: none;
  padding: 15px;
  margin: 0;
  overflow-y: auto;
  max-height: calc(100vh - 180px);
}

.sidebar-menu::-webkit-scrollbar {
  width: 4px;
}

.sidebar-menu::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
}

.sidebar-menu li {
  margin-bottom: 8px;
}

.sidebar-menu a {
  display: flex;
  align-items: center;
  gap: 15px;
  color: white;
  text-decoration: none;
  padding: 12px 15px;
  border-radius: 12px;
  transition: 0.3s;
  font-weight: 500;
}

.sidebar-menu a i {
  width: 22px;
  text-align: center;
}

.sidebar-menu a:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateX(5px);
}

/* SIDEBAR FOOTER & BOTÓN SALIR */
.sidebar-footer {
  padding: 15px;
  background: rgba(0, 0, 0, 0.2);
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  margin-top: auto !important;
}

.user-box {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.user-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.3);
  display: block;
}

.logout-btn {
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 8px !important;
  width: 100% !important;
  padding: 10px !important;
  background: var(--gold) !important;
  color: #222 !important;
  border-radius: 12px !important;
  text-align: center !important;
  font-weight: 700 !important;
  text-decoration: none !important;
  transition: 0.3s ease;
}

.logout-btn:hover {
  background: #ffffff !important;
  color: var(--primary) !important;
}

/* MAIN CONTENT WRAPPER */
.main-wrapper {
  margin-left: 260px;
  width: calc(100% - 260px);
  padding: 25px;
}

.top-header {
  margin-left: 260px;
}

/* ===========================================
   NAVBAR
=========================================== */

.navbar {
  background: linear-gradient(90deg, var(--primary), var(--primary-dark)) !important;
  padding: 12px 20px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.12);
}

.navbar-brand {
  font-size: 24px;
  font-weight: 700;
  color: #fff !important;
}

.navbar-brand i {
  color: var(--gold);
  margin-right: 8px;
}

.nav-link {
  color: #fff !important;
  font-weight: 500;
  margin: 0 4px;
  border-radius: 8px;
  padding: 9px 14px !important;
  transition: 0.25s;
}

.nav-link:hover {
  background: rgba(255, 255, 255, 0.12);
}

.nav-link.active {
  background: rgba(255, 255, 255, 0.18);
}

/* ===========================================
   CONTENEDOR Y TARJETAS
=========================================== */

.container-fluid {
  padding: 30px;
}

.card {
  border: none;
  border-radius: 18px;
  background: white;
  box-shadow: 0 8px 30px rgba(15, 23, 42, 0.08);
  overflow: hidden;
  transition: 0.25s;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.12);
}

.card-header {
  background: white;
  font-weight: 700;
  border-bottom: 1px solid #eee;
  padding: 18px 25px;
  color: var(--primary);
  font-size: 18px;
}

.card-header i {
  color: var(--gold);
  margin-right: 8px;
}

/* ===========================================
   DASHBOARD CARDS & WELCOME BOX
=========================================== */

.dashboard-content {
  padding-top: 10px;
}

.welcome-box {
  background: white;
  border-radius: 20px;
  padding: 25px 30px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  margin-bottom: 20px;
}

.welcome-info {
  display: flex;
  align-items: center;
  gap: 22px;
}

.welcome-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

.welcome-escudo {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  filter: drop-shadow(0px 4px 6px rgba(0, 0, 0, 0.15));
}

.welcome-box h2 {
  margin: 0;
  font-size: 28px;
  font-weight: 700;
  color: var(--primary);
}

.welcome-box h5 {
  margin: 5px 0 10px;
  font-size: 16px;
  font-weight: 600;
  color: var(--gold);
}

.welcome-box p {
  margin: 0;
  color: var(--text2);
  font-size: 15px;
  line-height: 1.7;
}

/* DASHBOARD CARDS GRID */
.row.g-4 {
  align-items: stretch;
}

.row.g-4 > div {
  display: flex;
}

.dashboard-card {
  width: 100%;
  height: 220px;
  min-height: 220px;
  padding: 28px;
  border-radius: 20px;
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
  box-shadow: 0 15px 35px rgba(0, 0, 0, 0.15);
  transition: 0.3s;
}

.dashboard-card:hover {
  transform: translateY(-6px);
  box-shadow: 0 20px 45px rgba(0, 0, 0, 0.22);
}

.dashboard-card i {
  position: absolute;
  right: 25px;
  top: 25px;
  font-size: 65px;
  opacity: 0.18;
}

.dashboard-card h5 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: white;
}

.dashboard-card h2 {
  margin: 0;
  font-size: 32px;
  font-weight: 800;
  line-height: 1;
}

.dashboard-card span {
  font-size: 14px;
  opacity: 0.85;
}

/* GRADIENTES TARJETAS */
.bg-ingresos {
  background: linear-gradient(135deg, #15803d, #22c55e);
}

.bg-gastos {
  background: linear-gradient(135deg, #991b1b, #ef4444);
}

.bg-saldo {
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
}

.bg-pendientes {
  background: linear-gradient(135deg, #b45309, #f59e0b);
}

/* ===========================================
   TABLAS Y MÓDULOS
=========================================== */

.module-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: white;
  padding: 25px;
  border-radius: 18px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.06);
  margin-bottom: 20px;
}

.module-header h2 {
  font-weight: 700;
  color: var(--primary);
  margin: 0;
}

.module-header h2 i {
  color: var(--gold);
  margin-right: 10px;
}

.module-header p {
  margin: 5px 0 0;
  color: #64748b;
}

.table-responsive {
  border-radius: 15px;
}

.table {
  background: white;
  border-radius: 15px;
  overflow: hidden;
  margin-bottom: 0;
}

.table thead th {
  background: var(--primary);
  color: white;
  font-weight: 600;
  border: none;
  padding: 15px;
  font-size: 14px;
}

.table tbody td {
  padding: 14px;
  vertical-align: middle;
  color: #374151;
}

.table tbody tr {
  transition: 0.25s;
}

.table-hover tbody tr:hover {
  background: #fff7f8;
}

/* ===========================================
   FORMULARIOS Y BOTONES
=========================================== */

.form-label {
  font-weight: 600;
  color: #374151;
}

.form-label i {
  color: var(--primary);
  margin-right: 6px;
}

.form-control,
.form-select {
  height: 48px;
  border-radius: 12px;
  border: 1px solid #d6d6d6;
  box-shadow: none;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 0.18rem rgba(123, 17, 40, 0.15);
}

.input-group-text {
  background: var(--primary);
  color: white;
  border: none;
  font-weight: 600;
  width: 48px;
  justify-content: center;
}

.btn {
  border-radius: 12px;
  padding: 10px 18px;
  font-weight: 600;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.btn-success {
  background: #15803d;
  border: none;
}

.btn-success:hover {
  background: #166534;
}

.btn-warning {
  background: var(--gold);
  border: none;
  color: #222;
}

.badge {
  padding: 8px 12px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 30px;
}

/* ===========================================
   LOGIN INSTITUCIONAL (CORREGIDO)
=========================================== */

.login-body {
  min-height: 100vh;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 30px;
}

.login-card {
  width: 430px;
  background: white;
  border-radius: 25px;
  overflow: hidden;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.3);
  animation: fadeLogin 0.5s ease;
  position: relative;
}

.login-header {
  background: linear-gradient(135deg, var(--primary), #4d0818);
  padding: 35px 25px 25px 25px;
  text-align: center;
  color: white;
  position: relative;
}

/* CIRCULO CONTENEDOR DEL ESCUDO */
.login-logo {
  width: 90px !important;
  height: 90px !important;
  min-width: 90px !important;
  min-height: 90px !important;
  max-width: 90px !important;
  max-height: 90px !important;
  margin: 0 auto 15px auto !important;
  background: var(--gold) !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25) !important;
  padding: 8px !important;
  overflow: hidden !important;
}

/* IMAGEN DEL ESCUDO DENTRO DEL CIRCULO */
.login-logo img,
.login-header img {
  width: 100% !important;
  height: 100% !important;
  max-width: 70px !important;
  max-height: 70px !important;
  object-fit: contain !important;
  display: block !important;
  margin: 0 auto !important;
}

.login-header h2 {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 4px;
  color: #ffffff;
}

.login-header h5 {
  font-size: 15px;
  font-weight: 500;
  margin-bottom: 10px;
  color: #ffffff;
}

.login-header p {
  margin: 0;
  font-size: 13px;
  opacity: 0.85;
  color: #ffffff;
}

.login-content {
  padding: 30px 35px 25px 35px;
  background: #ffffff;
}

.login-content label {
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
  display: block;
}

.btn-login {
  width: 100%;
  height: 52px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: white;
  font-size: 16px;
  font-weight: 700;
  transition: 0.3s;
  margin-top: 10px;
}

.btn-login:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px rgba(123, 17, 40, 0.35);
}

.login-footer {
  background: #f8f9fa;
  padding: 18px;
  text-align: center;
  font-size: 13px;
  color: var(--text2);
  border-top: 1px solid #ececec;
}

.login-footer i {
  color: var(--gold);
  margin-right: 6px;
}

/* ===========================================
   RESPONSIVE DESIGN
=========================================== */

@media (max-width: 768px) {
  .app-container {
    display: block;
  }

  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
  }

  .sidebar-menu {
    max-height: none;
  }

  .main-wrapper,
  .top-header {
    margin-left: 0;
    width: 100%;
  }

  .container-fluid {
    padding: 15px;
  }

  .dashboard-card {
    height: 200px;
    margin-bottom: 15px;
  }

  .welcome-info {
    flex-direction: column;
    text-align: center;
  }

  .module-header {
    display: block;
  }

  .module-header .btn {
    margin-top: 15px;
    width: 100%;
  }

  .login-card {
    width: 100%;
  }

  .login-content {
    padding: 25px;
  }
}