/* ===================================================================
   Running Dashboard - Main Stylesheet
   =================================================================== */

/* ===================================================================
   Base & Typography
   =================================================================== */

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: #ededed;
    color: var(--color-text-dark);
}

.running-app-container {
    max-width: 1600px;
    margin: 0 auto;
    padding-top: 40px;
    padding-bottom: 40px;
}

h3 {
    font-weight: 300;
}

/* ===================================================================
   Hero Section
   =================================================================== */
.running-hero-section {
    background-color: var(--color-background-dark);
    color: #fff;
    padding: 3rem 1.5rem;
    text-align: center;
    margin-bottom: 2rem;
    border-radius: .5rem;
}

.running-hero-section h1 {
    font-size: 2.5rem;
    font-weight: 600;
    margin-bottom: .5rem;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.running-hero-section .subtitle {
    font-size: 1.2rem;
    font-weight: 300;
    color: rgba(255,255,255,0.85);
    max-width: 600px;
    margin: 0 auto;
}

/* ===================================================================
   Dashboard Components
   =================================================================== */

.stats-card {
    background-color: #fff;
    border: 1px solid var(--color-border);
    border-radius: .5rem;
    padding: 1.25rem;
    height: 100%;
    text-align: center;
    box-shadow: var(--box-shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stats-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--box-shadow-md);
}

.stats-card .card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text-dark);
    margin-bottom: .75rem;
    text-transform: uppercase;
    letter-spacing: .5px;
}

.stats-highlight {
    font-size: 2rem;
    font-weight: 500;
    color: var(--color-primary);
}

.stats-unit {
    font-size: 1rem;
    color: var(--color-secondary);
    font-weight: 400;
}

.app-summary-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.app-summary-item {
    background-color: #fff;
    padding: 1rem;
    border-radius: .5rem;
    border: 1px solid var(--color-border);
    text-align: center;
}

.app-summary-label {
    font-size: 0.85rem;
    color: var(--color-secondary);
    margin-bottom: 0.25rem;
}

.app-summary-value {
    font-size: 1.5rem;
    font-weight: 500;
}

/* Filter Card Styles */
.filter-card {
    background-color: #fff;
    border: 1px solid var(--color-border);
    border-radius: .5rem;
    padding: 1.25rem;
    box-shadow: var(--box-shadow-sm);
}

.filter-section {
    padding-bottom: 1rem;
    margin-bottom: 1rem;
    border-bottom: 1px solid var(--color-border);
}

.filter-card .filter-section:last-child {
    padding-bottom: 0;
    margin-bottom: 0;
    border-bottom: none;
}

.app-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1rem;
    padding: 1rem;
    background-color: #fff;
    border-radius: .5rem;
    border: 1px solid var(--color-border);
}

.form-label-sm {
    font-size: .875rem;
    font-weight: 500;
    color: var(--color-secondary);
    margin-bottom: .25rem;
    display: block;
}

.dashboard-section-header {
    text-align: center;
    margin: 3rem 0 1.5rem 0;
}
.dashboard-section-header h2 {
    font-size: 2.25rem;
    font-weight: 300;
    margin-bottom: .5rem;
    color: var(--color-text-dark);
}
.dashboard-section-header p {
    font-size: 1.1rem;
    color: var(--color-secondary);
    max-width: 700px;
    margin: 0 auto;
}

/* ===================================================================
   Activity Table
   =================================================================== */
.activity-table {
    border-collapse: collapse;
    min-width: 800px;
    margin-bottom: 0;
}

.table-responsive {
    border: 1px solid var(--color-border);
    border-radius: .5rem;
    overflow: hidden;
    background: #fff;
}

.activity-table thead th {
    background-color: #f8f9fa;
    font-weight: 600;
    color: var(--color-text-dark);
    text-transform: uppercase;
    font-size: 0.85em;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--color-border);
    padding: 1rem .75rem;
    white-space: nowrap;
    border-top: 0;
}

.activity-table th, .activity-table td {
    padding: .75rem;
    text-align: left;
    vertical-align: middle;
    border-top: 1px solid var(--color-border);
}

.activity-table tbody tr:first-child td {
    border-top: 0;
}

.activity-table tbody tr:hover {
    background-color: rgba(0, 123, 255, 0.05);
}

.activity-table th[data-key] {
    cursor: pointer;
    user-select: none;
}

.activity-table th[data-key] i {
    margin-left: 5px;
    color: #ccc;
    transition: transform 0.2s, color 0.2s;
}

.activity-table th[data-key].asc i,
.activity-table th[data-key].desc i {
    color: var(--color-primary);
}

.activity-table th[data-key].desc i {
    transform: rotate(180deg);
}

/* Responsive Table */
@media (max-width: 991px) {
    .activity-table, .activity-table tbody, .activity-table tr, .activity-table td {
        display: block;
        width: 100%;
        min-width: 0;
    }
    .activity-table thead {
        display: none;
    }
    .activity-table tr {
        background: #fff;
        margin-bottom: 0.75rem;
        border-radius: .5rem;
    box-shadow: var(--box-shadow-sm);
    border: 1px solid var(--color-border);
    }
    .activity-table td {
        padding: 0.6rem 1rem;
        text-align: right;
        padding-left: 40%;
        position: relative;
        border-top: 1px solid #f1f1f1;
        font-size: 0.9rem;
    }
    .activity-table td:first-child {
        border-top: 0;
    }
    .activity-table td::before {
        content: attr(data-label);
        position: absolute;
        left: 1rem;
        width: 35%;
        text-align: left;
        font-weight: 600;
        color: var(--color-secondary);
        font-size: 0.8em;
        text-transform: uppercase;
    }
}


/* ===================================================================
   Detail View
   =================================================================== */
.detail-view-wrap {
    background: #fff;
    padding: 2rem;
    border-radius: .5rem;
    border: 1px solid var(--color-border);
}

.detail-title {
    font-size: 2.25rem;
    font-weight: 600;
    margin-bottom: .5rem;
}

.detail-meta {
    font-size: 1rem;
    color: var(--color-secondary);
    margin-bottom: 2rem;
}

.detail-meta a {
    color: var(--color-secondary);
    text-decoration: none;
}
.detail-meta a:hover {
    color: var(--color-primary);
    text-decoration: underline;
}

.detail-widget {
    margin-top: 2.5rem;
}

.detail-widget-title {
    font-size: 1.5rem;
    font-weight: 500;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: .75rem;
    margin-bottom: 1.5rem;
}

.activity-photo-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
}

.activity-photo-gallery img {
    width: 100%;
    height: auto;
    border-radius: .5rem;
    object-fit: cover;
    border: 1px solid var(--color-border);
}

.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.kpi-item {
    background: var(--light-gray);
    padding: .75rem 1rem;
    border-radius: .5rem;
    border: 1px solid #e9ecef;
}

.kpi-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-secondary);
    text-transform: uppercase;
    margin-bottom: .25rem;
}

.kpi-value {
    font-size: 1.25rem;
    font-weight: 500;
}

.analysis-points {
    padding-left: 1.25rem;
    margin-bottom: 1rem;
    list-style-type: '✓ ';
}
.analysis-points li {
    padding-left: .5rem;
    margin-bottom: .5rem;
}

.analysis-recommendation {
    background: #e9f7fd;
    border-left: 4px solid #0dcaf0;
    padding: 1rem;
    border-radius: .25rem;
}

/* ===================================================================
   Compare Panel
   =================================================================== */
.compare-panel {
    background: var(--light-gray);
    border: 1px solid var(--color-border);
    border-radius: .5rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    display: none; /* Initially hidden */
}

.compareDeepWrap {
    background: #fff;
    padding: 1.5rem;
    border-radius: .5rem;
    border: 1px solid var(--color-border);
    margin-top: 1.5rem;
    box-shadow: var(--box-shadow-sm);
}

.compareMetricBreakdown {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.compareInsightsWrap {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin: 1.5rem 0;
}

.compare-head {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 1rem;
    border-bottom: 1px solid var(--color-border);
    padding-bottom: 1rem;
    margin-bottom: 1rem;
}

.compare-subtitle {
    font-size: 0.9rem;
    margin-bottom: 0;
    color: var(--color-secondary);
}

.compare-mode-group {
    flex-shrink: 0;
    display: inline-flex;
    border: 1px solid var(--color-primary);
    border-radius: .5rem;
    overflow: hidden;
}
.compare-mode-btn {
    border: none;
    background: transparent;
    color: var(--color-primary);
    padding: .5rem 1rem;
    cursor: pointer;
}
.compare-mode-btn.active {
    background: var(--color-primary);
    color: #fff;
}

.run-map-container {
    height: 450px;
    width: 100%;
    border: 1px solid var(--color-border);
    background-color: #f8f9fa;
    border-radius: .5rem;
    box-shadow: var(--box-shadow-sm);
}

.compare-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.compare-item {
    background: #fff;
    padding: 1rem;
    border: 1px solid var(--color-border);
    border-radius: .5rem;
    box-shadow: var(--box-shadow-sm);
    font-size: 0.9rem;
    transition: transform 0.2s, box-shadow 0.2s;
}
.compare-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--box-shadow-md);
}
.compare-item .muted {
    color: var(--color-secondary);
    font-size: 0.8rem;
}

.compare-insights {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin: 1.5rem 0;
}

.compare-insight-card {
    flex: 1 1 200px;
    background: #f8f9fa;
    padding: 1rem;
    border-radius: .5rem;
    text-align: center;
    border: 1px solid #e9ecef;
}

.compare-insight-card strong {
    display: block;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--color-secondary);
    margin-bottom: .25rem;
}

.compare-insight-card div {
    font-size: 1.1rem;
    font-weight: 500;
}

.compare-insight-card .muted {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--color-primary);
}

.compare-matrix {
    width: 100%;
    margin-top: 1.5rem;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.compare-matrix th, .compare-matrix td {
    padding: .75rem;
    text-align: left;
    border: 1px solid var(--color-border);
    vertical-align: middle;
}
.compare-matrix thead th {
    background-color: #f8f9fa;
    font-weight: 600;
}
.compare-matrix .is-winner {
    background-color: #d1e7dd;
    font-weight: 600;
}
.compare-matrix .is-loser {
    background-color: #f8d7da;
}
.compare-matrix .muted {
    font-size: 0.8rem;
    color: var(--color-secondary);
    font-weight: 400;
    display: block;
}

.compareMatrixWrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.compare-deltas {
    margin-top: 1.5rem;
    font-size: 0.9rem;
}
.compare-delta-row {
    display: flex;
    justify-content: space-between;
    padding: .5rem;
    border-bottom: 1px solid var(--color-border);
}
.compare-delta-row:last-child {
    border-bottom: none;
}
.compare-delta-row span:first-child {
    font-weight: 500;
}


/* ===================================================================
   Comments Section
   =================================================================== */
.comments-section {
    margin-top: 2.5rem;
    padding-top: 2rem;
    border-top: 1px solid var(--color-border);
}

.comment-form-wrap {
    background: var(--light-gray);
    padding: 1.5rem;
    border-radius: .5rem;
    margin-bottom: 2rem;
}

.comments-list .comment-item {
    padding: 1rem 0;
    border-bottom: 1px solid #e9ecef;
}
.comments-list .comment-item:last-child {
    border-bottom: none;
}

.comment-meta {
    font-size: 0.875rem;
    color: var(--color-secondary);
    margin-bottom: 0.5rem;
}

.comment-body {
    line-height: 1.6;
}

.comment-actions {
    margin-top: .5rem;
}

/* ===================================================================
   App Sub-Navigation
   =================================================================== */
.app-sub-nav {
    background-color: #fff;
    border-bottom: 1px solid var(--color-border);
    padding: 0.5rem 0;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.04);
}
.app-sub-nav .container {
    max-width: 1600px;
}
.app-sub-nav nav {
    display: flex;
    gap: 1.5rem;
    justify-content: flex-start;
}
.app-sub-nav nav a {
    text-decoration: none;
    color: var(--color-text-dark);
    font-weight: 500;
    padding: 0.5rem 0;
    border-bottom: 2px solid transparent;
    transition: border-color 0.2s, color 0.2s;
}
.app-sub-nav nav a:hover,
.app-sub-nav nav a.active {
    color: var(--color-primary);
    border-bottom-color: var(--color-primary);
}

.app-sub-nav nav a:hover {
    color: var(--color-primary);
}

/* ===================================================================
   Stats Page
   =================================================================== */
.stats-card .list-group-item {
    font-size: 0.9rem;
    padding: 0.75rem 1rem;
}

.stats-card .card-header {
    background-color: #f8f9fa;
    font-size: 0.9rem;
}

.stats-note {
    font-size: 0.85rem;
    line-height: 1.5;
    margin-top: 1rem;
    padding: 1rem;
    background-color: #f8f9fa;
    border-radius: .25rem;
}

.chart-container.chart-narrow {
    max-width: 450px;
    margin: 0 auto;
    height: 300px;
}
/* A simple, responsive grid for your dashboard cards */
.dashboard-grid {
    display: grid;
    /* On larger screens, create a flexible grid that fits as many 350px cards as possible */
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
}

/* A clear, high-contrast focus style for keyboard navigation */
:focus-visible {
    outline: 3px solid #005fcc;
    outline-offset: 2px;
    box-shadow: 0 0 0 5px rgba(0, 95, 204, 0.3);
}

/* On screens smaller than 768px (tablets and phones) */
@media (max-width: 768px) {
    .dashboard-grid {
        /* Switch to a single column layout */
        grid-template-columns: 1fr;
    }
}

/* Wrapper for tables to make them horizontally scrollable on small screens */
.table-responsive-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
