/* ═══════════════════════════════════════════════════════════
   base.css — Reset, Container, Cards, Alerts, Tables,
              Grid, Utilities, HTMX
   ═══════════════════════════════════════════════════════════ */

/* ========== Brand Variables (IBB PAN) ========== */
:root {
    --brand:         #45a349;    /* IBB green (web) */
    --brand-dark:    #367f39;    /* IBB green pressed */
    --brand-active:  #45a349;
    --brand-muted:   #edf7ee;
    --accent:        #b07820;
    --page-bg:       #f7faf7;
    --surface:       #ffffff;
    --border:        #dce8dc;
    --text:          #212322;    /* IBB Pantone 419C */
    --text-muted:    #6c6d73;    /* IBB Cool Gray 10 C (Pantone, exact) */
}

/* ========== Reset & Base ========== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Lato', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    line-height: 1.6;
    color: var(--text);
    background: var(--page-bg);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Noto Sans', 'Lato', sans-serif;
}

a {
    color: var(--brand);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* ========== Container ========== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem;
    flex: 1;
    width: 100%;
    animation: pageFadeIn 0.2s ease both;
}

/* ========== Cards ========== */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 4px rgba(69, 163, 73, 0.07);
    transition: box-shadow 0.2s ease;
}

.card h2, .card h3 {
    margin-bottom: 0.75rem;
}

.card-header {
    background: var(--brand-muted);
    border-bottom: 1px solid var(--border);
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 1rem;
    margin: -1rem -1rem 1rem -1rem;
    border-radius: 8px 8px 0 0;
}

.card-body {
    padding: 0;
}

/* Anchor cards (clickable — e.g. calendar landing) */
a.card {
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}
a.card:hover {
    box-shadow: 0 4px 16px rgba(69, 163, 73, 0.15);
    transform: translateY(-2px);
    text-decoration: none;
}

/* ========== Alerts / Messages ========== */
.messages {
    margin-bottom: 1rem;
}

.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    animation: slideInDown 0.2s ease both;
}

.alert-success {
    background: #dcfce7;
    color: #166534;
    border: 1px solid #86efac;
}

.alert-error {
    background: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: #fef9c3;
    color: #854d0e;
    border: 1px solid #fde68a;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

/* ========== Tables ========== */
.table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
}

.table th, .table td {
    padding: 0.6rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    background: var(--brand-muted);
    font-weight: 600;
    font-size: 0.85rem;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.03em;
}

.table tr:hover {
    background: #f2faf3;
}

/* Responsive table wrapper */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
}

/* Report totals footer row */
.table tfoot td {
    border-top: 2px solid var(--border);
    padding-top: 0.75rem;
}

/* Reports table links */
.table a {
    font-weight: 500;
}

/* Details/summary (entity reference in reports) */
details summary {
    list-style: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 0.85rem;
}
details summary::-webkit-details-marker { display: none; }
details summary::before {
    content: "▸ ";
    transition: transform 0.15s;
}
details[open] summary::before { content: "▾ "; }

/* ========== Sortable table headers ========== */
.sortable-header {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.sortable-header:hover {
    background: var(--border);
}

.sortable-table thead th:not(.no-sort) {
    cursor: pointer;
    user-select: none;
}

.sortable-table thead th:not(.no-sort):hover {
    background: var(--border);
}

/* ========== Grid layouts ========== */
.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
}

.grid-sidebar {
    display: grid;
    grid-template-columns: 1fr 320px;
    gap: 1.5rem;
}

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-sidebar {
        grid-template-columns: 1fr;
    }
}

/* ========== Utilities ========== */
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 0.85rem; }
.text-error { color: #dc2626; font-size: 0.8rem; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-1 { gap: 0.5rem; }
.gap-2 { gap: 1rem; }

/* ========== HTMX loading indicator ========== */
.htmx-indicator {
    display: none;
}
.htmx-request .htmx-indicator {
    display: inline-block;
}

/* ========== Tab Component ========== */
.op-tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: 1.25rem;
}

.op-tab {
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    margin-bottom: -2px;
    padding: 0.7rem 1.3rem;
    font-size: 0.92rem;
    font-weight: 600;
    font-family: 'Lato', inherit;
    color: var(--text-muted);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
    white-space: nowrap;
}

.op-tab:hover {
    color: var(--text);
    background: var(--brand-muted);
}

.op-tab.active {
    color: var(--brand-dark);
    border-bottom-color: var(--brand);
}

.op-tab-badge {
    background: #dc2626;
    color: white;
    font-size: 0.65rem;
    padding: 0.1rem 0.4rem;
    border-radius: 10px;
    font-weight: 700;
    line-height: 1.4;
    min-width: 18px;
    text-align: center;
}

.op-tab-pane {
    display: none;
}

.op-tab-pane.active {
    display: block;
    animation: tabReveal 0.22s ease both;
}

@media (max-width: 640px) {
    .op-tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .op-tab  { padding: 0.6rem 0.9rem; font-size: 0.85rem; }
}

/* ========== Animations ========== */
@keyframes tabReveal {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@keyframes efReveal {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}
.ef-reveal { animation: efReveal 0.18s ease both; }

@keyframes pageFadeIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

@keyframes slideInDown {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
    .container    { animation: none; }
    .alert        { animation: none; }
    a.card        { transition: none; }
    .op-tab-pane.active { animation: none; }
}
