/* ==========================================================================
   RESET Y BASE
   ========================================================================== */

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

body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: #ffffff;
  color: #20504c;
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
}

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ==========================================================================
   LOADER
   ========================================================================== */

#loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #ffffff;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 10000;
}

.spinner {
  width: 60px;
  height: 60px;
  border: 4px solid #20504c;
  border-left-color: transparent;
  border-bottom-color: transparent;
  border-radius: 50%;
  animation: spin 0.8s ease-in-out infinite;
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(255, 255, 255, 0.8);
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 9999;
}

.loading-spinner {
  border: 5px solid #f3f3f3;
  border-top: 5px solid #009879;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  animation: spin 1s linear infinite;
  margin-bottom: 15px;
}

#loader p {
  margin-top: 0.75em;
  color: #20504c;
  font-size: 1em;
}

/* ==========================================================================
   MENU HAMBURGUESA
   ========================================================================== */

.menu-toggle {
  display: none;
  position: fixed;
  top: 15px;
  left: 15px;
  z-index: 1000;
  background: #20504c;
  color: white;
  border: none;
  border-radius: 8px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  transition: all 0.3s ease;
  justify-content: center;
  align-items: center;
}

.menu-toggle:hover {
  background: #183f3b;
}

.menu-toggle.active {
  transform: translateX(220px);
}

.menu-toggle i {
  font-size: 1.2em;
}

/* ==========================================================================
   SIDEBAR
   ========================================================================== */

.sidebar {
  width: 260px;
  background: #ffffff;
  padding: 2em 1.5em;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  position: fixed;
  height: 100vh;
  z-index: 999;
}
.sidebar.hidden {
  transform: translateX(-100%);
}

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

/* Logo */
.sidebar .logo {
  font-size: 1.8em;
  font-weight: bold;
  margin-bottom: 3em;
  display: flex;
  align-items: center;
  color: #20504c;
}

.sidebar .logo .star {
  font-size: 1.4em;
  margin-left: 0.5em;
}


/* Navegación */
.sidebar nav ul {
  list-style: none;
  padding: 0;
}

.sidebar nav ul li {
  margin-bottom: 2em;
  position: relative;
}

.sidebar nav ul li a {
  text-decoration: none;
  color: #20504c;
  display: flex;
  align-items: center;
  font-size: 1em;
  padding: 0.5em 0;
  transition: color 0.2s ease;
  pointer-events: none; /* Para enlaces inactivos */
}

.sidebar nav ul li a:hover {
  color: #183f3b;
}

.sidebar nav ul li a i {
  margin-right: 0.75em;
  font-size: 1.4em;
  min-width: 24px;
}

/* Submenús */
.sidebar nav ul li.has-sub > a {
  justify-content: space-between;
  cursor: pointer;
}

.sidebar nav ul li .sub-menu {
  list-style: none;
  padding-left: 2.5em;
  margin-top: 1em;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding-top 0.3s ease;
}

.sidebar nav ul li.has-sub.active .sub-menu {
  max-height: 200px;
  padding-top: 0.5em;
}

.sidebar nav ul li .sub-menu li {
  margin-bottom: 1.5em;
}

.sidebar nav ul li .sub-menu li a {
  font-size: 0.95em;
  color: #20504c;
  padding: 0.3em 0;
}

.sidebar nav ul li .sub-menu li a:hover {
  color: #183f3b;
}

.sidebar nav ul li .chevron {
  transition: transform 0.3s ease;
}

.sidebar nav ul li.has-sub.active .chevron {
  transform: rotate(180deg);
}

/* ==========================================================================
   ÁREA DE CONTENIDO
   ========================================================================== */

.content {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  margin-left: 260px;
  transition: margin-left 0.3s ease;
}

.content.full-width {
  margin-left: 0;
}

/* ==========================================================================
   HEADER
   ========================================================================== */

header {
  padding: 1em 1.5em;
  background: #ffffff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

header .back-btn {
  text-decoration: none;
  font-size: 1.8em;
  font-weight: 700;
  color: #009879;
  margin-right: 1em;
}

header .mobile-title {
  display: none;
  font-size: 1.4em;
  color: #222;
  margin-left: 0.5em;
  flex: 1;
  text-align: center;
}

header .supply {
  flex: 1;
  font-size: 1em;
  color: #555;
}

header .office-btn {
  text-decoration: none;
  background: #009879;
  color: #fff;
  padding: 0.5em 1em;
  border-radius: 4px;
  transition: background 0.2s ease;
}

header .office-btn:hover {
  background: #007D63;
}

/* ==========================================================================
   MAIN CONTENT
   ========================================================================== */

main {
  flex: 1;
  padding: 2em;
}

/* ==========================================================================
   CARDS Y FORMULARIOS
   ========================================================================== */

.card {
  background: #ffffff;
  padding: 2em;
  border-radius: 8px;
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
  max-width: 400px;
  width: 100%;
  text-align: center;
}

.payment-card,
.payment-result {
  background: #fff;
  padding: 2em;
  border-radius: 8px;
  box-shadow: 0 2px 15px rgba(0, 0, 0, 0.1);
  max-width: 500px;
  width: 100%;
}

.payment-card h1,
.payment-result h2 {
  text-align: center;
  margin-bottom: 1.5em;
  color: #20504c;
}

.icon {
  font-size: 3em;
  color: #20504c;
  margin-bottom: 0.5em;
}

.result-icon {
  text-align: center;
  font-size: 3em;
  margin-bottom: 20px;
}

.result-icon.success {
  color: #009879;
}

.result-icon.error {
  color: #e74c3c;
}

/* ==========================================================================
   TIPOS DE TARJETA
   ========================================================================== */

.card-types {
  display: flex;
  gap: 0.5em;
  margin-bottom: 1.5em;
}

.card-type {
  flex: 1;
  text-align: center;
  padding: 1em;
  border: 1px solid #ddd;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}

.card-type.selected {
  border-color: #009879;
  background: rgba(0, 152, 121, 0.1);
}

.card-type i {
  font-size: 1.5em;
  margin-bottom: 0.5em;
}

/* ==========================================================================
   FORMULARIOS
   ========================================================================== */

form {
  text-align: left;
}

.form-group {
  margin-bottom: 1.5em;
}

.form-group label {
  display: block;
  margin-bottom: 0.5em;
  font-weight: 600;
  color: #20504c;
}

.form-group input,
.form-group select,
input[type="text"] {
  width: 100%;
  padding: 0.75em;
  border: 1px solid #ddd;
  border-radius: 4px;
  transition: border-color 0.2s;
  font-size: 1em;
}

.form-group input:focus,
.form-group select:focus,
input[type="text"]:focus {
  border-color: #20504c;
  outline: none;
}

.invalid {
  border-color: #e74c3c !important;
  box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

.error-message {
  color: #e74c3c;
  text-align: center;
  margin: 20px 0;
  font-weight: bold;
}

/* ==========================================================================
   BOTONES
   ========================================================================== */

button,
.btn-pay,
.btn-retry {
  width: 100%;
  padding: 0.9em;
  background: #20504c;
  color: #ffffff;
  border: none;
  border-radius: 4px;
  font-size: 1em;
  cursor: pointer;
  transition: background 0.2s ease;
}

button:hover,
.btn-pay:hover,
.btn-retry:hover {
  background: #183f3b;
}

.btn-pay,
.btn-retry {
  background: #009879;
  padding: 0.75em;
  margin-top: 0.5em;
}

.btn-pay:hover,
.btn-retry:hover {
  background: #007D63;
}

.btn-next-fixed {
  display: none;
}

.btn-next-mobile {
  display: none;
}

/* ==========================================================================
   STEPS Y PANELES
   ========================================================================== */

.step h2 {
  font-size: 0.8em;
  color: #999;
  letter-spacing: 1px;
}

.step h1 {
  font-size: 1.6em;
  margin-bottom: 1em;
  color: #20504c;
}

.total-panel {
  background: #fff;
  padding: 0.8em 1em;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1em;
}

.total-panel .label {
  font-weight: 600;
  color: #555;
}

.total-panel .amount {
  font-size: 1.2em;
  color: #009879;
  font-weight: 700;
}

.amount-display {
  margin-top: 1em;
  text-align: center;
  font-size: 1.1em;
  font-weight: bold;
  color: #009879;
}

/* ==========================================================================
   TABLAS
   ========================================================================== */

.table-container {
  background: #fff;
  padding: 1em;
  border-radius: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  margin-bottom: 1em;
}

table {
  width: 100%;
  border-collapse: collapse;
}

.summary-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 1.5em;
}

.summary-table tr:not(:last-child) {
  border-bottom: 1px solid #eee;
}

.summary-table td {
  padding: 12px 0;
}

.summary-table td:first-child {
  font-weight: bold;
  width: 40%;
}


thead th {
  text-align: left;
  padding: 0.75em;
  background: #fafafa;
  border-bottom: 1px solid #eee;
  color: #555;
}

tbody tr {
  border-bottom: 1px solid #eee;
  transition: background-color 0.3s ease;
}

tbody tr.selected {
  background-color: rgba(0, 152, 121, 0.1);
}

td {
  padding: 0.75em;
  vertical-align: middle;
}

/* ==========================================================================
   STATUS Y ESTADOS
   ========================================================================== */

.status {
  padding: 0.3em 0.6em;
  border-radius: 4px;
  font-size: 0.9em;
  font-weight: 600;
}

.status.vencida,
.status.adeudada {
  background: #fdecea;
  color: #b32020;
}

.status.pagada {
  background: #e6f7ef;
  color: #20504c;
}

/* ==========================================================================
   CARDS MÓVILES
   ========================================================================== */

.cards {
  display: none;
}

.card-item {
  background: #fff;
  margin: 0 auto 1.5em;
  padding: 1.5em;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
  position: relative;
  width: calc(100% - 2em);
}

.card-item input[type="checkbox"] {
  position: absolute;
  top: 1em;
  right: 1em;
  transform: scale(1.4);
}

.card-item.selected {
  border-top: 4px solid #009879;
}

.field {
  display: flex;
  justify-content: space-between;
  padding: 0.75em 0;
  border-bottom: 1px solid #eee;
}

.field:last-child {
  border-bottom: none;
}

.field .label {
  font-size: 1em;
  font-weight: 700;
  color: #555;
}

.field .value {
  font-size: 1em;
  font-weight: 500;
  color: #333;
}

.card-item .status {
  position: static;
  margin: 0;
  float: right;
}

/* ==========================================================================
   FOOTER
   ========================================================================== */

footer {
  background: #ffffff;
  padding: 1.5em;
  text-align: center;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.social {
  margin-bottom: 1em;
}

.social a {
  margin: 0 0.5em;
  color: #20504c;
  font-size: 1.2em;
  transition: color 0.2s ease;
  text-decoration: none;
}

.social a:hover {
  color: #183f3b;
}

.legal {
  margin-top: 1em;
  font-size: 0.8em;
  color: #666;
}

.legal a {
  color: #20504c;
  text-decoration: none;
}

.legal a:hover {
  text-decoration: underline;
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

/* Desktop (>=769px) */
@media (min-width: 769px) {
  .sidebar {
    display: block;
  }
  
  .content {
    margin-left: 260px;
  }
  
  .total-panel {
    width: 60%;
    margin: 0 auto 1em;
  }
  
  .btn-next-fixed {
    display: block;
    position: fixed;
    bottom: 1em;
    right: 1em;
    background: #009879;
    color: #fff;
    padding: 0.8em 1.5em;
    border: none;
    border-radius: 4px;
    font-size: 1em;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    cursor: pointer;
  }
}

/* Tablet (<=992px) */
@media (max-width: 992px) {
  .sidebar {
    width: 240px;
    padding: 1.5em 1em;
  }
  
  .content {
    margin-left: 240px;
  }
}

/* Mobile (<=768px) */
@media (max-width: 768px) {
  .menu-toggle {
    display: flex;
  }
  
  .sidebar {
    transform: translateX(-100%);
    position: absolute;
    z-index: 999;
  }
  
  .sidebar.active {
    transform: translateX(0);
  }
  
  .content {
    margin-left: 0;
  }
  
  .content.full-width {
    margin-left: 0;
  }
  
  header {
    text-align: center;
  }
  
  header .mobile-title {
    display: inline-block;
  }
  
  header .supply,
  header .office-btn {
    display: none;
  }
  
  table {
    display: none;
  }
  
  .cards {
    display: block;
    margin-bottom: 4em;
  }
  
  .btn-next-mobile {
    display: block;
    position: fixed;
    bottom: 1em;
    left: 50%;
    transform: translateX(-50%);
    background: #009879;
    color: #fff;
    padding: 0.8em 1.5em;
    border: none;
    border-radius: 4px;
    font-size: 1em;
    width: calc(100% - 2em);
    text-align: center;
    box-shadow: 0 2px 6px rgba(0,0,0,0.2);
    z-index: 100;
  }
}

/* Mobile pequeño (<=480px) */
@media (max-width: 480px) {
  main {
    padding: 1em;
  }
  
  .card {
    padding: 1.5em;
  }
  
  footer {
    padding: 1em;
  }
  
  .menu-toggle {
    top: 10px;
    left: 10px;
  }
}