/* Styles across all pages */

/* Self-hosted Rubik font */
@font-face {
  font-family: 'Rubik';
  src: url('../fonts/rubik/Rubik-Regular.woff2') format('woff2'),
       url('../fonts/rubik/Rubik-Regular.woff') format('woff');
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Rubik';
  src: url('../fonts/rubik/Rubik-Medium.woff2') format('woff2'),
       url('../fonts/rubik/Rubik-Medium.woff') format('woff');
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: 'Rubik';
  src: url('../fonts/rubik/Rubik-Bold.woff2') format('woff2'),
       url('../fonts/rubik/Rubik-Bold.woff') format('woff');
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

/* Global typography */
/* Most elements will inherit from body, but this ensures buttons, inputs, etc. also use it */
p, h1, h2, h3, h4, h5, h6, button, input, textarea, select, label, span, div, li, td, th {
    font-family: inherit;
}

/* All links use btn-inactive light blue color */
a {
    color: rgb(100, 170, 235);
    text-decoration: none;
}

a:hover {
    color: rgb(80, 150, 215);
    text-decoration: underline;
}

a:visited {
    color: rgb(100, 170, 235);
}

/* Force white text for link-style buttons used on auth pages */
.auth-link,
.auth-link:link,
.auth-link:visited,
.auth-link:hover,
.auth-link:active {
    color: white;
}

/* Button styles that are the same in light and dark themes */
.btn-inactive,
.btn.btn-inactive,
.action-button.btn-inactive {
    background-color: rgb(100, 170, 235);
    color: white;
}

.btn-inactive:hover,
.btn.btn-inactive:hover,
.action-button.btn-inactive:hover {
    background-color: var(--button-primary);
    color: white;
    text-decoration: none;
}

.btn-unavailable,
.btn.btn-unavailable,
.action-button.btn-unavailable {
    background-color: rgb(100, 100, 100);
    color: white;
    cursor: not-allowed;
}

.btn-unavailable:hover,
.btn.btn-unavailable:hover,
.action-button.btn-unavailable:hover {
    background-color: rgb(100, 100, 100); /* No color change on hover */
}

/* Primary buttons use CSS variables (same in both themes) */
.btn-primary {
    background-color: var(--button-primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--button-primary-hover);
}

/* Secondary buttons have hardcoded colors (same in both themes) */
.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #545b62;
}

/* Danger buttons (light red) */
.btn-danger {
    background-color: #e77777;
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
    text-decoration: none;
}

/* Anchor-based buttons keep correct text color across all link states */
.btn-primary:link,
.btn-primary:visited,
.btn-primary:hover,
.btn-primary:active {
    color: white;
}

.btn-secondary:link,
.btn-secondary:visited,
.btn-secondary:hover,
.btn-secondary:active {
    color: white;
}

.btn-danger:link,
.btn-danger:visited,
.btn-danger:hover,
.btn-danger:active {
    color: white;
    text-decoration: none;
}

/* Lighter blue inactive buttons (used for secondary CTAs) keep white text */
.btn-inactive:link,
.btn-inactive:visited,
.btn-inactive:hover,
.btn-inactive:active {
    color: white;
}

/* Style dropdowns to match the buttons */
select,
.map-style-select,
.route-person-select {
    background-color: var(--button-primary);
    color: white;
    border: 2px solid var(--button-primary);
    border-radius: 6px;
    padding: 8px 12px;
    font-family: var(--font-family-base, inherit);
    font-size: 14px;
    cursor: pointer;
    outline: none;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    appearance: none; /* Remove default styling */
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='white' viewBox='0 0 16 16'%3e%3cpath d='m7.247 4.86-4.796 5.481c-.566.647-.106 1.659.753 1.659h9.592a1 1 0 0 0 .753-1.659l-4.796-5.48a1 1 0 0 0-1.506 0z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 12px;
    padding-right: 32px; /* Make room for arrow */
    
    /* Force option styling variables */
    --option-bg-default: rgb(100, 170, 235);
    --option-bg-hover: var(--button-primary);
    --option-color: white;
}

select:hover,
.map-style-select:hover,
.route-person-select:hover {
    background-color: var(--button-primary-hover);
    border-color: var(--button-primary-hover);
}

select:focus,
.map-style-select:focus,
.route-person-select:focus {
    border-color: var(--button-primary-hover);
    box-shadow: 0 0 0 2px rgba(66, 139, 202, 0.3);
}

/* Aggressive option styling to override browser defaults */
*[is="select"] option,
select > option,
.map-style-select > option,
.route-person-select > option,
select option,
.map-style-select option,
.route-person-select option {
    background-color: var(--option-bg-default, rgb(100, 170, 235));
    background: var(--option-bg-default, rgb(100, 170, 235));
    color: var(--option-color, white);
    padding: 8px 12px;
    border: none;
    outline: none;
    box-shadow: none;
}

/* Aggressive hover state with maximum specificity */
*[is="select"] option:hover,
*[is="select"] option:focus,
*[is="select"] option:active,
select > option:hover,
select > option:focus,
select > option:active,
.map-style-select > option:hover,
.map-style-select > option:focus,
.map-style-select > option:active,
.route-person-select > option:hover,
.route-person-select > option:focus,
.route-person-select > option:active,
select option:hover,
select option:focus,
select option:active,
.map-style-select option:hover,
.map-style-select option:focus,
.map-style-select option:active,
.route-person-select option:hover,
.route-person-select option:focus,
.route-person-select option:active {
    background-color: var(--option-bg-hover, var(--button-primary));
    background: var(--option-bg-hover, var(--button-primary));
    color: var(--option-color, white);
    border: none;
    outline: none;
    box-shadow: none;
}

/* Browser-specific and high-specificity selectors */
select option[selected]:hover,
select option[selected]:focus,
.map-style-select option[selected]:hover,
.map-style-select option[selected]:focus,
.route-person-select option[selected]:hover,
.route-person-select option[selected]:focus {
    background-color: var(--button-primary);
    background: var(--button-primary);
}

/* Force hover state when select is focused */
select:focus option:hover,
select:focus option:focus,
.map-style-select:focus option:hover,
.map-style-select:focus option:focus,
.route-person-select:focus option:hover,
.route-person-select:focus option:focus {
    background-color: var(--button-primary);
    background: var(--button-primary);
    color: white;
}

/* Selected options also use active/primary color */
select option:checked,
.map-style-select option:checked,
.route-person-select option:checked {
    background-color: var(--button-primary);
}

/* Style optgroups */
select optgroup,
.map-style-select optgroup {
    background-color: rgb(80, 150, 215);
    color: white;
    font-weight: bold;
    font-style: normal;
}

/* Text utilities */
.text-center {
    text-align: center;
}

.text-left {
    text-align: left;
}

.text-right {
    text-align: right;
}

.mb-10 {
    margin-bottom: 10px;
}

.mb-20 {
    margin-bottom: 20px;
}

.mb-30 {
    margin-bottom: 30px;
}

.mt-10 {
    margin-top: 10px;
}

.mt-20 {
    margin-top: 20px;
}

.mt-30 {
    margin-top: 30px;
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner {
    border: 2px solid var(--bg-alt);
    border-top: 2px solid var(--button-primary);
    border-radius: 50%;
    width: 20px;
    height: 20px;
    animation: spin 1s linear infinite;
    display: inline-block;
    margin-right: 10px;
}

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

/* Slider base structure */
.slider {
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background-color: var(--bg-alt);
    outline: none;
    border: 1px solid var(--border-color);
}

/* Navigation */
.nav-menu {
    list-style: none;
    padding: 0;
}

.nav-menu li {
    margin-bottom: 10px;
}

.nav-menu a {
    color: var(--text-primary);
    text-decoration: none;
    padding: 8px 12px;
    display: block;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.nav-menu a.active {
    background-color: var(--button-primary);
    color: white;
}

/* Top navigation */
.top-nav {
    background-color: var(--bg-primary);
    border-bottom: 2px solid var(--border-color);
    padding: 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

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

.top-nav-left {
    display: flex;
    align-items: center;
    gap: 0;
}

.nav-link {
    color: var(--text-primary);
    text-decoration: none;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    font-family: var(--font-family-base, inherit);
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.3s ease, color 0.3s ease;
    border-bottom: 3px solid transparent;
    cursor: pointer;
}

.nav-link:hover {
    background-color: var(--button-primary);
    color: white;
    text-decoration: none;
}

.nav-link.active {
    color: var(--button-primary);
    border-bottom-color: var(--button-primary);
    background-color: var(--bg-alt);
}

.nav-username {
    font-weight: 600;
    color: var(--button-primary);
}

.nav-username:hover {
    background-color: var(--button-primary);
    color: white;
    text-decoration: none;
}

/* Dialog */
.dialog {
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-family: var(--font-family-base, inherit);
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.dialog-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.dialog-content {
    padding: 20px;
}

.dialog-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    text-align: right;
}

/* Django messages (notifications to user) */
.messages-container {
    position: fixed;
    top: 80px;
    right: 20px;
    z-index: 1001;
    width: 300px;
}

.alert {
    padding: 12px 16px;
    margin-bottom: 10px;
    border-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: opacity 0.3s;
}

.alert-success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-info {
    background-color: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.alert-warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

/* Responsiveness */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    .left-panel {
        width: 100%;
        height: 50vh;
    }
    
    .right-panel {
        height: 50vh;
    }
    
    .top-nav-container {
        padding: 0 10px;
    }
    
    .top-nav-left {
        flex-wrap: wrap;
        gap: 0;
    }
    
    .nav-link {
        padding: 12px 16px;
        font-size: 13px;
    }
    
    @media (max-width: 480px) {
        .top-nav-left {
            flex-direction: column;
            align-items: stretch;
        }
        
        .nav-link {
            padding: 12px 20px;
            border-bottom: 1px solid var(--border-color);
            border-radius: 0;
        }
        
        .nav-link:last-child {
            border-bottom: none;
        }
    }
}