:root {
    --primary: #005D8A;
    --primary-dark: #00456B;
    --secondary: #FFC107;
    --secondary-dark: #E6AD00;
    --light: #F8F9FA;
    --dark: #212529;
    --gray: #6C757D;
    --light-gray: #E9ECEF;
    --white: #FFFFFF;
    --success: #28A745;
    --blue-accent: #0074D9;
    --focus-ring-color: rgba(0,93,138,0.5);
    --focus-visible-color: #0074D9;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--dark);
    background-color: var(--light);
    line-height: 1.6;
}

/* Improved Accessibility */
:focus {
    outline: 3px solid var(--focus-ring-color);
    outline-offset: 3px;
}

:focus-visible {
    outline: 3px solid var(--focus-visible-color);
    outline-offset: 3px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* Improved Header & Navigation */
.site-header {
    background-color: var(--white);
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    z-index: 1030;
}

.site-header .navbar-brand {
    font-weight: 700;
    color: var(--primary);
    font-size: 1.3rem;
    padding: 0.8rem 0;
}

.site-header .nav-link {
    color: var(--dark);
    font-weight: 600;
    padding: 0.8rem 1rem;
    margin: 0 0.2rem;
    border-radius: 6px;
    transition: all 0.25s ease;
    font-size: 1.05rem;
}

.site-header .nav-link:hover,
.site-header .nav-link:focus {
    background-color: var(--light-gray);
}

.site-header .nav-link.active {
    background-color: rgba(0,93,138,0.1);
    color: var(--primary);
}

/* Enhanced Hero Section */
.hero {
    background: linear-gradient(135deg, rgba(0,93,138,0.95) 0%, rgba(29,53,87,0.95) 100%);
    background-size: cover;
    background-position: center;
    color: var(--white);
    padding: 3.5rem 0;
    margin-bottom: 2.5rem;
    position: relative;
}

.hero-content {
    max-width: 700px;
}

.hero h1 {
    font-weight: 800;
    font-size: 2.5rem;
    margin-bottom: 1.2rem;
    line-height: 1.2;
}

.hero p {
    font-size: 1.25rem;
    margin-bottom: 2rem;
    line-height: 1.4;
}

/* Improved Quick Date Selection */
.date-selection {
    background-color: var(--white);
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
    padding: 1.75rem;
    margin-top: -3rem;
    margin-bottom: 2.5rem;
    position: relative;
    z-index: 10;
}

.date-selection h2 {
    margin-bottom: 1.25rem;
    font-weight: 600;
}

.date-selection .btn {
    padding: 0.85rem 1.25rem;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.25s ease;
    min-width: 120px;
    margin: 0.35rem;
    font-size: 1.05rem;
}

/* Enhanced Booking Box */
.booking-box {
    background-color: var(--white);
    border-radius: 10px;
    box-shadow: 0 12px 35px rgba(0,0,0,0.15);
    padding: 2.25rem;
    position: relative;
    z-index: 2;
    margin-bottom: 3rem;
}

.booking-box h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    color: var(--primary-dark);
}

.booking-box .form-label {
    font-weight: 600;
    font-size: 1rem;
    color: var(--gray);
    margin-bottom: 0.5rem;
}

.booking-box .form-control,
.booking-box .form-select {
    border: 1.5px solid var(--light-gray);
    padding: 0.85rem 1rem;
    border-radius: 8px;
    font-size: 1.05rem;
    height: auto;
}

.booking-box .form-control:focus,
.booking-box .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.25rem rgba(0,93,138,0.25);
}

.booking-box .form-text {
    margin-top: 0.45rem;
    color: var(--gray);
    font-size: 0.85rem;
}

/* Card Styles */
.card {
    border-radius: 10px;
    border: 1px solid var(--light-gray);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 24px rgba(0,0,0,0.1);
}

.card-header {
    background-color: rgba(0,93,138,0.05);
    border-bottom: 1px solid var(--light-gray);
    padding: 1rem 1.25rem;
}

.card-body {
    padding: 1.5rem;
}

/* Improved CTA Buttons */
.btn-primary {
    background-color: var(--primary);
    border-color: var(--primary);
    color: var(--white);
    padding: 0.85rem 1.5rem;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.25s ease;
    font-size: 1.05rem;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
    border-color: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.15);
}

.btn-primary:focus {
    box-shadow: 0 0 0 0.25rem rgba(0,93,138,0.25);
}

.btn-secondary {
    background-color: var(--secondary);
    border-color: var(--secondary);
    color: var(--dark);
    padding: 0.85rem 1.5rem;
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.25s ease;
    font-size: 1.05rem;
}

.btn-secondary:hover {
    background-color: var(--secondary-dark);
    border-color: var(--secondary-dark);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.15);
}

.btn-secondary:focus {
    box-shadow: 0 0 0 0.25rem rgba(255,193,7,0.25);
}

.btn-outline-primary {
    border: 2px solid var(--primary);
    color: var(--primary);
    font-weight: 600;
    border-radius: 8px;
    transition: all 0.25s ease;
    padding: 0.8rem 1.4rem;
}

.btn-outline-primary:hover {
    background-color: var(--primary);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

/* Enhanced Schedule Table */
.schedule-container {
    background-color: var(--white);
    border-radius: 10px;
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
    padding: 2rem;
    margin-bottom: 3.5rem;
}

.schedule-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.schedule-table th {
    background-color: var(--primary);
    color: var(--white);
    padding: 1.2rem 1rem;
    font-weight: 600;
    text-align: left;
    font-size: 1.05rem;
}

.schedule-table th:first-child {
    border-top-left-radius: 8px;
}

.schedule-table th:last-child {
    border-top-right-radius: 8px;
}

.schedule-table td {
    padding: 1.1rem 1rem;
    border-bottom: 1px solid var(--light-gray);
    vertical-align: middle;
    font-size: 1rem;
}

.schedule-table tr:last-child td {
    border-bottom: none;
}

.schedule-table tr:hover {
    background-color: rgba(0,93,138,0.05);
}

/* Improved Mobile View for Departures */
.mobile-departure-card {
    background-color: var(--white);
    border-radius: 10px;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    border-left: 4px solid var(--primary);
}

.mobile-departure-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--light-gray);
    padding-bottom: 0.75rem;
}

.mobile-departure-time {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-dark);
}

.mobile-departure-details {
    margin-bottom: 1rem;
}

.mobile-departure-details .detail-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
    padding: 0.5rem 0;
    font-size: 1.05rem;
}

.mobile-departure-details .detail-item:not(:last-child) {
    border-bottom: 1px dashed var(--light-gray);
}

.mobile-departure-actions {
    text-align: center;
}

.mobile-departure-actions .btn {
    padding: 0.85rem 1rem;
    font-size: 1.05rem;
    width: 100%;
}

/* Accordion Styles */
.accordion-item {
    margin-bottom: 0.75rem;
    border: 1px solid var(--light-gray);
    border-radius: 8px;
    overflow: hidden;
}

.accordion-header {
    margin: 0;
}

.accordion-button {
    padding: 1.25rem;
    font-size: 1.1rem;
    font-weight: 600;
    background-color: var(--white);
    color: var(--primary);
}

.accordion-button:not(.collapsed) {
    background-color: rgba(0,93,138,0.05);
    color: var(--primary-dark);
}

.accordion-button:focus {
    box-shadow: 0 0 0 0.25rem rgba(0,93,138,0.25);
    border-color: var(--primary);
}

.accordion-button::after {
    color: var(--primary);
}

.accordion-body {
    padding: 1.25rem;
    background-color: var(--white);
}

/* Improved Price Tags */
.price-tag {
    font-weight: 700;
    font-size: 1.15rem;
    color: var(--dark);
}

.price-tag.special {
    color: var(--success);
    font-size: 1.2rem;
}

/* Enhanced Footer */
.site-footer {
    background-color: var(--primary);
    color: var(--white);
    padding: 4.5rem 0 2.5rem;
}

.site-footer a {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    transition: color 0.2s ease;
    font-size: 1.05rem;
}

.site-footer a:hover {
    color: var(--white);
    text-decoration: underline;
}

.site-footer h5 {
    font-weight: 700;
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
}

.footer-bottom {
    border-top: 1px solid rgba(255,255,255,0.2);
    padding-top: 2rem;
    margin-top: 2.5rem;
    font-size: 0.95rem;
}

/* Back to Top Button */
.back-to-top {
    position: fixed;
    bottom: 2.5rem;
    right: 2.5rem;
    width: 3.5rem;
    height: 3.5rem;
    border-radius: 50%;
    background-color: var(--primary);
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
    box-shadow: 0 8px 20px rgba(0,0,0,0.2);
    border: none;
}

.back-to-top.show {
    opacity: 1;
    visibility: visible;
}

.back-to-top:hover,
.back-to-top:focus {
    background-color: var(--primary-dark);
    transform: translateY(-5px);
    color: var(--white);
}

/* Enhanced Highlight Box */
.highlight-box {
    background-color: rgba(0,93,138,0.08);
    border-left: 5px solid var(--primary);
    padding: 1.75rem;
    margin-bottom: 2rem;
    border-radius: 0 10px 10px 0;
    font-size: 1.05rem;
}

/* Loading Indicator */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem;
}

.spinner-border {
    width: 3.5rem;
    height: 3.5rem;
    margin-bottom: 1.5rem;
    color: var(--primary);
}

/* Accessible Skip Link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary);
    color: white;
    padding: 8px;
    z-index: 1100;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 0;
}

/* Improved Responsive Table Handling */
.schedule-table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 8px;
    /* Add more visible scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: var(--primary) var(--light-gray);
}

.schedule-table-responsive::-webkit-scrollbar {
    height: 8px;
}

.schedule-table-responsive::-webkit-scrollbar-track {
    background: var(--light-gray);
    border-radius: 4px;
}

.schedule-table-responsive::-webkit-scrollbar-thumb {
    background-color: var(--primary);
    border-radius: 4px;
}

/* Tablet View Table Adjustments */
.tablet-schedule-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.tablet-schedule-table th {
    background-color: var(--primary);
    color: var(--white);
    padding: 1rem;
    font-weight: 600;
    text-align: left;
    font-size: 1rem;
}

.tablet-schedule-table th:first-child {
    border-top-left-radius: 8px;
}

.tablet-schedule-table th:last-child {
    border-top-right-radius: 8px;
}

.tablet-schedule-table td {
    padding: 1rem;
    border-bottom: 1px solid var(--light-gray);
    vertical-align: middle;
}

.tablet-schedule-table tr:last-child td {
    border-bottom: none;
}

.tablet-schedule-table tr:hover {
    background-color: rgba(0,93,138,0.05);
}

/* Updated Media Queries for better responsive behavior */
/* Desktop view (large screens) */
@media (min-width: 1200px) {
    .desktop-table {
        display: block;
    }
    .tablet-view,
    .mobile-view {
        display: none;
    }
}

/* Tablet view (medium screens) */
@media (min-width: 768px) and (max-width: 1199px) {
    .desktop-table {
        display: none;
    }
    .tablet-view {
        display: block;
    }
    .mobile-view {
        display: none;
    }
}

/* Mobile view (small screens) */
@media (max-width: 767px) {
    .desktop-table,
    .tablet-view {
        display: none;
    }
    .mobile-view {
        display: block;
    }
}

/* Additional responsive adjustments */
@media (max-width: 992px) {
    .hero h1 {
        font-size: 2.2rem;
    }
    
    .booking-box {
        padding: 2rem;
    }
}

@media (max-width: 768px) {
    .hero {
        padding: 3rem 0;
    }
    
    .hero h1 {
        font-size: 1.9rem;
    }
    
    .hero p {
        font-size: 1.1rem;
    }
    
    .site-header .nav-link {
        padding: 1rem;
        margin: 0.2rem 0;
    }
    
    .date-selection {
        padding: 1.5rem;
    }
    
    .date-selection .btn {
        width: calc(50% - 0.7rem);
        margin: 0.35rem;
        padding: 0.8rem 0.5rem;
        font-size: 0.95rem;
        min-width: auto;
    }
}

@media (max-width: 576px) {
    .hero {
        padding: 2.5rem 0;
    }
    
    .hero h1 {
        font-size: 1.8rem;
    }
    
    .hero p {
        font-size: 1rem;
    }
    
    .booking-box {
        padding: 1.5rem;
    }
    
    .date-selection {
        padding: 1.25rem;
        margin-left: 0.5rem;
        margin-right: 0.5rem;
    }
    
    /* Make buttons more touch-friendly on small screens */
    .btn-primary, 
    .btn-secondary,
    .btn-outline-primary {
        width: 100%;
        margin-bottom: 0.75rem;
        padding: 1rem;
        font-size: 1.1rem;
    }
    
    .back-to-top {
        width: 3rem;
        height: 3rem;
        bottom: 1.5rem;
        right: 1.5rem;
    }
}
/* Swedish-specific styles and enhancements */

/* External loading overlay */
.external-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.95);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

.external-loading p {
    margin-top: 1rem;
    font-size: 1.1rem;
    color: var(--primary);
}

/* Loading state for body */
body.loading-external {
    overflow: hidden;
}

/* Notification styles */
.notification {
    position: fixed;
    top: 80px;
    right: 20px;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    background-color: var(--white);
    border-left: 4px solid;
    z-index: 1050;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    max-width: 300px;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification-success {
    border-left-color: var(--success);
    color: var(--success);
}

.notification-warning {
    border-left-color: var(--secondary);
    color: var(--secondary-dark);
}

.notification-info {
    border-left-color: var(--primary);
    color: var(--primary);
}

/* Offline mode styles */
body.offline .requires-online {
    opacity: 0.5;
    pointer-events: none;
}

body.offline::before {
    content: "Offline-läge";
    position: fixed;
    top: 70px;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--secondary);
    color: var(--dark);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    z-index: 1040;
}

/* Input focus enhancement */
.input-focused .form-label {
    color: var(--primary);
    font-weight: 600;
}

/* Performance-based optimizations */
body.fast-connection img {
    loading: eager;
}

body.slow-connection img {
    loading: lazy;
}

body.slow-connection .hero {
    background-image: none !important;
}

/* Navbar animation enhancement */
.navbar-collapse.showing {
    animation: slideDown 0.35s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Swedish flag accent (optional) */
.site-header::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #006AA7 40%, #FECC00 40%, #FECC00 60%, #006AA7 60%);
    opacity: 0.8;
}

/* Improve readability for Swedish text */
body[lang="sv"] {
    letter-spacing: 0.01em;
}

/* Swedish-specific mobile adjustments */
@media (max-width: 768px) {
    body[lang="sv"] .hero h1 {
        font-size: 1.75rem;
        line-height: 1.3;
    }
    
    body[lang="sv"] .btn {
        font-size: 0.95rem;
    }
    
    .notification {
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

/* Print styles */
@media print {
    .site-header,
    .site-footer,
    .back-to-top,
    .external-loading,
    .notification {
        display: none !important;
    }
    
    .hero {
        background: none !important;
        color: var(--dark) !important;
        padding: 1rem 0 !important;
    }
    
    .btn {
        border: 1px solid var(--dark) !important;
        color: var(--dark) !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn-primary {
        border: 2px solid var(--white);
    }
    
    .card {
        border: 2px solid var(--dark);
    }
    
    .notification {
        border: 2px solid;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .notification {
        transition: none;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    /* Add dark mode styles if needed */
}