/* CSS Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Body and Container */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #0a1a2f;
    color: white;
    overflow-x: hidden;
    line-height: 1.6;
    font-size: 14px;
    padding-top: 10px;
}

.container {
    max-width: 1800px;
    margin: 0 auto;
    padding: 20px;
    margin-top: 60px;
}

/* User Authentication Styles */
.user-auth {
    position: fixed;
    top: 10px;
    right: 20px;
    z-index: 9999;
    background: rgba(26, 45, 74, 0.98);
    padding: 10px 15px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    border: 1px solid #2d4365;
    backdrop-filter: blur(5px);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
}

.username {
    font-weight: 500;
    color: #74c0fc;
}

.logout-form {
    margin: 0;
}

.logout-btn {
    background: #dc3545;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s;
    font-weight: 500;
}

.logout-btn:hover {
    background: #c82333;
    transform: translateY(-1px);
}

.login-prompt {
    text-align: center;
}

.login-link {
    color: #4dabf5;
    text-decoration: none;
    font-weight: 500;
    padding: 6px 12px;
    border: 1px solid #4dabf5;
    border-radius: 4px;
    transition: all 0.2s;
    font-size: 12px;
}

.login-link:hover {
    background: #4dabf5;
    color: white;
    text-decoration: none;
}

.login-required {
    text-align: center;
    padding: 20px;
    background: #1a2d4a;
    border-radius: 8px;
    margin: 20px 0;
    border: 1px solid #2d4365;
}

.login-required a {
    color: #4dabf5;
    text-decoration: none;
    font-weight: 500;
}

.login-required a:hover {
    text-decoration: underline;
}

/* Common Card Styles */
.card {
    background: #1a2d4a;
    border-radius: 8px;
    padding: 20px;
    color: white;
    margin-bottom: 20px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border: 1px solid #2d4365;
}

header {
    margin-bottom: 20px;
}

.column-selection-panel {
    margin: 20px 0;
}

/* Typography */
h1 {
    color: #4dabf5;
    margin-bottom: 15px;
    font-size: 24px;
    font-weight: 700;
}

h2 {
    color: #4dabf5;
    margin-bottom: 15px;
    font-size: 20px;
    font-weight: 600;
}

h3 {
    color: #4dabf5;
    margin-bottom: 12px;
    font-size: 18px;
    font-weight: 600;
}

.chart-title {
    color: #4dabf5;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
}

.column-group h4 {
    color: #4dabf5;
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 10px 0;
    border-bottom: 1px solid #2d4365;
    padding-bottom: 8px;
}

/* Controls */
.controls {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: flex-end;
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
    min-width: 200px;
}

label {
    color: #74c0fc;
    font-weight: 600;
    font-size: 13px;
}

/* Form Elements */
input,
select,
button {
    padding: 10px 12px;
    border-radius: 6px;
    border: 1px solid #2d4365;
    background: #0a1a2f;
    color: white;
    font-size: 14px;
    transition: all 0.3s ease;
}

input:focus,
select:focus {
    outline: none;
    border-color: #4dabf5;
    box-shadow: 0 0 0 2px rgba(77, 171, 245, 0.2);
}

button {
    background: #339af0;
    color: white;
    cursor: pointer;
    font-weight: 600;
    border: none;
    transition: all 0.3s ease;
    white-space: nowrap;
}

button:hover {
    background: #4dabf5;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

button:disabled {
    background: #495057;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

button:active {
    transform: translateY(0);
}

.apply-btn,
.preset-btn {
    padding: 10px 20px;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 600;
}

.apply-btn {
    background: #339af0;
    margin-right: 10px;
}

.apply-btn:hover {
    background: #4dabf5;
    transform: translateY(-1px);
}

.preset-btn {
    padding: 8px 16px;
    font-size: 12px;
    margin-right: 8px;
    margin-bottom: 8px;
}

.preset-btn.minimal {
    background: #228be6;
}

.preset-btn.minimal:hover {
    background: #339af0;
}

.preset-btn.detailed {
    background: #4dabf5;
}

.preset-btn.detailed:hover {
    background: #74c0fc;
}

.preset-btn.fuel-focused {
    background: #3b5bdb;
}

.preset-btn.fuel-focused:hover {
    background: #4d6fff;
}

/* Layout */
.dashboard {
    margin-bottom: 20px;
}

.row {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 20px;
    margin-bottom: 20px;
}

.col-12 { grid-column: span 12; }
.col-11 { grid-column: span 11; }
.col-10 { grid-column: span 10; }
.col-9 { grid-column: span 9; }
.col-8 { grid-column: span 8; }
.col-7 { grid-column: span 7; }
.col-6 { grid-column: span 6; }
.col-5 { grid-column: span 5; }
.col-4 { grid-column: span 4; }
.col-3 { grid-column: span 3; }
.col-2 { grid-column: span 2; }
.col-1 { grid-column: span 1; }

/* Charts Grid Layout */
.charts-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    width: 100%;
}

.chart-container {
    background: #152642;
    padding: 20px;
    border-radius: 8px;
    height: 300px;
    position: relative;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border: 1px solid #2d4365;
}

.chart-container-gps {
    height: 600px;
}

.chart-container-small {
    height: 350px;
}

/* Map */
#map {
    height: 100%;
    border-radius: 8px;
    overflow: hidden;
}

/* Tables */
.report-table,
.events-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    background: #152642;
    border-radius: 8px;
    overflow: hidden;
    border: 1px solid #2d4365;
}

.report-table {
    font-size: 14px;
}

.report-table th,
.report-table td {
    border: 1px solid #2d4365;
    padding: 8px;
    text-align: center;
}

.events-table th,
.events-table td {
    border: 1px solid #2d4365;
    padding: 12px 8px;
}

.events-table th {
    background: #0a1a2f;
    text-align: left;
    color: #4dabf5;
    font-weight: 600;
    border-bottom: 2px solid #4dabf5;
}

.events-table td {
    text-align: left;
}

.report-table th {
    background: #2d4365;
    color: #4dabf5;
    font-weight: bold;
    font-size: 13px;
    white-space: nowrap;
}

.report-table tr:nth-child(even) {
    background: #1a2d4a;
}

.report-table tr:hover,
.events-table tbody tr:hover {
    background: #3a5a7f;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

/* Color Classes */
.positive {
    color: #51cf66;
}

.negative {
    color: #ff6b6b;
}

.neutral {
    color: #74c0fc;
}

.event-refuel {
    color: #51cf66;
}

.event-drain {
    color: #ff6b6b;
}

.event-row.selected {
    background: #4dabf5 !important;
    color: white;
}

/* Summary & Column Selection */
.report-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
    padding: 20px;
    background: #2d4365;
    border-radius: 8px;
    border: 1px solid #3a5a7f;
}

.summary-item {
    text-align: center;
    padding: 15px;
    background: #152642;
    border-radius: 6px;
    transition: transform 0.2s ease;
    border: 1px solid #2d4365;
}

.summary-item:hover {
    transform: translateY(-2px);
}

.summary-value {
    font-size: 24px;
    font-weight: bold;
    color: #74c0fc;
    margin-bottom: 5px;
}

.summary-label {
    font-size: 13px;
    color: #cccccc;
    font-weight: 500;
}

.column-groups {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 0px;
}

.column-group {
    padding: 20px;
    border-radius: 8px;
    background: #152642;
    border: 1px solid #2d4365;
}

.column-checkboxes {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 8px;
}

.column-checkboxes label {
    display: flex;
    align-items: center;
    font-size: 12px;
    color: #cccccc;
    cursor: pointer;
    padding: 5px 0;
    transition: color 0.2s ease;
    font-weight: normal;
}

.column-checkboxes label:hover {
    color: white;
}

.column-checkboxes input[type="checkbox"] {
    margin-right: 8px;
    transform: scale(1.1);
    accent-color: #4dabf5;
    cursor: pointer;
}

.preset-buttons {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #2d4365;
    text-align: center;
}

/* Utility Classes */
.table-container {
    overflow-x: auto;
    max-width: 100%;
    margin-top: 10px;
    border-radius: 8px;
}

.event-icon {
    font-size: 18px;
    display: inline-block;
    margin-right: 8px;
}

canvas {
    max-width: 100%;
    height: auto !important;
}

/* Loading and Error States */
.loading {
    text-align: center;
    padding: 60px 40px;
    color: #4dabf5;
}

.spinner {
    border: 4px solid #1a2d4a;
    border-top: 4px solid #4dabf5;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.error-message {
    background: #ff6b6b;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    border-left: 4px solid #fa5252;
}

.success-message {
    background: #51cf66;
    color: white;
    padding: 15px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    text-align: center;
    border-left: 4px solid #40c057;
}

/* Crosshair and Tooltip */
.crosshair {
    position: absolute;
    pointer-events: none;
    z-index: 10;
}

.crosshair-vertical {
    width: 1px;
    background: #4dabf5;
    opacity: 0.7;
}

.crosshair-horizontal {
    height: 1px;
    background: #4dabf5;
    opacity: 0.7;
}

.tooltip-custom {
    position: absolute;
    background: #1a2d4a;
    border: 2px solid #4dabf5;
    padding: 10px 15px;
    border-radius: 6px;
    font-size: 12px;
    pointer-events: none;
    z-index: 100;
    white-space: nowrap;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

/* Download button styles */
.report-actions {
    margin-bottom: 0px;
    text-align: right;
}

.download-btn {
    background-color: #20c997;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.download-btn:hover {
    background-color: #12b886;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.download-btn:disabled {
    background-color: #868e96;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Upload Section Styles */
.upload-container {
    text-align: center;
}

.file-input-wrapper {
    position: relative;
    display: inline-block;
    margin: 1rem 0;
}

.file-input {
    position: absolute;
    left: -9999px;
}

.file-input-label {
    display: inline-block;
    padding: 12px 24px;
    background: #1e88e5;
    color: white;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
}

.file-input-label:hover {
    background: #1565c0;
}

.file-name {
    margin-top: 0.5rem;
    color: #cccccc;
    font-size: 0.9rem;
}

.upload-btn {
    padding: 12px 24px;
    background: #4caf50;
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    margin-top: 1rem;
}

.upload-btn:disabled {
    background: #495057;
    cursor: not-allowed;
}

.instructions {
    background: #152642;
    padding: 1rem;
    border-radius: 5px;
    margin: 1rem 0;
    text-align: left;
    border: 1px solid #2d4365;
}

.instructions h3 {
    color: #4dabf5;
    margin-top: 0;
}

.instructions ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.instructions li {
    margin: 0.25rem 0;
    color: #cccccc;
}

/* Medium screen breakpoint */
@media (max-width: 1200px) {
    .col-8-md {
        grid-column: span 12;
    }
    .col-4-md {
        grid-column: span 12;
    }
}

/* Tablet breakpoint */
@media (max-width: 992px) {
    .container {
        padding: 15px;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .col-6 {
        grid-column: span 12;
    }
}

/* Mobile breakpoint */
@media (max-width: 768px) {
    .user-auth {
        position: static;
        margin-bottom: 20px;
        text-align: center;
    }

    .user-info {
        flex-direction: column;
        gap: 10px;
    }

    .container {
        margin-top: 20px;
    }

    .row {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    [class*="col-"] {
        grid-column: 1 !important;
    }

    .controls {
        flex-direction: column;
        align-items: stretch;
    }

    .control-group {
        min-width: auto;
    }

    .charts-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }

    .column-groups {
        grid-template-columns: 1fr;
    }

    .column-checkboxes {
        grid-template-columns: 1fr;
    }

    .preset-buttons {
        text-align: center;
    }

    .preset-btn {
        display: block;
        width: 100%;
        margin-right: 0;
        margin-bottom: 10px;
    }

    .report-table {
        font-size: 10px;
    }

    .report-table th,
    .report-table td {
        padding: 6px 4px;
    }

    .report-summary {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
        gap: 10px;
        padding: 15px;
    }

    .summary-value {
        font-size: 20px;
    }

    .chart-container-gps {
        height: 400px;
    }

    .chart-container {
        height: 250px;
        padding: 15px;
    }

    .report-actions {
        text-align: center;
    }
}

/* Small mobile breakpoint */
@media (max-width: 576px) {
    .container {
        padding: 10px;
    }

    .card {
        padding: 15px;
    }

    header,
    .chart-container,
    .consolidated-report,
    .events-container,
    .column-selection-panel {
        padding: 15px;
    }

    h1 {
        font-size: 20px;
    }

    h2 {
        font-size: 18px;
    }

    h3 {
        font-size: 16px;
    }

    .chart-title {
        font-size: 14px;
    }

    .report-summary {
        grid-template-columns: 1fr 1fr;
    }

    .summary-item {
        padding: 10px;
    }

    .summary-value {
        font-size: 18px;
    }

    .download-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Print Styles */
@media print {
    .no-print,
    .controls,
    .column-selection-panel,
    .report-actions,
    .user-auth {
        display: none !important;
    }

    .chart-container {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    body {
        background: white;
        color: black;
    }

    .card {
        background: white;
        color: black;
        border: 1px solid #ddd;
    }

    h1, h2, h3, .chart-title, label, .column-group h4 {
        color: #333;
    }

    .report-table th {
        background: #f0f0f0;
        color: #333;
    }
}