/* ============================================================
   SPQR Simulation Engine · Dashboard Styles
   ------------------------------------------------------------
   Roman Republic Economic Simulation — Imperium Dashboard
   MCCSoft LLC · SPQR Dashboard v2.0
   ============================================================ */

/* ── CSS Custom Properties ────────────────────────────────── */
:root {
    --stone-light: #d4cfc4;
    --stone: #a69f8f;
    --stone-dark: #6b6459;
    --parchment: #f4efe4;
    --parchment-dark: #e8dfc9;
    --marble: #f9f7f3;
    --gold: #c9a227;
    --gold-dark: #9a7b1c;
    --terracotta: #c45c3e;
    --laurel: #5a6b32;
    --blood: #8b2500;
    --ink: #2d2a26;
    --ink-light: #4a4640;
    --shadow: rgba(45,42,38,0.15);
}

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

/* ── Base ─────────────────────────────────────────────────── */
body {
    font-family: 'Spectral', Georgia, serif;
    font-size: 15px;
    line-height: 1.6;
    color: var(--ink);
    min-height: 100vh;
    background: linear-gradient(135deg, var(--parchment) 0%, var(--parchment-dark) 50%, var(--parchment) 100%);
    background-attachment: fixed;
}

/* ── Header ───────────────────────────────────────────────── */
.header {
    background: linear-gradient(180deg, var(--stone-dark) 0%, #52504a 50%, var(--stone-dark) 100%);
    text-align: center;
    box-shadow: 0 4px 20px rgba(0,0,0,0.4);
    position: relative;
    z-index: 10;
}

.header-inner {
    padding: 1rem;
    background: linear-gradient(90deg, transparent 0%, rgba(201,162,39,0.15) 50%, transparent 100%);
}

.header h1 {
    font-family: 'Cinzel', serif;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gold);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    letter-spacing: 0.25em;
}

.header .subtitle {
    font-family: 'Cinzel', serif;
    font-size: 0.7rem;
    color: var(--stone-light);
    letter-spacing: 0.1em;
    text-transform: uppercase;
}

.header-border {
    height: 4px;
    background: linear-gradient(90deg, var(--stone-dark), var(--gold) 30%, var(--gold-dark) 50%, var(--gold) 70%, var(--stone-dark));
}

/* ── Status Bar ───────────────────────────────────────────── */
.status-bar {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.5rem 1.25rem;
    padding: 0.5rem 1rem;
    background: rgba(0,0,0,0.25);
    font-size: 0.75rem;
    color: var(--stone-light);
    align-items: center;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.status-dot.alive {
    background: #22c55e;
    box-shadow: 0 0 6px #22c55e;
    animation: pulse 2s infinite;
}

.status-dot.dead {
    background: #dc2626;
}

.status-dot.paused {
    background: #eab308;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.5; }
}

.status-divider {
    width: 1px;
    height: 16px;
    background: rgba(201,162,39,0.35);
}

/* ── Roman Date Display ───────────────────────────────────── */
.roman-date-display {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    font-family: 'Cinzel', serif;
    font-size: 0.65rem;
    letter-spacing: 0.06em;
    color: var(--gold);
}

.roman-date-display .date-part { opacity: 0.95; }
.roman-date-display .auc-year  { color: var(--stone-light); font-size: 0.6rem; opacity: 0.75; }
.roman-date-display .hora      { font-size: 0.65rem; color: var(--stone-light); opacity: 0.85; font-family: 'Cinzel', serif; font-variant-numeric: tabular-nums; letter-spacing: 0.05em; display: inline-block; min-width: 5.5em; text-align: right; }

/* ── Container / Grid ─────────────────────────────────────── */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0.75rem;
}

.grid-main {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

/* ── Stat Cards ───────────────────────────────────────────── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: var(--marble);
    border: 1px solid var(--stone);
    border-radius: 4px;
    padding: 0.75rem 0.5rem;
    text-align: center;
    position: relative;
    box-shadow: 0 2px 6px var(--shadow);
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--gold), transparent);
}

.stat-card .label {
    font-family: 'Cinzel', serif;
    font-size: 0.55rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--stone-dark);
    margin-bottom: 0.25rem;
}

.stat-card .value {
    font-family: 'Cinzel', serif;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--ink);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.1rem;
}

/* ── Denarii Icon ─────────────────────────────────────────── */
.d-icon {
    display: inline-flex;
    align-items: center;
    vertical-align: baseline;
}

.d-icon svg {
    width: 1em;
    height: 1em;
    vertical-align: -0.12em;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* ── Panels ───────────────────────────────────────────────── */
.panel {
    background: var(--marble);
    border: 1px solid var(--stone);
    border-radius: 4px;
    margin-bottom: 0.75rem;
    box-shadow: 0 2px 8px var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.panel-header {
    background: linear-gradient(180deg, var(--stone) 0%, var(--stone-dark) 100%);
    color: var(--parchment);
    padding: 0.6rem 0.75rem;
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
    border-bottom: 2px solid var(--gold);
    flex-shrink: 0;
}

.panel-body          { padding: 0.75rem; overflow-y: auto; flex: 1 1 auto; min-height: 0; }
.panel-body.compact  { padding: 0; }

.controls {
    display: flex;
    gap: 0.35rem;
    flex-wrap: wrap;
}

/* ── Form Elements ────────────────────────────────────────── */
select,
input[type="text"] {
    font-family: 'Spectral', serif;
    font-size: 0.75rem;
    padding: 0.3rem 0.5rem;
    border: 1px solid var(--stone);
    border-radius: 3px;
    background: var(--parchment);
    color: var(--ink);
}

input[type="text"] {
    width: 90px;
}

/* ── Citizens Panel ───────────────────────────────────────── */
.citizens-panel             { max-height: 600px; }
.citizens-panel .panel-body.compact { overflow-y: auto; flex: 1 1 auto; min-height: 0; }

/* ── Data Tables ──────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8rem;
}

.data-table th {
    background: var(--parchment-dark);
    font-family: 'Cinzel', serif;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--stone-dark);
    padding: 0;
    text-align: left;
    border-bottom: 2px solid var(--stone);
    position: sticky;
    top: 0;
    z-index: 5;
    user-select: none;
}

.th-inner {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.5rem;
    cursor: pointer;
    white-space: nowrap;
    transition: background 0.15s;
}

.th-inner:hover { background: var(--stone-light); }

.sort-arrow {
    display: inline-flex;
    flex-direction: column;
    line-height: 1;
    font-size: 0.5rem;
    color: var(--stone);
    flex-shrink: 0;
}

.sort-arrow .up,
.sort-arrow .down     { line-height: 0.6; }
.sort-arrow.asc .up   { color: var(--gold-dark); font-weight: bold; }
.sort-arrow.desc .down { color: var(--gold-dark); font-weight: bold; }

.data-table td                              { padding: 0.5rem; border-bottom: 1px solid var(--parchment-dark); }
.data-table tr:hover td                     { background: var(--parchment); }
.data-table tr.clickable                    { cursor: pointer; }
.data-table tr.dead td                      { opacity: 0.5; }
.data-table tbody tr:nth-child(even) td     { background: rgba(164,159,143,0.04); }
.data-table tbody tr:nth-child(even):hover td { background: var(--parchment); }

/* ── Tick Badges ──────────────────────────────────────────── */
.tick-num {
    display: inline-block;
    font-family: 'Cinzel', serif;
    font-size: 0.5rem;
    font-weight: 600;
    color: var(--gold-dark);
    background: rgba(201,162,39,0.12);
    border: 1px solid rgba(201,162,39,0.25);
    border-radius: 2px;
    padding: 0.05rem 0.3rem;
    letter-spacing: 0.03em;
    margin-right: 0.3rem;
    vertical-align: baseline;
}

/* ── Progress Bars (mini) ─────────────────────────────────── */
.bar-mini   { display: flex; align-items: center; gap: 0.3rem; }
.bar-track  { flex: 1; height: 5px; background: var(--parchment-dark); border-radius: 2px; overflow: hidden; min-width: 35px; }
.bar-fill   { height: 100%; border-radius: 2px; transition: width 0.4s ease; }
.bar-fill.hunger { background: linear-gradient(90deg, var(--laurel), var(--gold), var(--terracotta)); }
.bar-fill.energy { background: linear-gradient(90deg, #3b82f6, #60a5fa); }
.bar-fill.health { background: linear-gradient(90deg, var(--blood), var(--laurel)); }
.bar-val    { font-size: 0.65rem; color: var(--ink-light); min-width: 26px; text-align: right; }

/* ── Badges ───────────────────────────────────────────────── */
.badge {
    display: inline-block;
    padding: 0.1rem 0.35rem;
    border-radius: 2px;
    font-size: 0.6rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge.work  { background: #dbeafe; color: #1e40af; }
.badge.rest  { background: #fef3c7; color: #92400e; }
.badge.eat   { background: #dcfce7; color: #166534; }
.badge.buy   { background: #f3e8ff; color: #6b21a8; }
.badge.died  { background: #fee2e2; color: var(--blood); }
.badge.idle  { background: #f3f4f6; color: #6b7280; }
.badge.alive { background: #dcfce7; color: var(--laurel); }
.badge.dead  { background: #fee2e2; color: var(--blood); }

/* ── Citizen Name Cells ───────────────────────────────────── */
.money          { font-family: 'Cinzel', serif; font-weight: 600; color: var(--gold-dark); white-space: nowrap; }
.citizen-name   { font-weight: 500; font-size: 0.85rem; }
.citizen-family { font-size: 0.7rem; color: var(--stone-dark); font-style: italic; }

.data-table td:first-child                       { border-left: 2px solid transparent; }
.data-table tr.clickable:hover td:first-child    { border-left-color: var(--gold); }

/* ── Overview Panel / Tabs ────────────────────────────────── */
.overview-panel                    { max-height: 600px; }
.overview-panel .panel-body        { display: flex; flex-direction: column; overflow: hidden; min-height: 0; }
.overview-panel .tabs              { flex-shrink: 0; }
.overview-panel .tab-content       { display: none; flex: 1 1 auto; overflow-y: auto; min-height: 0; }
.overview-panel .tab-content.active { display: flex; flex-direction: column; }
.overview-panel .tab-content-inner { flex: 1 1 auto; overflow-y: auto; min-height: 0; }

.tabs {
    display: flex;
    border-bottom: 2px solid var(--stone);
    margin-bottom: 0.5rem;
}

.tab {
    padding: 0.35rem 0.6rem;
    font-family: 'Cinzel', serif;
    font-size: 0.75rem;
    color: var(--stone-dark);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
}

.tab:hover  { color: var(--ink); }
.tab.active { color: var(--gold-dark); border-bottom-color: var(--gold); }

/* ── Modal Overlay ────────────────────────────────────────── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(45,42,38,0.85);
    z-index: 1000;
    justify-content: center;
    align-items: flex-start;
    padding: 0.75rem;
    overflow-y: auto;
}

.modal-overlay.active { display: flex; }

.modal {
    background: var(--marble);
    border: 2px solid var(--gold);
    border-radius: 6px;
    width: 100%;
    max-width: 550px;
    margin: 1rem auto;
    box-shadow: 0 15px 50px rgba(0,0,0,0.5);
}

.modal-header {
    background: linear-gradient(180deg, var(--stone) 0%, var(--stone-dark) 100%);
    color: var(--parchment);
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--gold);
}

.modal-header h2 {
    font-family: 'Cinzel', serif;
    font-size: 1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--parchment);
    font-size: 1.25rem;
    cursor: pointer;
    line-height: 1;
}

.modal-body { padding: 0.75rem; }

/* ── Detail Grid (modal interiors) ────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.detail-box {
    background: var(--parchment);
    padding: 0.5rem;
    border-radius: 3px;
    border-left: 2px solid var(--gold);
}

.detail-box .label { font-size: 0.6rem; text-transform: uppercase; color: var(--stone-dark); }
.detail-box .value { font-size: 0.9rem; font-weight: 600; color: var(--ink); }

.section-title {
    font-family: 'Cinzel', serif;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--stone-dark);
    border-bottom: 1px solid var(--gold);
    padding-bottom: 0.3rem;
    margin: 1rem 0 0.5rem;
}

/* ── Inventory Grid ───────────────────────────────────────── */
.inv-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 0.4rem;
}

.inv-item {
    background: var(--parchment);
    border: 1px solid var(--parchment-dark);
    border-radius: 3px;
    padding: 0.4rem;
    text-align: center;
}

.inv-item .qty  { font-family: 'Cinzel', serif; font-size: 1.1rem; font-weight: 700; color: var(--gold-dark); }
.inv-item .name { font-size: 0.65rem; color: var(--ink); }

/* ── Action Rows ──────────────────────────────────────────── */
.action-row {
    display: flex;
    gap: 0.4rem;
    padding: 0.35rem 0;
    border-bottom: 1px solid var(--parchment-dark);
    align-items: center;
    flex-wrap: wrap;
    font-size: 0.75rem;
}

.action-tick   { font-family: 'Cinzel', serif; font-size: 0.6rem; color: var(--stone); min-width: 190px; line-height: 1.3; white-space: nowrap; }
.action-detail { flex: 1; color: var(--ink-light); }

/* ── Personality Rows ─────────────────────────────────────── */
.personality-row            { display: flex; align-items: center; gap: 0.4rem; margin-bottom: 0.3rem; }
.personality-row .trait     { font-size: 0.7rem; color: var(--ink-light); min-width: 80px; }
.personality-row .bar-track { min-width: 60px; flex: 1; }
.personality-row .bar-fill  { background: linear-gradient(90deg, var(--stone), var(--gold)); }

/* ── Leaderboard ──────────────────────────────────────────── */
.leader-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.4rem 0.5rem;
    border-bottom: 1px solid var(--parchment-dark);
    cursor: pointer;
}

.leader-row:hover   { background: var(--parchment); }
.leader-rank        { font-family: 'Cinzel', serif; font-size: 1rem; font-weight: 700; color: var(--gold); width: 22px; text-align: center; }
.leader-info        { flex: 1; min-width: 0; }
.leader-name        { font-weight: 500; color: var(--ink); font-size: 0.85rem; }
.leader-job         { font-size: 0.7rem; color: var(--stone-dark); }
.leader-money       { font-family: 'Cinzel', serif; font-weight: 700; color: var(--gold-dark); font-size: 0.85rem; }

/* ── Activity Feed ────────────────────────────────────────── */
.feed-item {
    display: flex;
    gap: 0.4rem;
    padding: 0.4rem 0;
    border-bottom: 1px solid var(--parchment-dark);
    font-size: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.feed-tick    { font-family: 'Cinzel', serif; font-size: 0.5rem; color: var(--stone); min-width: 110px; white-space: nowrap; }
.feed-content { flex: 1; color: var(--ink-light); }
.feed-person  { color: var(--gold-dark); cursor: pointer; font-weight: 500; }

/* ── Shop Items ───────────────────────────────────────────── */
.shop-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem;
    border-bottom: 1px solid var(--parchment-dark);
    cursor: pointer;
    gap: 0.5rem;
}

.shop-item:hover { background: var(--parchment); }
.shop-name       { font-weight: 500; color: var(--ink); font-size: 0.85rem; }
.shop-type       { font-size: 0.7rem; color: var(--stone-dark); font-style: italic; }
.shop-stats      { display: flex; gap: 0.6rem; font-size: 0.75rem; color: var(--ink-light); }

/* ── Spinner / Loading ────────────────────────────────────── */
.spinner-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    gap: 0.6rem;
    color: var(--stone-dark);
    font-style: italic;
    font-size: 0.8rem;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2.5px solid var(--parchment-dark);
    border-top-color: var(--gold);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.refresh-note {
    font-size: 0.65rem;
    color: var(--stone);
    text-align: right;
    padding: 0.35rem 0.5rem;
    border-top: 1px solid var(--parchment-dark);
    flex-shrink: 0;
}

.loading {
    text-align: center;
    padding: 1rem;
    color: var(--stone);
    font-style: italic;
}

/* ── Scrollbars ───────────────────────────────────────────── */
::-webkit-scrollbar       { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--parchment); }
::-webkit-scrollbar-thumb { background: var(--stone); border-radius: 3px; }

/* ── Responsive ───────────────────────────────────────────── */
@media (min-width: 768px) {
    .container                { padding: 1rem; }
    .stats-row                { grid-template-columns: repeat(8, 1fr); gap: 0.75rem; }
    .stat-card                { padding: 1rem; }
    .stat-card .label         { font-size: 0.6rem; }
    .stat-card .value         { font-size: 1.4rem; }
    .grid-main                { grid-template-columns: 3fr 2fr; }
    .header h1                { font-size: 2rem; }
    .detail-grid              { grid-template-columns: repeat(4, 1fr); }
    .citizens-panel           { max-height: 700px; }
    .overview-panel           { max-height: 700px; }
}

/* Mood filter — dims non-matching rows */
tr.mood-filtered-out { opacity: 0.15; pointer-events: none; transition: opacity 0.3s; }
tr.mood-filtered-out:hover { opacity: 0.15; }

