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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    line-height: 1.6;
    color: #334155;
    background-color: #f8fafc;
    height: 100vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

/* Header */
header {
    background: #f8fafc;
    flex-shrink: 0;
    padding: 0;
}

.nav-container {
    max-width: 100%;
    padding: 2.5rem 3rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
}

.nav-buttons {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* Buttons */
.btn-primary {
    background: #4c88f7;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(76, 136, 247, 0.2);
}

.btn-primary:hover {
    background: #3b77e6;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(76, 136, 247, 0.3);
}

.btn-secondary {
    background: white;
    color: #64748b;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.btn-secondary:hover {
    background: #f8fafc;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

/* Main Content */
main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 3rem 3rem 3rem;
    gap: 0;
    overflow: hidden;
}

/* Status Section */
.status-section {
    flex-shrink: 0;
    padding: 0 0 1.5rem 0;
}

.current-filters {
    display: flex;
    align-items: center;
    gap: 2rem;
}

.agency-status, .time-period-status {
    display: flex;
    align-items: center;
    gap: 0;
}

.filter-label {
    font-weight: 500;
    color: #64748b;
    font-size: 0.875rem;
}

.filter-value {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.875rem;
}

/* Combined Button Style */
.combined-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0;
    background: transparent;
    border: none;
    font-weight: 600;
    font-size: 0.875rem;
    color: #1e293b;
    cursor: pointer;
    transition: color 0.2s ease;
}

.combined-btn:hover {
    color: #4c88f7;
}

.combined-btn:hover i {
    color: #4c88f7;
}

.combined-btn i {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease, color 0.2s ease;
    color: #94a3b8;
}

/* Agency Star Button (next to agency name) */
/*
.agency-star-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    color: #94a3b8;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.5rem;
    position: relative;
}

.agency-star-btn:hover {
    color: #4c88f7;
}

.agency-star-btn.following {
    color: #4c88f7;
}

.agency-star-btn.following::before {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='%234c88f7' stroke='%234c88f7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='12,2 15.09,8.26 22,9.27 17,14.14 18.18,21.02 12,17.77 5.82,21.02 7,14.14 2,9.27 8.91,8.26'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: 16px 16px;
}

.agency-star-btn.following i {
    opacity: 0;
}

.agency-star-btn.hidden {
    display: none;
}

.agency-star-btn i {
    width: 16px;
    height: 16px;
}
*/

/* Dropdown Styles */
.dropdown {
    position: relative;
}

.dropdown-content {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    min-width: 160px;
    background: white;
    border: none;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

.dropdown.open .dropdown-content {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown.open .combined-btn i[data-lucide="chevron-down"] {
    transform: rotate(180deg);
    color: #4c88f7;
}

.dropdown-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: #475569;
    transition: background 0.15s ease;
}

.dropdown-item:hover {
    background: #f8fafc;
}

.dropdown-item.active {
    background: #eff6ff;
    color: #4c88f7;
    font-weight: 500;
}

.dropdown-item:first-child {
    border-radius: 8px 8px 0 0;
}

.dropdown-item:last-child {
    border-radius: 0 0 8px 8px;
}

/* Data Display */
.data-display {
    flex: 1;
    background: white;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    position: relative;
}

.view {
    display: none;
    flex: 1;
    flex-direction: column;
    padding: 2rem;
    overflow: hidden;
}

.view.active {
    display: flex;
}

#chart-container,
#table-container {
    flex: 1;
    min-height: 0;
    background: #fefefe;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

#chart-container:empty,
#table-container:empty {
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
}

#chart-container:empty::before {
    content: "📊 Chart will load here";
    color: #64748b;
    font-weight: 500;
    font-size: 0.875rem;
}

#table-container:empty::before {
    content: "📋 Table will load here";
    color: #64748b;
    font-weight: 500;
    font-size: 0.875rem;
}

/* Floating Controls */
.floating-controls {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    display: flex;
    gap: 0.5rem;
    z-index: 100;
}

.floating-btn {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    color: #64748b;
}

.floating-btn:hover {
    background: #f8fafc;
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
    color: #374151;
}

/* DataTables */
.dataTables_wrapper {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter {
    margin-bottom: 1rem;
}

.dataTables_wrapper .dataTables_scroll {
    flex: 1;
}

table.dataTable {
    font-size: 0.875rem;
    border-collapse: separate;
    border-spacing: 0;
}

table.dataTable thead th {
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    color: #475569;
    font-weight: 600;
    padding: 0.75rem;
}

table.dataTable tbody td {
    padding: 0.75rem;
    border-bottom: 1px solid #f1f5f9;
    color: #475569;
}

table.dataTable tbody tr:hover {
    background: #f8fafc;
}

/* Chart.js */
#chart-container canvas {
    max-height: 100% !important;
}

/* Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    transform: scale(0.95);
    transition: transform 0.2s ease;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

.modal-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1e293b;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    color: #64748b;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: #f8fafc;
    color: #374151;
}

.modal-body {
    padding: 1.5rem;
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Search Container - Fixed */
.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-container::before {
    content: "";
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: 16px 16px;
    z-index: 10;
    pointer-events: none;
}

#agency-search {
    width: 100%;
    padding: 12px 16px 12px 40px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.875rem;
    background: white;
    transition: all 0.2s ease;
}

#agency-search:focus {
    outline: none;
    border-color: #4c88f7;
    box-shadow: 0 0 0 3px rgba(76, 136, 247, 0.1);
}

/* Agency List */
.agency-list {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
}

.agency-list.hidden {
    display: none;
}

.agency-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.875rem;
    color: #475569;
    transition: background 0.15s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.agency-item:hover {
    background: white;
}

.agency-item:last-child {
    border-bottom: none;
}

.agency-item.selected {
    background: #eff6ff;
    color: #4c88f7;
    font-weight: 500;
}

.agency-item input[type="radio"] {
    margin: 0;
}

.modal-footer {
    padding: 1.5rem;
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* Modal Star Button (in search results) */
.agency-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

/*
.modal-star-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    color: #94a3b8;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.modal-star-btn:hover {
    color: #4c88f7;
    background: rgba(76, 136, 247, 0.1);
}

.modal-star-btn.following {
    color: #4c88f7;
}

.modal-star-btn.following::before {
    content: "";
    position: absolute;
    width: 16px;
    height: 16px;
    background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='%234c88f7' stroke='%234c88f7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolygon points='12,2 15.09,8.26 22,9.27 17,14.14 18.18,21.02 12,17.77 5.82,21.02 7,14.14 2,9.27 8.91,8.26'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-size: 16px 16px;
}

.modal-star-btn.following i {
    opacity: 0;
}

.modal-star-btn i {
    width: 16px;
    height: 16px;
    transition: opacity 0.2s ease;
}
*/

/* Update agency-item to use space-between layout */
.agency-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.875rem;
    color: #475569;
    transition: background 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

/* DataTable Styling */
#table-container {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

/* DataTable wrapper */
.dataTables_wrapper {
    font-family: 'Inter', sans-serif !important;
}

/* Table styling */
#ridership-table {
    width: 100% !important;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 8px;
    overflow: hidden;
}

#ridership-table thead th {
    background: #f8fafc;
    color: #374151;
    font-weight: 600;
    padding: 16px 12px;
    text-align: left;
    border-bottom: 2px solid #e5e7eb;
    font-size: 14px;
}

#ridership-table tbody td {
    padding: 12px;
    border-bottom: 1px solid #f3f4f6;
    font-size: 14px;
    color: #374151;
}

#ridership-table tbody tr:hover {
    background-color: #f9fafb;
}

#ridership-table tbody tr:last-child td {
    border-bottom: none;
}

/* DataTable controls styling */
.dataTables_length,
.dataTables_filter,
.dataTables_info,
.dataTables_paginate {
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    color: #6b7280;
}

.dataTables_length {
    margin-bottom: 16px;
}

/* Hide DataTable search with proper specificity */
.dataTables_wrapper .dataTables_filter {
    display: none;
}

.dataTables_filter {
    margin-bottom: 16px;
}

.dataTables_filter input {
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 8px 12px;
    margin-left: 8px;
    font-size: 14px;
}

.dataTables_paginate {
    margin-top: 16px;
}

.dataTables_paginate .paginate_button {
    padding: 8px 12px !important;
    margin-left: 4px;
    border: 1px solid #d1d5db !important;
    border-radius: 6px !important;
    background: white !important;
    color: #374151 !important;
    text-decoration: none !important;
}

.dataTables_paginate .paginate_button:hover {
    background: #f3f4f6 !important;
    color: #374151 !important;
}

.dataTables_paginate .paginate_button.current {
    background: #3b82f6 !important;
    color: white !important;
    border-color: #3b82f6 !important;
}

/* Right align ridership numbers */
.text-right {
    text-align: right !important;
    font-variant-numeric: tabular-nums;
    font-weight: 500;
}

/* Icons */
.lucide {
    width: 16px;
    height: 16px;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f5f9;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Modern chart styling */
#chart-container {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    height: 100%; /* Fill available height */
    position: relative;
}

#ridership-chart {
    max-height: 350px;
}

/* Clean chart view without background */
#chart-view {
    background: transparent;
    min-height: 500px;
    padding: 0; /* Remove padding so chart takes full space */
    border-radius: 12px;
}

.mode-item.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.mode-item.disabled span {
    font-style: italic;
    color: #6b7280;
}

/* Mode list styling - match agency list appearance */
.mode-list {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    background: #f8fafc;
    max-height: 300px; /* Add max height for scrolling */
}

.mode-list.hidden {
    display: none;
}

.mode-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid #e2e8f0;
    font-size: 0.875rem;
    color: #475569;
    transition: background 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.mode-item:hover {
    background: white;
}

.mode-item:last-child {
    border-bottom: none;
}

.mode-item.selected {
    background: #eff6ff;
    color: #4c88f7;
    font-weight: 500;
}

/* Mode info styling - match agency info */
.mode-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.mode-info input[type="radio"] {
    margin: 0;
}

.mode-info label {
    cursor: pointer;
    flex: 1;
}

.mode-item.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.mode-item.disabled span {
    font-style: italic;
    color: #6b7280;
}

/* Auth modal styling */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #374151;
    font-size: 0.875rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: border-color 0.2s ease;
}

.form-group input:focus {
    outline: none;
    border-color: #4c88f7;
    box-shadow: 0 0 0 3px rgba(76, 136, 247, 0.1);
}

.auth-description {
    color: #6b7280;
    font-size: 0.875rem;
    margin: 0.75rem 0;
    text-align: center;
}

.error-message {
    background: #fef2f2;
    color: #dc2626;
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
    margin-top: 1rem;
}

.success-message {
    background: #f0fdf4;
    color: #16a34a;
    padding: 0.75rem;
    border-radius: 6px;
    font-size: 0.875rem;
    margin-top: 1rem;
}

.hidden {
    display: none;
}

.filter-tags-container {
    display: flex;
    gap: 8px;
    margin-left: 16px;
    align-items: center;
}

.filter-tag {
    display: flex;
    align-items: center;
    background: #f3f4f6;
    border-radius: 16px;
    padding: 4px 8px;
    font-size: 14px;
    gap: 4px;
}

.filter-tag-remove {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 50%;
    font-size: 16px;
    line-height: 1;
    color: #666;
}

.filter-tag-remove:hover {
    background: #e5e7eb;
}

/* Dashboard Styles */
.dashboard-section {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 2rem 3rem 3rem 3rem;
    gap: 2rem;
    overflow: hidden;
}

.dashboard-section.hidden {
    display: none;
}

.dashboard-header {
    flex-shrink: 0;
}

.dashboard-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.dashboard-subtitle {
    color: #64748b;
    font-size: 0.875rem;
    margin: 0;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 1.5rem;
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.agency-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
    min-height: 280px;
    display: flex;
    flex-direction: column;
}

.agency-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
}

.agency-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
    gap: 1rem;
}

.agency-card-title {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.875rem;
    line-height: 1.4;
    flex: 1;
}

.agency-card-chart {
    flex: 1;
    min-height: 160px;
    position: relative;
    height: 160px; /* Add explicit height */
}

.agency-card-stats {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 1rem;
    border-top: 1px solid #f1f5f9;
    margin-top: auto;
}

.stat-item {
    text-align: center;
}

.stat-value {
    font-weight: 600;
    color: #1e293b;
    font-size: 0.875rem;
    display: block;
}

.stat-label {
    color: #64748b;
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

/* Loading States */
.dashboard-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    gap: 1rem;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #f1f5f9;
    border-top: 3px solid #4c88f7;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Empty State */
.dashboard-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
}

.empty-state {
    text-align: center;
    max-width: 400px;
    padding: 2rem;
}

.empty-state i {
    width: 48px;
    height: 48px;
    color: #94a3b8;
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1.125rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: #64748b;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 768px) {
    .modal-content {
        width: 95%;
        max-height: 90vh;
        margin: 1rem;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-footer button {
        width: 100%;
    }

    .nav-container {
        padding: 1rem;
        flex-direction: column;
        gap: 1rem;
    }

    .nav-buttons {
        width: 100%;
        justify-content: center;
    }

    main {
        padding: 0 1rem 1rem 1rem;
    }

    .current-filters {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
}