/* ═══════════════════════════════════════════════════════════════════════════
   Condominio La Placette — Estilos 100% Responsive
   Breakpoints: móvil <480px | tablet 481–768px | desktop >768px
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Variables ───────────────────────────────────────────────────────────── */
:root {
  --cp-blue:       #1a5276;
  --cp-blue-l:     #2e86c1;
  --cp-green:      #1a7a4a;
  --cp-red:        #c0392b;
  --cp-yellow:     #f39c12;
  --cp-bg:         #f4f7fb;
  --cp-card:       #ffffff;
  --cp-border:     #dce3ed;
  --cp-text:       #2c3e50;
  --cp-muted:      #7f8c8d;
  --cp-radius:     10px;
  --accent:        var(--cp-blue);
  --cp-touch:      44px;   /* tamaño mínimo táctil */
}

/* ══════════════════════════════════════════════════════════
   BASE
   ══════════════════════════════════════════════════════════ */

.cp-wrap {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  color: var(--cp-text);
  max-width: 1400px;
  /* Evitar overflow horizontal en móvil */
  overflow-x: hidden;
}

.cp-title {
  font-size: 20px !important;
  font-weight: 700 !important;
  color: var(--cp-blue) !important;
  border-left: 4px solid var(--cp-blue);
  padding-left: 12px !important;
  margin-bottom: 16px !important;
  line-height: 1.3;
}

/* ══════════════════════════════════════════════════════════
   CARD
   ══════════════════════════════════════════════════════════ */

.cp-card {
  background: var(--cp-card);
  border: 1px solid var(--cp-border);
  border-radius: var(--cp-radius);
  padding: 20px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  /* Evitar desbordamiento de contenido */
  overflow: hidden;
}

.cp-card h3 {
  color: var(--cp-blue);
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 12px;
}

/* ══════════════════════════════════════════════════════════
   FLEX HELPERS
   ══════════════════════════════════════════════════════════ */

.cp-flex-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

/* En móvil, cada item ocupa 100% */
@media (max-width: 480px) {
  .cp-flex-row {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .cp-flex-row > * {
    width: 100%;
  }
  .cp-flex-row input,
  .cp-flex-row select,
  .cp-flex-row button,
  .cp-flex-row .button {
    width: 100% !important;
    min-height: var(--cp-touch);
    font-size: 15px !important;
  }
}

/* ══════════════════════════════════════════════════════════
   STATS GRID
   ══════════════════════════════════════════════════════════ */

.cp-stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 12px;
  margin: 12px 0;
}

.cp-stat-card {
  background: var(--cp-card);
  border: 1px solid var(--cp-border);
  border-top: 4px solid var(--accent, var(--cp-blue));
  border-radius: var(--cp-radius);
  padding: 16px 12px;
  text-align: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  transition: transform .15s, box-shadow .15s;
}

.cp-stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,0.10); }
.cp-stat-alert  { --accent: var(--cp-red);   }
.cp-stat-icon   { font-size: 24px; margin-bottom: 6px; }
.cp-stat-value  { font-size: 22px; font-weight: 700; line-height: 1.1; }
.cp-stat-label  { font-size: 10px; color: var(--cp-muted); text-transform: uppercase; letter-spacing: .4px; margin-top: 4px; }

@media (max-width: 480px) {
  .cp-stats-grid { grid-template-columns: 1fr 1fr; gap: 8px; }
  .cp-stat-card  { padding: 12px 8px; }
  .cp-stat-icon  { font-size: 20px; }
}

/* ══════════════════════════════════════════════════════════
   TABLAS RESPONSIVAS
   El truco: en móvil cada fila se convierte en una "tarjeta"
   usando data-label en las celdas para mostrar el encabezado.
   ══════════════════════════════════════════════════════════ */

.cp-wrap table.widefat {
  border-radius: 8px;
  border: 1px solid var(--cp-border);
  font-size: 13px;
  width: 100%;
  border-collapse: collapse;
  /* Scroll horizontal en tablet cuando no hay espacio */
}

.cp-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 8px;
  border: 1px solid var(--cp-border);
  /* Indicador visual de scroll */
  background:
    linear-gradient(to right, white 30%, rgba(255,255,255,0)),
    linear-gradient(to right, rgba(255,255,255,0), white 70%) 0 100%,
    radial-gradient(farthest-side at 0% 50%, rgba(0,0,0,.15), rgba(0,0,0,0)),
    radial-gradient(farthest-side at 100% 50%, rgba(0,0,0,.15), rgba(0,0,0,0)) 0 100%;
  background-repeat: no-repeat;
  background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
  background-attachment: local, local, scroll, scroll;
}

.cp-wrap table.widefat thead th {
  background: var(--cp-blue) !important;
  color: #fff !important;
  font-weight: 600;
  border-bottom: none !important;
  padding: 10px 12px;
  white-space: nowrap;
}

.cp-wrap table.widefat tbody tr:hover { background: #eaf3fb !important; }

.cp-wrap table.widefat tbody td {
  padding: 9px 12px;
  vertical-align: middle;
  border-bottom: 1px solid var(--cp-border);
}

.cp-wrap table.widefat tfoot td {
  background: #ecf0f1;
  font-weight: 600;
  padding: 8px 12px;
}

/* ── Tabla tipo tarjeta en móvil ─────────────────────────────────────────── */
@media (max-width: 600px) {
  /* Wrap todas las tablas en un div scrollable automáticamente */
  .cp-wrap table.widefat {
    border: none;
    border-radius: 0;
  }

  /* Ocultar thead en móvil */
  .cp-wrap table.widefat thead { display: none; }

  /* Cada fila = tarjeta */
  .cp-wrap table.widefat tbody tr {
    display: block;
    background: var(--cp-card);
    border: 1px solid var(--cp-border);
    border-radius: 8px;
    margin-bottom: 10px;
    padding: 10px 12px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  }

  .cp-wrap table.widefat tbody tr:hover { background: #eaf3fb !important; }

  /* Cada celda = fila con label */
  .cp-wrap table.widefat tbody td {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 8px;
    padding: 5px 0;
    border-bottom: 1px dashed #eee;
    font-size: 13px;
    text-align: right;
  }

  .cp-wrap table.widefat tbody td:last-child { border-bottom: none; }

  /* Label tomado de data-label */
  .cp-wrap table.widefat tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--cp-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .3px;
    text-align: left;
    flex-shrink: 0;
    max-width: 45%;
  }

  /* Botones en móvil: más grandes */
  .cp-wrap table.widefat tbody td .button,
  .cp-wrap table.widefat tbody td button {
    min-height: 36px;
    padding: 6px 12px;
    font-size: 13px;
  }

  /* Tfoot como bloque */
  .cp-wrap table.widefat tfoot tr { display: block; }
  .cp-wrap table.widefat tfoot td {
    display: block;
    border-bottom: 1px dashed #ccc;
    text-align: left;
  }
}

/* ══════════════════════════════════════════════════════════
   BOTONES
   ══════════════════════════════════════════════════════════ */

.cp-wrap .button,
.cp-wrap button.button {
  min-height: 34px;
  padding: 5px 14px;
  font-size: 13px;
  cursor: pointer;
  border-radius: 5px;
}

.cp-wrap .button-primary {
  background: var(--cp-blue) !important;
  border-color: var(--cp-blue) !important;
  color: #fff !important;
}
.cp-wrap .button-primary:hover {
  background: var(--cp-blue-l) !important;
  border-color: var(--cp-blue-l) !important;
}

/* En móvil botones a ancho completo */
@media (max-width: 480px) {
  .cp-wrap .button,
  .cp-wrap button.button {
    width: 100%;
    min-height: var(--cp-touch);
    font-size: 15px;
    text-align: center;
    justify-content: center;
    margin-bottom: 4px;
  }
}

/* ══════════════════════════════════════════════════════════
   FORMULARIOS
   ══════════════════════════════════════════════════════════ */

.cp-wrap .form-table {
  width: 100%;
}
.cp-wrap .form-table th {
  color: var(--cp-text);
  font-size: 13px;
  padding: 10px 16px 10px 0;
  width: 160px;
  vertical-align: top;
}
.cp-wrap .form-table td {
  padding: 8px 0;
}

/* En móvil form-table se vuelve linear */
@media (max-width: 600px) {
  .cp-wrap .form-table,
  .cp-wrap .form-table tbody,
  .cp-wrap .form-table tr,
  .cp-wrap .form-table th,
  .cp-wrap .form-table td {
    display: block;
    width: 100%;
  }
  .cp-wrap .form-table th {
    padding: 8px 0 2px;
    font-size: 12px;
    color: var(--cp-muted);
  }
  .cp-wrap .form-table td {
    padding: 0 0 10px;
  }
  .cp-wrap .form-table input[type="text"],
  .cp-wrap .form-table input[type="number"],
  .cp-wrap .form-table input[type="email"],
  .cp-wrap .form-table input[type="month"],
  .cp-wrap .form-table select,
  .cp-wrap .form-table textarea,
  .cp-wrap .form-table .large-text,
  .cp-wrap .form-table .regular-text {
    width: 100% !important;
    min-height: var(--cp-touch);
    font-size: 15px;
    box-sizing: border-box;
  }
}

/* Inputs base */
.cp-wrap input[type="text"],
.cp-wrap input[type="number"],
.cp-wrap input[type="email"],
.cp-wrap input[type="month"],
.cp-wrap select,
.cp-wrap textarea {
  border-radius: 5px;
  border: 1px solid var(--cp-border);
  padding: 6px 10px;
  font-size: 13px;
  max-width: 100%;
}

/* ══════════════════════════════════════════════════════════
   MODAL
   ══════════════════════════════════════════════════════════ */

#cp-receipt-modal {
  backdrop-filter: blur(3px);
  padding: 10px;
}

#cp-receipt-modal > div {
  max-width: 800px; max-width: min(800px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  margin: 20px auto;
}

#cp-receipt-content table {
  border-collapse: collapse;
  width: 100%;
  font-size: 8pt;
}
#cp-receipt-content table td,
#cp-receipt-content table th {
  border: 1px solid #bbb;
  padding: 2px 4px;
}

/* En móvil el modal ocupa toda la pantalla */
@media (max-width: 600px) {
  #cp-receipt-modal {
    padding: 0;
  }
  #cp-receipt-modal > div {
    margin: 0;
    max-height: 100vh;
    border-radius: 0;
  }
}

/* ══════════════════════════════════════════════════════════
   STATUS SELECT
   ══════════════════════════════════════════════════════════ */

.cp-status-sel {
  border-radius: 4px;
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 600;
  border: 1px solid #ccc;
  cursor: pointer;
  min-height: 32px;
}

@media (max-width: 480px) {
  .cp-status-sel {
    width: 100%;
    min-height: var(--cp-touch);
    font-size: 14px;
  }
}

/* ══════════════════════════════════════════════════════════
   NOTICES
   ══════════════════════════════════════════════════════════ */

.notice.inline {
  margin: 0 !important;
  padding: 6px 12px !important;
}

/* ══════════════════════════════════════════════════════════
   ADMIN PANEL SHORTCODE — NAVEGACIÓN POR PESTAÑAS
   ══════════════════════════════════════════════════════════ */

#cp-admin-panel {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  max-width: 1300px;
  margin: 0 auto;
  background: var(--cp-bg);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,0.10);
}

.cp-tab-nav {
  display: flex;
  align-items: stretch;
  background: var(--cp-blue);
  padding: 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  gap: 0;
}
.cp-tab-nav::-webkit-scrollbar { display: none; }

.cp-tab-link {
  display: flex;
  align-items: center;
  padding: 14px 16px;
  color: rgba(255,255,255,0.75) !important;
  text-decoration: none !important;
  font-size: 13px;
  font-weight: 500;
  border-bottom: 3px solid transparent;
  transition: color .15s, border-color .15s, background .15s;
  white-space: nowrap;
  flex-shrink: 0;
}
.cp-tab-link:hover {
  color: #fff !important;
  background: rgba(255,255,255,0.08);
  border-bottom-color: rgba(255,255,255,0.4);
}
.cp-tab-active {
  color: #fff !important;
  border-bottom-color: #f39c12 !important;
  font-weight: 700;
  background: rgba(255,255,255,0.12);
}
.cp-tab-nav-right {
  margin-left: auto;
  padding: 0 12px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}
.cp-tab-nav-right a { color: #add8f7 !important; font-size: 12px; }

.cp-tab-content {
  padding: 20px;
  min-height: 400px;
}

/* Tablet: iconos más compactos */
@media (max-width: 768px) {
  .cp-tab-link {
    padding: 12px 12px;
    font-size: 12px;
  }
  .cp-tab-nav-right { display: none; }
}

/* Móvil: pestañas solo con emoji */
@media (max-width: 480px) {
  .cp-tab-link {
    padding: 12px 10px;
    font-size: 11px;
    flex-direction: column;
    gap: 2px;
    text-align: center;
  }
  .cp-tab-link .cp-tab-text {
    font-size: 10px;
  }
}

/* ══════════════════════════════════════════════════════════
   PORTAL PÚBLICO
   ══════════════════════════════════════════════════════════ */

.cp-portal {
  font-family: 'Segoe UI', system-ui, sans-serif;
  max-width: 900px;
  margin: 0 auto;
  padding: clamp(10px, 3vw, 16px);
}

.cp-portal table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

@media (max-width: 600px) {
  .cp-portal table thead { display: none; }
  .cp-portal table tbody tr {
    display: block;
    border: 1px solid var(--cp-border);
    border-radius: 8px;
    margin-bottom: 10px;
    padding: 10px;
    background: #fff;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  }
  .cp-portal table tbody td {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    border-bottom: 1px dashed #eee;
    font-size: 13px;
  }
  .cp-portal table tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--cp-muted);
    font-size: 11px;
    text-transform: uppercase;
  }
  .cp-portal table tbody td:last-child { border-bottom: none; }
  .cp-portal table tbody td a {
    width: 100%;
    text-align: center;
    display: block;
    padding: 8px;
  }
}

/* ══════════════════════════════════════════════════════════
   OVERRIDES PANEL FRONTEND
   ══════════════════════════════════════════════════════════ */

#cp-admin-panel .cp-wrap { max-width: 100%; }
#cp-admin-panel .cp-title { margin-top: 0 !important; }
#cp-admin-panel .wrap > h1:first-child { margin-top: 0; }

/* Evitar que Divi/tema rompa los estilos */
#cp-admin-panel *,
#cp-admin-panel *::before,
#cp-admin-panel *::after {
  box-sizing: border-box;
}

/* ══════════════════════════════════════════════════════════
   UTILIDADES RESPONSIVAS
   ══════════════════════════════════════════════════════════ */

/* Ocultar en móvil */
@media (max-width: 480px) {
  .cp-hide-mobile  { display: none !important; }
}
/* Ocultar en tablet */
@media (max-width: 768px) {
  .cp-hide-tablet  { display: none !important; }
}
/* Solo visible en móvil */
.cp-show-mobile { display: none !important; }
@media (max-width: 480px) {
  .cp-show-mobile { display: block !important; }
}

/* Texto responsivo */
.cp-text-small { font-size: 11px; }
.cp-text-mono  { font-family: 'Courier New', monospace; }

/* ══════════════════════════════════════════════════════════
   TOPBAR — Barra superior con usuario y cerrar sesión
   Siempre visible en todas las resoluciones
   ══════════════════════════════════════════════════════════ */

.cp-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #0e2f44;
  padding: 8px 16px;
  gap: 10px;
  flex-wrap: wrap;
}

.cp-topbar-left {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow: hidden;
}

.cp-topbar-building {
  color: rgba(255,255,255,0.7);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cp-topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.cp-topbar-user {
  color: rgba(255,255,255,0.8);
  font-size: 12px;
  white-space: nowrap;
}

.cp-topbar-since {
  color: rgba(255,255,255,0.45);
  font-size: 11px;
}

/* ── Botón Cerrar Sesión — siempre visible ────────────────────────────── */
.cp-logout-btn {
  display: inline-flex !important;
  align-items: center;
  gap: 5px;
  background: #c0392b !important;
  color: #fff !important;
  padding: 6px 14px !important;
  border-radius: 6px;
  text-decoration: none !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  white-space: nowrap;
  transition: background .2s, transform .1s;
  border: none;
  cursor: pointer;
  min-height: 32px;
  box-shadow: 0 2px 6px rgba(192,57,43,0.4);
}

.cp-logout-btn:hover {
  background: #a93226 !important;
  color: #fff !important;
  transform: translateY(-1px);
  box-shadow: 0 4px 10px rgba(192,57,43,0.5);
}

.cp-logout-btn:active {
  transform: translateY(0);
}

/* En móvil: texto más corto pero botón siempre visible */
@media (max-width: 480px) {
  .cp-topbar {
    padding: 6px 10px;
  }
  .cp-topbar-building {
    font-size: 11px;
  }
  .cp-topbar-user {
    display: none;  /* Ocultar en móvil muy pequeño, el username ya está en topbar-left */
  }
  .cp-logout-btn {
    padding: 6px 10px !important;
    font-size: 12px !important;
  }
  .cp-logout-btn span {
    display: none; /* Solo mostrar emoji en móvil muy pequeño */
  }
}

@media (min-width: 481px) and (max-width: 768px) {
  .cp-topbar-since { display: none; }
}
