/* ACC Complementary Palette — cool slate base with warm gold accent */
:root {
    --acc-gold: #c8a44e;
    --acc-gold-hover: #b8943e;
    --acc-slate: #1e2a38;
    --acc-slate-light: #263445;
    --acc-slate-border: #374a5e;
    --acc-text: #e2e6ea;
    --acc-text-muted: #8a95a3;
    --acc-positive: #5dab6a;
    --acc-negative: #d45d5d;

    /* Pico dark theme overrides */
    --pico-primary: var(--acc-gold);
    --pico-primary-hover: var(--acc-gold-hover);
    --pico-primary-focus: rgba(200, 164, 78, 0.25);
    --pico-primary-inverse: #1a1a1a;
    --pico-background-color: #141c26;
    --pico-card-background-color: var(--acc-slate);
    --pico-card-border-color: var(--acc-slate-border);
}

/* Nav bar */
nav {
    background-color: var(--acc-slate) !important;
    border-bottom: 2px solid var(--acc-gold);
    padding: 0.5rem 0;
    position: relative;
}

.mobile-menu-toggle {
    display: none;
}

nav .logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

nav .logo img {
    height: 40px;
    width: auto;
}

nav .logo strong {
    color: var(--acc-text) !important;
    font-size: 1.1rem;
}

nav a {
    color: var(--acc-text-muted) !important;
    transition: color 0.2s;
}

nav a:hover {
    color: var(--acc-gold) !important;
}

/* Metric cards */
.metric-value {
    font-size: 2rem;
    font-weight: 700;
    text-align: center;
    margin: 0;
    color: var(--acc-gold);
}

#metrics-row article {
    text-align: center;
    padding: 1rem;
    background-color: var(--acc-slate);
    border: 1px solid var(--acc-slate-border);
    border-radius: 8px;
}

#metrics-row article header {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--acc-text-muted);
    margin-bottom: 0.25rem;
}

/* Positive/negative indicators */
.metric-positive {
    color: var(--acc-positive) !important;
}

.metric-negative {
    color: var(--acc-negative) !important;
}

/* Mobile: metric cards as 2x2 grid */
@media (max-width: 768px) {
    #metrics-row {
        display: grid !important;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    #metrics-row article {
        padding: 0.5rem;
    }

    .metric-value {
        font-size: 1.4rem;
    }

    #metrics-row article header {
        font-size: 0.65rem;
    }

    /* Stack filters vertically */
    .filter-bar {
        display: flex;
        flex-direction: column;
        gap: 0.4rem;
    }

    .filter-bar select {
        width: 100%;
    }

    /* Date range: full width, side by side */
    .date-range-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }

    .date-inputs {
        display: grid;
        grid-template-columns: auto 1fr auto 1fr;
        align-items: center;
        gap: 0.5rem;
        width: 100%;
    }

    .date-inputs input[type="date"] {
        width: 100%;
    }

    .chart-options {
        display: flex;
        flex-wrap: wrap;
        gap: 0.75rem;
        align-items: center;
    }

    /* Nav: hamburger menu on mobile */
    nav .logo img {
        height: 28px;
    }

    nav .logo strong {
        font-size: 0.85rem;
    }

    .nav-links {
        display: none !important;
        flex-direction: column;
        position: absolute;
        top: 100%;
        right: 0;
        background-color: var(--acc-slate);
        border: 1px solid var(--acc-slate-border);
        border-radius: 0 0 8px 8px;
        padding: 0.75rem;
        z-index: 999;
        min-width: 180px;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    }

    .nav-links.open {
        display: flex !important;
    }

    .nav-links li {
        padding: 0.4rem 0;
    }

    .mobile-menu-toggle {
        display: flex !important;
        background: none;
        border: none;
        color: var(--acc-text-muted);
        cursor: pointer;
        padding: 0.25rem;
        margin: 0;
    }

    /* Chart bigger on mobile portrait */
    canvas {
        max-height: none !important;
        height: 400px !important;
    }

    article:has(canvas) {
        padding: 0.5rem;
        min-height: 420px;
    }

    /* Data table scroll */
    figure {
        overflow-x: auto;
    }
}

/* Landscape mobile: use horizontal space */
@media (max-width: 768px) and (orientation: landscape) {
    main.container {
        max-width: 95vw;
        width: 95vw;
        padding: 0 2.5vw;
    }

    #metrics-row {
        grid-template-columns: repeat(4, 1fr) !important;
        width: 90vw;
    }

    .filter-bar {
        flex-direction: row !important;
        flex-wrap: wrap;
        gap: 0.4rem;
        width: 90vw;
    }

    .filter-bar select {
        width: auto;
        flex: 1;
        min-width: 0;
    }

    .date-range-bar {
        flex-direction: row !important;
        align-items: center;
        width: 90vw;
    }

    .date-inputs {
        flex: 1;
    }

    article:has(canvas) {
        width: 90vw;
    }

    canvas {
        height: 90vh !important;
        width: 80vw !important;
    }
}

/* Filter bar */
.filter-bar {
    margin-bottom: 1.5rem;
}

.filter-bar select {
    background-color: var(--acc-slate);
    border-color: var(--acc-slate-border);
    color: var(--acc-text);
}

.filter-bar select:focus {
    border-color: var(--acc-gold);
}

/* Chart container */
canvas {
    max-height: 400px;
}

article:has(canvas) {
    background-color: var(--acc-slate);
    border: 1px solid var(--acc-slate-border);
    border-radius: 8px;
}

/* Buttons */
button[type="submit"],
input[type="submit"] {
    background-color: var(--acc-gold);
    border-color: var(--acc-gold);
    color: #1a1a1a;
    font-weight: 600;
}

button[type="submit"]:hover,
input[type="submit"]:hover {
    background-color: var(--acc-gold-hover);
    border-color: var(--acc-gold-hover);
    color: #1a1a1a;
}

/* Tables (admin page) */
table thead {
    background-color: var(--acc-slate);
}

table thead th {
    border-bottom: 2px solid var(--acc-gold);
}

/* Date range bar */
.date-range-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.date-inputs {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.date-inputs select {
    margin: 0;
}

.date-inputs label {
    margin: 0;
    color: var(--acc-text-muted);
    font-size: 0.85rem;
}

.date-inputs input[type="date"] {
    margin: 0;
    padding: 0.4rem 0.6rem;
    background-color: var(--acc-slate);
    border-color: var(--acc-slate-border);
    color: var(--acc-text);
    width: auto;
}

.chart-options {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chart-options label {
    margin: 0;
    color: var(--acc-text-muted);
    font-size: 0.85rem;
    cursor: pointer;
}

.custom-date-group {
    margin: 0;
    display: inline-flex;
}

/* Small button variant */
.btn-sm {
    padding: 0.3rem 0.75rem;
    font-size: 0.8rem;
    margin: 0;
}

/* Admin form inputs */
input[type="date"] {
    background-color: var(--acc-slate);
    border-color: var(--acc-slate-border);
    color: var(--acc-text);
}

/* ===== Phase 2 Styles ===== */

/* Login page */
.login-container {
    max-width: 400px;
    margin: 4rem auto;
}

.login-container article {
    background-color: var(--acc-slate);
    border: 1px solid var(--acc-slate-border);
}

.login-error {
    color: var(--acc-negative);
    text-align: center;
    margin-bottom: 1rem;
}

/* User profile in nav */
.user-profile {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.user-name {
    color: var(--acc-text-muted);
    font-size: 0.85rem;
}

.logout-link {
    font-size: 0.8rem;
}

/* Notification bell */
.notification-bell {
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    padding: 0.25rem;
    color: var(--acc-text-muted);
    transition: color 0.2s;
}

.notification-bell:hover {
    color: var(--acc-gold);
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -6px;
    background-color: var(--acc-negative);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* Notification panel */
.notification-panel {
    position: fixed;
    top: 60px;
    right: 1rem;
    width: 360px;
    max-height: 480px;
    overflow-y: auto;
    background-color: var(--acc-slate);
    border: 1px solid var(--acc-slate-border);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    padding: 0.75rem;
}

.notification-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.notification-actions {
    text-align: right;
    margin-bottom: 0.5rem;
}

.notification-item {
    padding: 0.6rem;
    border-radius: 6px;
    border-left: 3px solid var(--acc-slate-border);
}

.notification-item.unread {
    background-color: var(--acc-slate-light);
    border-left-color: var(--acc-gold);
}

.notification-item.read {
    opacity: 0.6;
}

.notification-msg {
    font-size: 0.9rem;
    color: var(--acc-text);
    margin-bottom: 0.25rem;
}

.notification-detail {
    font-size: 0.8rem;
    color: var(--acc-text-muted);
}

.notification-time {
    font-size: 0.75rem;
    color: var(--acc-text-muted);
    margin-top: 0.25rem;
}

.notification-empty {
    text-align: center;
    color: var(--acc-text-muted);
    padding: 1rem;
}

/* Event Management */
.event-search {
    margin-bottom: 1rem;
    background-color: var(--acc-slate);
    border-color: var(--acc-slate-border);
    color: var(--acc-text);
}

.mapping-controls {
    margin: 0;
    gap: 0.25rem;
}

.mapping-controls select {
    font-size: 0.8rem;
    padding: 0.25rem 0.4rem;
    margin: 0;
}

tr.mapped {
    background-color: rgba(200, 164, 78, 0.08);
}

.text-muted {
    color: var(--acc-text-muted);
}

/* User Management */
.user-form {
    margin-top: 1rem;
}

.role-badge {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 0.15rem 0.5rem;
    border-radius: 4px;
}

.role-viewer { background-color: rgba(138, 149, 163, 0.2); color: var(--acc-text-muted); }
.role-manager { background-color: rgba(200, 164, 78, 0.2); color: var(--acc-gold); }
.role-admin { background-color: rgba(212, 93, 93, 0.2); color: var(--acc-negative); }

.status-active { color: var(--acc-positive); }
.status-inactive { color: var(--acc-text-muted); }

.action-menu {
    margin: 0;
}

.action-dropdown {
    padding: 0.75rem;
    min-width: 250px;
}

/* Event Data page */
.data-filters fieldset {
    margin-bottom: 0.5rem;
}

.data-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.export-buttons {
    display: flex;
    gap: 0.5rem;
}

th.sortable {
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

th.sortable:hover {
    color: var(--acc-gold);
}

th.sort-asc::after {
    content: " \25B2";
    font-size: 0.7rem;
}

th.sort-desc::after {
    content: " \25BC";
    font-size: 0.7rem;
}

#data-table td {
    font-size: 0.85rem;
    white-space: nowrap;
}

/* Drilldown popup on bar click */
#drilldown-popup {
    position: absolute;
    background-color: var(--acc-slate);
    border: 1px solid var(--acc-gold);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    z-index: 1000;
}

#drilldown-popup a {
    color: var(--acc-gold);
    text-decoration: none;
    font-size: 0.85rem;
    white-space: nowrap;
}

#drilldown-popup a:hover {
    text-decoration: underline;
}
