/* Base styles shared across all pages */

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

:root {
    --blue: #3381db;
    --green: #00b84e;
    --red: #ff4b36;
    --orange: #ffd023;

    --bg: #f5f5f5;
    --surface: #fff;
    --text: #333;
    --text-secondary: #666;
    --text-muted: #888;
    --border: #ddd;
    --border-light: #eee;
    --hover: #e0e0e0;
    --tab-bg: #f5f5f5;
    --selected-bg: #e3f2fd;
    --shadow: rgba(0, 0, 0, 0.1);
    --shadow-strong: rgba(0, 0, 0, 0.15);
    --overlay: rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] {
    --bg: #09090b;
    --surface: #18181b;
    --text: #f4f4f5;
    --text-secondary: #a1a1aa;
    --text-muted: #71717a;
    --border: #3f3f46;
    --border-light: #27272a;
    --hover: #27272a;
    --tab-bg: #18181b;
    --selected-bg: #27272a;
    --shadow: rgba(0, 0, 0, 0.4);
    --shadow-strong: rgba(0, 0, 0, 0.5);
    --overlay: rgba(0, 0, 0, 0.6);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    background: var(--bg);
    color: var(--text);
}

/* Toolbar */
#toolbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.5rem 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 3px var(--shadow);
    flex-shrink: 0;
    position: relative;
    z-index: 10;
}

#toolbar .logo img {
    height: 32px;
}

#toolbar .nav-link {
    color: var(--blue);
    text-decoration: none;
    font-size: 0.9rem;
    padding: 0.4rem 0.8rem;
    border: 1px solid var(--blue);
    border-radius: 4px;
    background: none;
    cursor: pointer;
}

#toolbar .nav-link:hover {
    background: var(--blue);
    color: #fff;
}

/* View Tabs */
#viewTabs {
    display: flex;
    gap: 0;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.tab-btn {
    padding: 0.5rem 1rem;
    border: 1px solid var(--border);
    background: var(--tab-bg);
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: all 0.2s;
}

.tab-btn:first-child {
    border-radius: 4px 0 0 4px;
}

.tab-btn:last-child {
    border-radius: 0 4px 4px 0;
    border-left: none;
}

.tab-btn:hover {
    background: var(--hover);
}

.tab-btn.active {
    background: var(--blue);
    border-color: var(--blue);
    color: #fff;
}

/* Utilities */
.inline {
    display: flex;
    gap: 0.3rem;
    align-items: center;
}

/* Color indicators */
.circle {
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 50%;
    background-color: color-mix(in srgb, var(--color1, black) calc(var(--compliance, 0)*2%), var(--color2, black));
}

.blue {
    background: var(--blue);
}

.orange {
    background: var(--orange);
}

.red {
    background: var(--red);
}

.green {
    background: var(--green);
}

/* Sidebar */
#mainContent {
    flex: 1;
    display: flex;
    overflow: hidden;
}

#sidebar {
    width: 200px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    overflow: hidden;
}

.legend {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    font-size: 0.75rem;
    padding: 0.8rem 1rem;
    border-bottom: 1px solid var(--border-light);
}

#gradientLegend {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

#gradientLegend .gradient {
    flex: 1;
    height: 10px;
    background: linear-gradient(to right, #dc3545, #ffa500, #4cc04c, #4a90d9);
    border-radius: 2px;
}

#reports {
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text);
    padding: 0.2rem 0;
}

.nav-item:hover {
    text-decoration: underline;
}

.nav-item.selected {
    background: var(--selected-bg);
    margin: 0 -1rem;
    padding: 0.2rem 1rem;
    border-radius: 0;
    font-weight: 500;
}

.nav-item .count {
    color: var(--text-muted);
    font-size: 0.75rem;
    margin-left: auto;
}

.nav-item>span:not(.count) {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Tooltip for compliance circles */
.tooltip {
    position: relative;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: fit-content;
    max-width: 80px;
    background-color: black;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px 0.6rem;
    position: absolute;
    left: 1.5rem;
    top: 50%;
    transform: translateY(-50%);
    z-index: 1000;
    font-size: 0.75rem;
    white-space: nowrap;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    pointer-events: none;
}

/* Hamburger button - hidden on desktop */
#burgerBtn {
    display: none;
    background: none;
    border: none;
    font-size: 1.4rem;
    cursor: pointer;
    padding: 0.2rem 0.4rem;
    color: var(--text);
    line-height: 1;
}

#themeToggle {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.2rem 0.5rem;
    color: var(--text-secondary);
    line-height: 1;
    margin-left: auto;
    transition: color 0.2s;
}

#themeToggle:hover {
    color: var(--text);
}

#sidebarOverlay {
    display: none;
}

/* Responsive base */
@media (max-width: 768px) {
    #burgerBtn {
        display: block;
    }

    #toolbar {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    #toolbar .nav-link {
        font-size: 0.8rem;
        padding: 0.3rem 0.6rem;
    }

    #sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 260px;
        height: 100vh;
        max-height: none;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
        border-right: 1px solid var(--border);
        border-bottom: none;
        box-shadow: 2px 0 8px var(--shadow-strong);
    }

    #sidebar.open {
        transform: translateX(0);
    }

    #sidebarOverlay {
        display: none;
        position: fixed;
        inset: 0;
        background: var(--overlay);
        z-index: 99;
    }

    #sidebarOverlay.open {
        display: block;
    }

    #reports {
        flex-direction: column;
        gap: 0.3rem;
        padding: 0.5rem 1rem;
    }

    .nav-item {
        padding: 0.3rem 0;
    }

    .nav-item.selected {
        margin: 0 -1rem;
        padding: 0.3rem 1rem;
    }

    #viewTabs {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        transform: none;
        z-index: 10;
        background: var(--surface);
        border-top: 1px solid var(--border);
        box-shadow: 0 -1px 3px var(--shadow);
        justify-content: stretch;
    }

    #viewTabs .tab-btn {
        flex: 1;
        border-radius: 0;
        border-left: none;
        border-right: none;
        border-top: none;
        border-bottom: none;
        padding: 0.7rem 1rem;
    }

    #viewTabs .tab-btn:first-child {
        border-radius: 0;
        border-right: 1px solid var(--border);
    }

    #viewTabs .tab-btn:last-child {
        border-radius: 0;
    }

    body {
        padding-bottom: 44px;
    }
}

@media (max-width: 480px) {
    #toolbar .logo img {
        height: 24px;
    }

    #toolbar .nav-link {
        font-size: 0.75rem;
    }
}
