/***************************************************************************************************
 * Copyright (C) 2026 by WallyHackenslacker wallyhackenslacker@noreply.git.hackenslacker.space      *
 *                                                                                                  *
 * Permission to use, copy, modify, and/or distribute this software for any purpose with or without *
 * fee is hereby granted.                                                                           *
 *                                                                                                  *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS     *
 * SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE  *
 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES      *
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,        *
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE *
 * OF THIS SOFTWARE.                                                                                *
 ****************************************************************************************************/

:root {
    /* Light Mode Variables */
    --bg-base: #f5f5f7; /* Apple-like light gray background */
    --bg-primary: #ffffff;
    --bg-secondary: #f0f0f5;
    --bg-tertiary: #e5e5ea;
    --text-primary: #1d1d1f; /* Almost black */
    --text-secondary: #86868b;
    --text-muted: #aeaeb2;
    --border-color: #d2d2d7;
    --shadow-color: rgba(0, 0, 0, 0.05);
    
    /* Pastel Accent Colors */
    --accent-color: #007aff; /* Apple Blue */
    --accent-hover: #0062cc;
    --accent-secondary: #5ac8fa; /* Apple Light Blue */
    
    /* Selection */
    --selection-bg: rgba(0, 122, 255, 0.1);
    --selection-text: #007aff;
    
    /* UI metrics */
    --card-radius: 12px;
    --button-radius: 8px;
    --border-width: 1px;
}

[data-theme="dark"] {
    /* Dark Mode Variables */
    --bg-base: #000000;
    --bg-primary: #1c1c1e;
    --bg-secondary: #2c2c2e;
    --bg-tertiary: #3a3a3c;
    --text-primary: #f5f5f7;
    --text-secondary: #86868b;
    --text-muted: #636366;
    --border-color: #38383a;
    --shadow-color: rgba(0, 0, 0, 0.2);
    
    --accent-color: #0a84ff; /* Apple Dark Mode Blue */
    --accent-hover: #409cff;
    --selection-bg: rgba(10, 132, 255, 0.15);
    --selection-text: #0a84ff;
}

@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-base: #000000;
        --bg-primary: #1c1c1e;
        --bg-secondary: #2c2c2e;
        --bg-tertiary: #3a3a3c;
        --text-primary: #f5f5f7;
        --text-secondary: #86868b;
        --text-muted: #636366;
        --border-color: #38383a;
        --shadow-color: rgba(0, 0, 0, 0.2);
        
        --accent-color: #0a84ff;
        --accent-hover: #409cff;
        --selection-bg: rgba(10, 132, 255, 0.15);
        --selection-text: #0a84ff;
    }
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    font-size: 15px; /* Slightly larger for readability */
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    background-color: var(--bg-base);
    background-image: url('__BACKGROUND_IMAGE__');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    min-height: 100vh;
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* Theme Toggle Button */
.theme-toggle {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    box-shadow: 0 2px 8px var(--shadow-color);
    transition: all 0.2s ease;
    color: var(--text-primary);
}

.theme-toggle:hover {
    background: var(--bg-secondary);
    transform: translateY(-1px);
}

.theme-toggle:active {
    transform: translateY(0);
}

.theme-toggle .icon-auto {
    position: relative;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-toggle .icon-auto::before,
.theme-toggle .icon-auto::after {
    position: absolute;
    font-size: 20px;
    line-height: 1;
}

.theme-toggle .icon-auto::before {
    content: '☀️';
    clip-path: inset(0 50% 0 0);
}

.theme-toggle .icon-auto::after {
    content: '🌙';
    clip-path: inset(0 0 0 50%);
}

/* Card Style */
.card {
    background: var(--bg-primary);
    border-radius: var(--card-radius);
    border: 1px solid var(--border-color);
    box-shadow: 0 4px 12px var(--shadow-color);
    margin-bottom: 24px;
    overflow: hidden;
    transition: box-shadow 0.3s ease;
}

.card:hover {
    box-shadow: 0 6px 16px var(--shadow-color);
}

.card-header {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-primary); /* Flat header */
}

.card-title {
    font-size: 17px; /* Apple uses specific sizing */
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.card-content {
    padding: 24px;
}

.summaries-content {
    padding: 0;
    padding-top: 0; /* Tabs sit flush */
}

/* Filters */
.filters {
    display: flex;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
}

.filter-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    padding: 8px 16px;
    border-radius: 20px; /* Pill shape */
    background: var(--bg-secondary);
    border: 1px solid transparent;
    transition: all 0.2s ease;
    font-weight: 500;
    font-size: 13px;
    color: var(--text-primary);
}

.filter-label:hover {
    background: var(--bg-tertiary);
}

.filter-label input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 4px; /* Rounded checkbox */
    border: 1px solid var(--text-muted);
    background: var(--bg-primary);
    cursor: pointer;
    position: relative;
    transition: all 0.2s ease;
    margin: 0;
}

.filter-label input[type="checkbox"]:checked {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

.filter-label input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 6px;
    top: 2px;
    width: 4px;
    height: 9px;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.filter-label .service-name {
    text-transform: capitalize;
}

.filter-label .service-count {
    color: var(--text-secondary);
    font-size: 12px;
}

/* Stats */
.stats {
    display: flex;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
}

.stat {
    text-align: center;
    padding: 24px 32px;
    background: var(--bg-secondary);
    border-radius: var(--card-radius);
    min-width: 160px;
    border: 1px solid transparent; /* Prepare for border */
}

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--accent-color);
    font-variant-numeric: tabular-nums;
    letter-spacing: -0.02em;
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 4px;
    font-weight: 500;
}

/* Charts */
.charts-wrapper {
    display: grid;
    grid-auto-columns: minmax(280px, 450px);
    grid-template-columns: repeat(auto-fill, minmax(280px, 450px));
    grid-gap: 24px;
    justify-content: center;
    flex-wrap: wrap;
}

.chart-container {
    min-width: 280px;
    max-width: 450px;
    padding: 20px;
    background: var(--bg-primary);
    border-radius: var(--card-radius);
    border: 1px solid var(--border-color);
}

.chart-title {
    font-size: 15px;
    font-weight: 600;
    text-align: center;
    margin-bottom: 16px;
    color: var(--text-primary);
}

@media (max-width: 700px) {
    .charts-wrapper {
        flex-direction: column;
        align-items: center;
    }
    .chart-container {
        max-width: 100%;
        width: 100%;
    }
}

/* Tabs */
.tabs {
    display: flex;
    padding: 0 24px;
    margin-bottom: 0;
    position: relative;
    z-index: 1;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
}

.tab {
    padding: 14px 0;
    margin-right: 24px;
    cursor: pointer;
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 14px;
    background: transparent;
    border-bottom: 2px solid transparent;
    transition: color 0.2s, border-bottom-color 0.2s;
}

.tab:hover {
    color: var(--text-primary);
}

.tab.active {
    color: var(--accent-color);
    border-bottom: 2px solid var(--accent-color);
}

.tab-content {
    background: var(--bg-primary);
    padding: 0;
}

.tab-panel {
    display: none;
}

.tab-panel.active {
    display: block;
}

/* Tables */
.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

th {
    padding: 12px 24px;
    text-align: left;
    font-weight: 600;
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-color);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td {
    padding: 12px 24px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
    height: 48px;
}

tr:hover td {
    background: var(--bg-secondary);
}

tr:last-child td {
    border-bottom: none;
}

.time {
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

.percent {
    font-variant-numeric: tabular-nums;
    text-align: right;
    color: var(--text-secondary);
}

.color-box {
    display: inline-block;
    width: 10px;
    height: 10px;
    margin-right: 12px;
    vertical-align: middle;
    border-radius: 2px; /* Slight rounding */
}

.service-badge {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    background: var(--bg-secondary);
    border-radius: 4px;
    color: var(--text-secondary);
    margin-left: 8px;
    text-transform: capitalize;
    font-weight: 500;
}

.category-badge {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    background: var(--selection-bg);
    border-radius: 4px;
    color: var(--selection-text);
    margin-left: 4px;
    text-transform: capitalize;
    font-weight: 500;
}

.no-data {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

/* Others row expansion */
.others-row {
    cursor: pointer;
}

.others-row td:first-child::before {
    content: '';
    display: inline-block;
    width: 0;
    height: 0;
    border-left: 5px solid var(--text-muted);
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    margin-right: 10px;
    transition: transform 0.2s ease;
    vertical-align: middle;
}

.others-row.expanded td:first-child::before {
    transform: rotate(90deg);
}

.others-detail {
    display: none;
    background: var(--bg-base); /* Slightly darker/lighter background for details */
}

.others-detail.visible {
    display: table-row;
}

.others-detail td {
    padding-left: 48px;
    font-size: 13px;
    color: var(--text-secondary);
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Responsive */
@media (max-width: 600px) {
    body {
        padding: 16px;
    }

    .stats {
        gap: 16px;
    }

    .stat {
        padding: 16px 20px;
        min-width: 100px;
    }

    .stat-value {
        font-size: 28px;
    }

    .filter-label {
        padding: 6px 12px;
        font-size: 13px;
    }
    
    .tabs {
        padding: 0 16px;
        overflow-x: auto;
    }

    .tab {
        padding: 12px 0;
        margin-right: 16px;
        white-space: nowrap;
    }
}

/* Scroll to Top Button */
.scroll-top {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: var(--bg-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px var(--shadow-color);
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    color: var(--text-primary);
}

.scroll-top.visible {
    opacity: 1;
    visibility: visible;
}

.scroll-top:hover {
    transform: translateY(-2px);
    background: var(--bg-secondary);
}

.scroll-top-arrow {
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 8px solid currentColor;
}
