/* =============================================
   portal.css - Sistema visual del portal sismo.cloud
   Se carga después del CSS existente para las secciones nuevas.
   ============================================= */

:root {
    --p-bg: #f5f7fb;
    --p-surface: #ffffff;
    --p-surface-2: #eef2f8;
    --p-ink: #0b1220;
    --p-ink-2: #334155;
    --p-muted: #64748b;
    --p-line: #dbe3ee;
    --p-brand: #0f5fd7;
    --p-brand-2: #0b3f96;
    --p-brand-soft: #e7f0ff;
    --p-red: #d92d20;
    --p-orange: #e26a0b;
    --p-yellow: #b77900;
    --p-green: #16834a;
    --p-radius: 18px;
    --p-radius-sm: 12px;
    --p-shadow: 0 10px 30px rgba(15, 35, 70, 0.08);
    --p-shadow-sm: 0 3px 12px rgba(15, 35, 70, 0.06);
}

body.p-page {
    margin: 0;
    background: var(--p-bg);
    color: var(--p-ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.45;
    -webkit-font-smoothing: antialiased;
}

body.p-page *,
body.p-page *::before,
body.p-page *::after {
    box-sizing: border-box;
}

.p-shell {
    width: min(1240px, calc(100% - 32px));
    margin: 0 auto;
}

/* ===== HEADER ===== */
.p-header {
    position: sticky;
    top: 0;
    z-index: 1200;
    background: rgba(255, 255, 255, 0.94);
    border-bottom: 1px solid var(--p-line);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
}

.p-header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
    min-height: 66px;
    padding: 8px 0;
}

.p-brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: var(--p-ink);
    text-decoration: none;
    font-weight: 850;
    letter-spacing: -0.03em;
    font-size: 19px;
    white-space: nowrap;
}

.p-brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    color: #fff;
    background: linear-gradient(135deg, var(--p-brand), #7c3aed);
    box-shadow: 0 6px 14px rgba(15, 95, 215, 0.3);
    font-size: 18px;
}

.p-nav {
    display: flex;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
}

.p-nav::-webkit-scrollbar { display: none; }

.p-nav a {
    color: var(--p-ink-2);
    text-decoration: none;
    font-size: 14px;
    font-weight: 650;
    padding: 9px 12px;
    border-radius: 10px;
    white-space: nowrap;
    transition: background 0.18s, color 0.18s;
}

.p-nav a:hover { background: var(--p-surface-2); color: var(--p-ink); }
.p-nav a.active { background: var(--p-brand-soft); color: var(--p-brand-2); }

.p-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    background: var(--p-brand);
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    font-weight: 750;
    padding: 10px 15px;
    border-radius: 11px;
    white-space: nowrap;
    box-shadow: 0 6px 16px rgba(15, 95, 215, 0.22);
    transition: transform 0.16s, background 0.16s;
}

.p-cta:hover { background: var(--p-brand-2); transform: translateY(-1px); }

/* ===== HERO ===== */
.p-hero {
    padding: 38px 0 22px;
}

.p-hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(300px, 0.75fr);
    gap: 28px;
    align-items: stretch;
}

.p-kicker {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    color: var(--p-brand-2);
    background: var(--p-brand-soft);
    border: 1px solid #d4e3ff;
    border-radius: 999px;
    padding: 6px 11px;
    font-size: 12px;
    font-weight: 750;
    letter-spacing: 0.02em;
}

.p-kicker .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--p-green);
    box-shadow: 0 0 0 4px rgba(22, 131, 74, 0.12);
}

.p-hero h1 {
    margin: 14px 0 10px;
    font-size: clamp(30px, 4.4vw, 56px);
    line-height: 1.02;
    letter-spacing: -0.045em;
    font-weight: 900;
    color: var(--p-ink);
}

.p-hero h1 em {
    font-style: normal;
    color: var(--p-brand);
}

.p-hero-lead {
    color: var(--p-muted);
    font-size: clamp(14px, 1.5vw, 17px);
    line-height: 1.6;
    max-width: 620px;
}

.p-hero-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.p-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 42px;
    padding: 0 17px;
    border-radius: 11px;
    border: 1px solid transparent;
    background: var(--p-brand);
    color: #fff;
    text-decoration: none;
    font-size: 14px;
    font-weight: 750;
    box-shadow: 0 8px 18px rgba(15, 95, 215, 0.2);
}

.p-btn:hover { background: var(--p-brand-2); }
.p-btn.ghost {
    background: var(--p-surface);
    color: var(--p-ink);
    border-color: var(--p-line);
    box-shadow: var(--p-shadow-sm);
}
.p-btn.ghost:hover { background: var(--p-surface-2); }

.p-last {
    background:
        radial-gradient(120% 140% at 95% 0%, rgba(255,255,255,0.16), transparent 55%),
        linear-gradient(145deg, #0b2f6b, #0f5fd7 68%, #3b82f6);
    color: #fff;
    border-radius: var(--p-radius);
    padding: 22px;
    box-shadow: var(--p-shadow);
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 210px;
    position: relative;
    overflow: hidden;
}

.p-last::after {
    content: "";
    position: absolute;
    right: -34px;
    bottom: -48px;
    width: 170px;
    height: 170px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,0.18);
    box-shadow: 0 0 0 28px rgba(255,255,255,0.04), 0 0 0 58px rgba(255,255,255,0.03);
}

.p-last-label {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.72);
}

.p-last-main {
    display: flex;
    align-items: baseline;
    gap: 10px;
    margin-top: 8px;
}

.p-last-mag {
    font-size: 46px;
    line-height: 1;
    font-weight: 900;
    letter-spacing: -0.05em;
}

.p-last-place {
    font-size: 15px;
    line-height: 1.35;
    font-weight: 700;
    max-width: 240px;
}

.p-last-meta {
    margin-top: 14px;
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.p-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    border-radius: 999px;
    padding: 5px 9px;
    background: rgba(255,255,255,0.13);
    color: rgba(255,255,255,0.92);
    font-size: 11px;
    font-weight: 650;
    border: 1px solid rgba(255,255,255,0.15);
}

.p-last-link {
    position: relative;
    z-index: 1;
    color: #fff;
    font-size: 12px;
    font-weight: 800;
    text-decoration: none;
    margin-top: 16px;
}

.p-last-link:hover { text-decoration: underline; }

/* ===== STATS ===== */
.p-stats {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 10px;
    margin: 8px 0 26px;
}

.p-stat {
    background: var(--p-surface);
    border: 1px solid var(--p-line);
    border-radius: 14px;
    padding: 13px 14px;
    box-shadow: var(--p-shadow-sm);
}

.p-stat-label {
    color: var(--p-muted);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    white-space: nowrap;
}

.p-stat-value {
    margin-top: 5px;
    font-size: 24px;
    line-height: 1;
    font-weight: 900;
    letter-spacing: -0.04em;
    color: var(--p-ink);
}

.p-stat-value.red { color: var(--p-red); }
.p-stat-value.orange { color: var(--p-orange); }
.p-stat-value.yellow { color: var(--p-yellow); }
.p-stat-value.green { color: var(--p-green); }
.p-stat-value.gray { color: var(--p-muted); }

/* ===== SECTIONS ===== */
.p-section {
    padding: 34px 0;
}

.p-section-head {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}

.p-section-head h2 {
    margin: 0;
    font-size: clamp(21px, 2.4vw, 30px);
    letter-spacing: -0.035em;
    font-weight: 900;
}

.p-section-head p {
    margin: 5px 0 0;
    color: var(--p-muted);
    font-size: 14px;
}

.p-link {
    color: var(--p-brand);
    font-size: 13px;
    font-weight: 800;
    text-decoration: none;
    white-space: nowrap;
}
.p-link:hover { text-decoration: underline; }

/* ===== COUNTRY CARDS ===== */
.p-countries-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
}

.p-country-card {
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--p-surface);
    border: 1px solid var(--p-line);
    border-radius: var(--p-radius-sm);
    padding: 16px;
    text-decoration: none;
    color: var(--p-ink);
    box-shadow: var(--p-shadow-sm);
    transition: transform 0.16s, box-shadow 0.16s, border-color 0.16s;
}

.p-country-card:hover {
    transform: translateY(-2px);
    border-color: #b9cdf0;
    box-shadow: 0 12px 26px rgba(15, 35, 70, 0.1);
}

.p-country-top {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.p-country-flag {
    width: 40px;
    height: 40px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    background: var(--p-surface-2);
    font-size: 23px;
    flex: 0 0 auto;
    overflow: hidden;
}

.p-country-flag img {
    width: 27px;
    height: auto;
    display: block;
    border-radius: 3px;
    box-shadow: 0 1px 4px rgba(15, 35, 70, 0.18);
}

.p-country-name {
    font-size: 14px;
    font-weight: 800;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.p-country-region {
    color: var(--p-muted);
    font-size: 11px;
    margin-top: 2px;
}

.p-country-count {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-top: 2px;
}

.p-country-count strong {
    font-size: 27px;
    line-height: 1;
    letter-spacing: -0.04em;
}

.p-country-count span {
    color: var(--p-muted);
    font-size: 11px;
    font-weight: 650;
}

.p-country-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    color: var(--p-muted);
    font-size: 11px;
    border-top: 1px solid var(--p-line);
    padding-top: 9px;
    margin-top: auto;
}

.p-country-card.is-empty { opacity: 0.64; }
.p-country-card.is-empty .p-country-count strong { color: var(--p-muted); }

/* ===== SEARCH / FILTERS ===== */
.p-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin: 0 0 16px;
}

.p-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--p-surface);
    border: 1px solid var(--p-line);
    border-radius: 11px;
    padding: 9px 12px;
    min-width: min(340px, 100%);
    box-shadow: var(--p-shadow-sm);
}

.p-search input {
    border: 0;
    outline: 0;
    background: transparent;
    font: inherit;
    font-size: 14px;
    color: var(--p-ink);
    width: 100%;
}

.p-search span { color: var(--p-muted); font-size: 15px; }

.p-region-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 7px;
}

.p-region-nav a {
    color: var(--p-ink-2);
    background: var(--p-surface);
    border: 1px solid var(--p-line);
    border-radius: 999px;
    padding: 7px 11px;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}

.p-region-nav a:hover { background: var(--p-brand-soft); color: var(--p-brand-2); border-color: #c9dcff; }

.p-region-title {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 26px 0 12px;
    font-size: 13px;
    font-weight: 850;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--p-muted);
}

.p-region-title .line {
    height: 1px;
    background: var(--p-line);
    flex: 1;
}

/* ===== COUNTRY HERO (mapa.php) ===== */
.p-country-hero {
    margin: 18px auto 0;
    background: var(--p-surface);
    border: 1px solid var(--p-line);
    border-radius: var(--p-radius);
    box-shadow: var(--p-shadow);
    padding: 20px;
}

.p-country-hero-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}

.p-country-hero-title {
    display: flex;
    align-items: center;
    gap: 13px;
    min-width: 0;
}

.p-country-hero-flag {
    width: 54px;
    height: 54px;
    border-radius: 15px;
    display: grid;
    place-items: center;
    background: var(--p-surface-2);
    font-size: 32px;
    flex: 0 0 auto;
    overflow: hidden;
}

.p-country-hero-flag img {
    width: 42px;
    height: auto;
    display: block;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(15, 35, 70, 0.18);
}

.p-country-hero-title h1 {
    margin: 0;
    font-size: clamp(22px, 3vw, 34px);
    line-height: 1.05;
    letter-spacing: -0.04em;
    font-weight: 900;
}

.p-country-hero-title p {
    margin: 3px 0 0;
    color: var(--p-muted);
    font-size: 12px;
}

.p-country-stats {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 8px;
    margin-top: 16px;
}

.p-country-stat {
    border: 1px solid var(--p-line);
    background: var(--p-bg);
    border-radius: 11px;
    padding: 10px 11px;
}

.p-country-stat b {
    display: block;
    font-size: 20px;
    line-height: 1;
    letter-spacing: -0.03em;
}

.p-country-stat span {
    display: block;
    margin-top: 4px;
    color: var(--p-muted);
    font-size: 10px;
    font-weight: 750;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.p-country-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

.p-country-actions .p-btn { min-height: 36px; font-size: 12px; padding: 0 13px; }

/* ===== LISTA DE SISMOS DEL PAÍS ===== */
.p-country-sismos { padding-top: 8px; }

.p-recent-list {
    display: grid;
    gap: 8px;
}

.p-recent-item {
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--p-surface);
    border: 1px solid var(--p-line);
    border-radius: 12px;
    padding: 11px 13px;
    text-decoration: none;
    color: var(--p-ink);
    box-shadow: var(--p-shadow-sm);
    transition: border-color 0.16s, transform 0.16s, box-shadow 0.16s;
}

.p-recent-item:hover {
    border-color: #b9cdf0;
    transform: translateY(-1px);
    box-shadow: 0 8px 18px rgba(15, 35, 70, 0.08);
}

.p-recent-mag {
    width: 46px;
    height: 46px;
    border-radius: 11px;
    display: grid;
    place-items: center;
    flex: 0 0 auto;
    background: linear-gradient(135deg, #e7f0ff, #dbeafe);
    color: var(--p-brand-2);
    font-size: 16px;
    font-weight: 900;
    letter-spacing: -0.03em;
}

.p-recent-info {
    min-width: 0;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.p-recent-place {
    font-size: 13px;
    font-weight: 750;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.p-recent-meta {
    font-size: 11px;
    color: var(--p-muted);
    line-height: 1.35;
}

.p-recent-arrow {
    color: var(--p-brand);
    font-size: 18px;
    font-weight: 800;
    flex: 0 0 auto;
}

/* ===== DÍA / ARCHIVO DIARIO ===== */
.p-date-hero {
    margin: 18px auto 0;
    background: var(--p-surface);
    border: 1px solid var(--p-line);
    border-radius: var(--p-radius);
    box-shadow: var(--p-shadow);
    padding: 20px;
}

.p-date-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
    flex-wrap: wrap;
}

.p-date-top h1 {
    margin: 10px 0 4px;
    font-size: clamp(24px, 3vw, 36px);
    line-height: 1.05;
    letter-spacing: -0.04em;
    font-weight: 900;
}

.p-date-top p {
    margin: 0;
    color: var(--p-muted);
    font-size: 13px;
    line-height: 1.5;
}

.p-date-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.p-date-nav a {
    display: inline-flex;
    align-items: center;
    min-height: 34px;
    padding: 0 11px;
    border: 1px solid var(--p-line);
    border-radius: 9px;
    background: var(--p-surface);
    color: var(--p-ink-2);
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
}

.p-date-nav a:hover { background: var(--p-brand-soft); color: var(--p-brand-2); }

.p-date-stats {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-top: 14px;
}

.p-date-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 14px;
}

body.p-date-view #map {
    height: min(58vh, 560px);
    min-height: 340px;
}

body.p-country-view #map {
    height: min(64vh, 640px);
    min-height: 380px;
}

/* ===== AJUSTES DEL PANEL DE PAÍSES (home) ===== */
.selector-pais { min-height: 0; }
.selector-lista { min-height: 170px; flex: 1 1 auto; }
.side-panel .sismos-panel { flex: 1 1 auto; min-height: 0; }

/* ===== EMPTY / NOTICE ===== */
.p-empty {
    background: var(--p-surface);
    border: 1px dashed var(--p-line);
    border-radius: var(--p-radius-sm);
    padding: 26px;
    text-align: center;
    color: var(--p-muted);
    font-size: 14px;
}

/* ===== FOOTER ===== */
.p-footer {
    margin-top: 34px;
    border-top: 1px solid var(--p-line);
    background: #fff;
    padding: 26px 0;
    color: var(--p-muted);
    font-size: 12px;
}

.p-footer-inner {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    flex-wrap: wrap;
}

.p-footer strong { color: var(--p-ink); }
.p-footer a { color: var(--p-ink-2); text-decoration: none; margin-right: 12px; }
.p-footer a:hover { color: var(--p-brand); }

/* ===== RESPONSIVE ===== */
@media (max-width: 980px) {
    .p-hero-grid { grid-template-columns: 1fr; }
    .p-last { min-height: 180px; }
    .p-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
    .p-country-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
    .p-header-inner { min-height: 58px; gap: 8px; }
    .p-brand { font-size: 16px; }
    .p-brand-mark { width: 30px; height: 30px; font-size: 16px; }
    .p-nav a { padding: 8px 9px; font-size: 12px; }
    .p-cta { display: none; }
    .p-shell { width: min(100% - 24px, 1240px); }
    .p-hero { padding-top: 26px; }
    .p-hero h1 { font-size: 38px; }
    .p-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .p-country-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .p-section { padding: 24px 0; }
    .p-section-head { align-items: flex-start; }
    .p-countries-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
    .p-country-card { padding: 13px; }
    .p-country-flag { width: 34px; height: 34px; font-size: 20px; }
    .p-country-count strong { font-size: 23px; }
    .p-country-hero { padding: 15px; margin-top: 10px; }
    .p-date-hero { padding: 15px; margin-top: 10px; }
    .p-date-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .p-date-nav { width: 100%; }
    .p-recent-mag { width: 40px; height: 40px; font-size: 14px; }
    .p-recent-place { white-space: normal; }
    .p-recent-meta { font-size: 10px; }
}

@media (max-width: 430px) {
    .p-countries-grid { grid-template-columns: 1fr 1fr; }
    .p-country-meta { font-size: 10px; }
    .p-country-name { font-size: 13px; }
    .p-hero h1 { font-size: 33px; }
}

@media (prefers-reduced-motion: reduce) {
    .p-country-card, .p-cta { transition: none; }
}
