/* Linkt Toll Dashboard Styles */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f0f2f5;
    color: #1e293b;
    line-height: 1.5;
}

.dashboard-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.dashboard-header h2 {
    font-size: 1.5em;
    color: #1e293b;
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: wrap;
}

.data-age {
    font-size: 12px;
    color: #64748b;
    padding: 4px 10px;
    background: #e2e8f0;
    border-radius: 4px;
}

/* Buttons */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary {
    background: #2563eb;
    color: white;
}
.btn-primary:hover { background: #1d4ed8; }

.btn-secondary {
    background: #64748b;
    color: white;
}
.btn-secondary:hover { background: #475569; }

.btn-success {
    background: #16a34a;
    color: white;
}
.btn-success:hover { background: #15803d; }

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
}

/* Tabs */
.tab-nav {
    display: flex;
    gap: 2px;
    background: #e2e8f0;
    border-radius: 8px 8px 0 0;
    padding: 4px 4px 0;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
}

.tab-btn {
    padding: 10px 20px;
    background: transparent;
    border: none;
    border-radius: 6px 6px 0 0;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #64748b;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

.tab-btn:hover {
    color: #1e293b;
    background: rgba(255, 255, 255, 0.5);
}

.tab-btn.active {
    background: white;
    color: #2563eb;
    font-weight: 600;
}

.tab-content {
    display: none;
    background: white;
    border-radius: 0 0 8px 8px;
    padding: 20px;
    border: 1px solid #e2e8f0;
    border-top: none;
}

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

/* Summary Cards */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.summary-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.summary-card .card-label {
    font-size: 12px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.summary-card .card-value {
    font-size: 1.8em;
    font-weight: 700;
    color: #1e293b;
}

.summary-card .card-value.text-green { color: #16a34a; }
.summary-card .card-value.text-blue { color: #2563eb; }
.summary-card .card-value.text-orange { color: #ea580c; }
.summary-card .card-value.text-purple { color: #7c3aed; }

/* Charts */
.chart-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.chart-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
}

.chart-card h3 {
    font-size: 14px;
    color: #475569;
    margin-bottom: 12px;
}

.chart-card canvas {
    width: 100% !important;
    max-height: 300px;
}

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

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.data-table th {
    background: #f8fafc;
    border-bottom: 2px solid #e2e8f0;
    padding: 10px 12px;
    text-align: left;
    font-weight: 600;
    color: #475569;
    white-space: nowrap;
    cursor: pointer;
}

.data-table th:hover {
    background: #e2e8f0;
}

.data-table td {
    padding: 10px 12px;
    border-bottom: 1px solid #f1f5f9;
    color: #334155;
}

.data-table tr:hover td {
    background: #f8fafc;
}

.data-table .amount {
    font-weight: 600;
    color: #1e293b;
    text-align: right;
}

/* Filters */
.filter-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-bar select,
.filter-bar input {
    padding: 7px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 13px;
    background: white;
    color: #1e293b;
}

.filter-bar input[type="date"] {
    min-width: 140px;
}

/* Vehicle/Tag Cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
}

.vehicle-card,
.tag-card {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 16px;
    transition: box-shadow 0.2s;
}

.vehicle-card:hover,
.tag-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.vehicle-card h4,
.tag-card h4 {
    font-size: 16px;
    color: #1e293b;
    margin-bottom: 8px;
}

.vehicle-card .detail,
.tag-card .detail {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 4px;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.badge-active { background: #dcfce7; color: #16a34a; }
.badge-inactive { background: #fee2e2; color: #dc2626; }
.badge-paid { background: #dcfce7; color: #16a34a; }
.badge-unpaid { background: #fef3c7; color: #d97706; }

/* Scraper Progress Overlay */
.scraper-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.scraper-overlay.active {
    display: flex;
}

.scraper-modal {
    background: white;
    border-radius: 12px;
    padding: 30px;
    max-width: 500px;
    width: 90%;
    text-align: center;
}

.scraper-modal h3 {
    margin-bottom: 16px;
    color: #1e293b;
}

.progress-bar-container {
    background: #e2e8f0;
    border-radius: 8px;
    height: 24px;
    overflow: hidden;
    margin-bottom: 12px;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #2563eb, #3b82f6);
    border-radius: 8px;
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 12px;
    font-weight: 600;
    min-width: 40px;
}

.scraper-step {
    font-size: 14px;
    color: #64748b;
    margin-bottom: 8px;
}

.scraper-log {
    text-align: left;
    max-height: 200px;
    overflow-y: auto;
    background: #f8fafc;
    border-radius: 6px;
    padding: 10px;
    font-family: monospace;
    font-size: 11px;
    color: #475569;
    margin-top: 12px;
}

.scraper-log div {
    margin-bottom: 2px;
}

/* No Data State */
.no-data {
    text-align: center;
    padding: 60px 20px;
    color: #94a3b8;
}

.no-data h3 {
    font-size: 1.2em;
    margin-bottom: 8px;
    color: #64748b;
}

.no-data p {
    margin-bottom: 16px;
}

/* Recent Trips (Overview) */
.recent-trips {
    margin-top: 24px;
}

.recent-trips h3 {
    font-size: 16px;
    color: #475569;
    margin-bottom: 12px;
}

/* Confirmation Overlay */
.confirm-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 3000;
    justify-content: center;
    align-items: center;
}

.confirm-overlay.active {
    display: flex;
}

.confirm-box {
    background: white;
    border-radius: 10px;
    padding: 30px;
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.confirm-box p {
    margin-bottom: 20px;
    color: #1e293b;
}

.confirm-box .btn {
    margin: 0 6px;
}

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #e2e8f0;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Responsive */
@media (max-width: 768px) {
    .dashboard-container { padding: 12px; }
    .summary-cards { grid-template-columns: repeat(2, 1fr); }
    .chart-grid { grid-template-columns: 1fr; }
    .filter-bar { flex-direction: column; }
    .tab-nav {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        flex-wrap: nowrap;
    }
    .tab-btn { padding: 8px 14px; font-size: 13px; flex-shrink: 0; }
    .dashboard-header { flex-direction: column; align-items: flex-start; }
}

@media (max-width: 480px) {
    .summary-cards { grid-template-columns: 1fr; }
    .card-grid { grid-template-columns: 1fr; }
}

/* ==================== DARK MODE ==================== */

[data-theme="dark"] body {
    background: #0f172a;
    color: #e2e8f0;
}

[data-theme="dark"] .dashboard-header h2 {
    color: #e2e8f0;
}

[data-theme="dark"] .data-age {
    background: #1e293b;
    color: #94a3b8;
}

[data-theme="dark"] .tab-nav {
    background: #1e293b;
}

[data-theme="dark"] .tab-btn {
    color: #94a3b8;
}

[data-theme="dark"] .tab-btn:hover {
    color: #e2e8f0;
    background: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .tab-btn.active {
    background: #0f172a;
    color: #60a5fa;
}

[data-theme="dark"] .tab-content {
    background: #0f172a;
    border-color: #334155;
}

[data-theme="dark"] .summary-card {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .summary-card .card-label {
    color: #94a3b8;
}

[data-theme="dark"] .summary-card .card-value {
    color: #e2e8f0;
}

[data-theme="dark"] .chart-card {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .chart-card h3 {
    color: #94a3b8;
}

[data-theme="dark"] .data-table th {
    background: #1e293b;
    border-bottom-color: #334155;
    color: #94a3b8;
}

[data-theme="dark"] .data-table th:hover {
    background: #334155;
}

[data-theme="dark"] .data-table td {
    border-bottom-color: #1e293b;
    color: #cbd5e1;
}

[data-theme="dark"] .data-table tr:hover td {
    background: #1e293b;
}

[data-theme="dark"] .data-table .amount {
    color: #e2e8f0;
}

[data-theme="dark"] .filter-bar select,
[data-theme="dark"] .filter-bar input {
    background: #1e293b;
    border-color: #334155;
    color: #e2e8f0;
}

[data-theme="dark"] .vehicle-card,
[data-theme="dark"] .tag-card {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .vehicle-card:hover,
[data-theme="dark"] .tag-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .vehicle-card h4,
[data-theme="dark"] .tag-card h4 {
    color: #e2e8f0;
}

[data-theme="dark"] .vehicle-card .detail,
[data-theme="dark"] .tag-card .detail {
    color: #94a3b8;
}

[data-theme="dark"] .scraper-modal {
    background: #1e293b;
    color: #e2e8f0;
}

[data-theme="dark"] .scraper-modal h3 {
    color: #e2e8f0;
}

[data-theme="dark"] .progress-bar-container {
    background: #334155;
}

[data-theme="dark"] .scraper-step {
    color: #94a3b8;
}

[data-theme="dark"] .scraper-log {
    background: #0f172a;
    color: #94a3b8;
}

[data-theme="dark"] .confirm-box {
    background: #1e293b;
}

[data-theme="dark"] .confirm-box p {
    color: #e2e8f0;
}

[data-theme="dark"] .no-data {
    color: #64748b;
}

[data-theme="dark"] .no-data h3 {
    color: #94a3b8;
}

[data-theme="dark"] .recent-trips h3 {
    color: #94a3b8;
}
