/* ==========================================================================
   Ferry Route Connection Boxes - Integrated with Global Design System
   ========================================================================== */

/* Route Box Container */
.route-box {
    background: var(--bs-white, #ffffff);
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: var(--bs-border-radius-lg, 0.5rem);
    margin-bottom: var(--space-sm, 1rem);
    overflow: hidden;
    transition: all var(--transition-base, 0.2s ease-in-out);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.route-box:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-1px);
    border-color: var(--bs-gray-300);
}

/* Route Header */
.route-header {
    padding: var(--space-sm, 1rem) var(--space-md, 1.5rem);
    background: linear-gradient(135deg, var(--bs-gray-100, #f8f9fa) 0%, var(--bs-white, #ffffff) 100%);
    border-bottom: 1px solid var(--bs-border-color, #dee2e6);
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: var(--space-xs, 0.5rem);
}

.route-title {
    font-family: var(--font-heading, 'Inter', sans-serif);
    font-size: var(--fs-body, 1rem);
    font-weight: var(--fw-semibold, 600);
    color: var(--bs-primary, #34509c);
    letter-spacing: var(--ls-heading, -0.02em);
    margin: 0;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.provider-badge {
    font-family: var(--font-body, 'Open Sans', sans-serif);
    font-size: var(--fs-small, 0.875rem);
    font-weight: var(--fw-medium, 500);
    color: var(--bs-secondary-color, #6c757d);
    background: var(--bs-primary-subtle, #eceef6);
    padding: 0.25rem 0.75rem;
    border-radius: 50rem;
    white-space: nowrap;
    border: 1px solid rgba(52, 80, 156, 0.1);
}

/* Connection Grid */
.connection-grid {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr) auto;
    gap: var(--space-md, 1.5rem);
    padding: var(--space-sm, 1rem) var(--space-md, 1.5rem);
    align-items: center;
    border-bottom: 1px solid var(--bs-gray-100, #f8f9fa);
    transition: background-color var(--transition-base);
}

.connection-grid:last-child {
    border-bottom: none;
}

.connection-grid:hover {
    background-color: var(--bs-gray-100, #f8f9fa);
}

/* Logo Cell */
.logo-cell {
    width: 120px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo-cell img {
    max-width: 100%;
    max-height: 32px;
    height: auto;
    width: auto;
    object-fit: contain;
    filter: grayscale(20%);
    transition: filter var(--transition-base);
}

.connection-grid:hover .logo-cell img {
    filter: grayscale(0%);
}

/* Info Cell */
.info-cell {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md, 1.5rem);
    align-items: center;
    min-width: 0;
}

.info-item {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs, 0.5rem);
    font-family: var(--font-body, 'Open Sans', sans-serif);
    font-size: var(--fs-small, 0.875rem);
    font-weight: var(--fw-normal, 400);
    color: var(--bs-body-color, #495057);
    white-space: nowrap;
}

.info-item i,
.info-item .bi {
    font-size: 1rem;
    color: var(--bs-primary, #34509c);
    opacity: 0.7;
    flex-shrink: 0;
}

/* Action Cell - Using existing button styles */
.action-cell {
    display: flex;
    align-items: center;
}

.btn-book {
    font-family: var(--font-body, 'Open Sans', sans-serif);
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs, 0.5rem);
    padding: 0.5rem 1.25rem;
    font-size: var(--fs-small, 0.875rem);
    font-weight: var(--fw-medium, 500);
    color: #fff;
    background: linear-gradient(135deg, var(--bs-primary, #34509c) 0%, #2c447f 100%);
    border: 2px solid var(--bs-primary, #34509c);
    border-radius: 50rem;
    text-decoration: none;
    white-space: nowrap;
    transition: all var(--transition-base);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(52, 80, 156, 0.15);
}

.btn-book:hover {
    background: linear-gradient(135deg, #2c447f 0%, #243967 100%);
    border-color: #284073;
    color: #fff;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(52, 80, 156, 0.25);
    text-decoration: none;
}

.btn-book:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(52, 80, 156, 0.2);
}

.btn-book i,
.btn-book .bi {
    font-size: 0.875rem;
}

.btn-book:disabled,
.btn-book.disabled {
    color: var(--bs-gray-500, #adb5bd);
    background: var(--bs-gray-200, #e9ecef);
    border-color: var(--bs-gray-300, #dee2e6);
    cursor: not-allowed;
    opacity: 0.65;
    box-shadow: none;
}

.btn-book:disabled:hover,
.btn-book.disabled:hover {
    transform: none;
    background: var(--bs-gray-200, #e9ecef);
    border-color: var(--bs-gray-300, #dee2e6);
    color: var(--bs-gray-500, #adb5bd);
}

/* Compact Variant */
.route-box.compact {
    margin-bottom: var(--space-xs, 0.5rem);
    box-shadow: none;
}

.route-box.compact:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.route-box.compact .route-header {
    padding: 0.625rem 1rem;
    background: transparent;
    border-bottom: 1px solid var(--bs-gray-200, #e9ecef);
}

.route-box.compact .route-title {
    font-size: 0.9375rem;
}

.route-box.compact .provider-badge {
    font-size: 0.75rem;
    padding: 0.125rem 0.5rem;
}

.route-box.compact .connection-grid {
    padding: 0.75rem 1rem;
    gap: 1rem;
}

.route-box.compact .logo-cell {
    width: 100px;
    height: 24px;
}

.route-box.compact .logo-cell img {
    max-height: 24px;
}

.route-box.compact .info-item {
    font-size: 0.8125rem;
}

.route-box.compact .btn-book {
    padding: 0.375rem 1rem;
    font-size: 0.8125rem;
}

/* Mobile Layout */
@media (max-width: 767px) {
    .route-box {
        margin-bottom: var(--space-sm, 1rem);
        border-radius: 0.375rem;
    }

    .route-header {
        padding: 0.875rem 1rem;
    }

    .route-title {
        font-size: 0.9375rem;
    }

    .provider-badge {
        font-size: 0.75rem;
        padding: 0.125rem 0.5rem;
    }

    .connection-grid {
        grid-template-columns: 1fr;
        gap: 0.875rem;
        padding: 1rem;
    }

    .logo-cell {
        width: auto;
        justify-content: flex-start;
        height: 28px;
    }

    .logo-cell img {
        max-height: 28px;
    }

    .info-cell {
        gap: 0.875rem;
    }

    .info-item {
        font-size: 0.8125rem;
    }

    .action-cell {
        width: 100%;
    }

    .btn-book {
        width: 100%;
        justify-content: center;
        padding: 0.625rem 1.25rem;
        font-size: 0.9375rem;
        border-radius: 0.375rem;
    }

    /* Compact variant on mobile */
    .route-box.compact {
        margin-bottom: 0.75rem;
    }

    .route-box.compact .connection-grid {
        padding: 0.875rem;
    }

    .route-box.compact .btn-book {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
    }
}

/* Tablet Layout */
@media (min-width: 768px) and (max-width: 991px) {
    .connection-grid {
        grid-template-columns: 110px minmax(0, 1fr) auto;
        gap: 1.25rem;
    }

    .logo-cell {
        width: 110px;
    }
}

/* Integration with Hero Section */
.hero-section + section .route-box:first-of-type {
    margin-top: var(--space-lg, 2rem);
}

/* Dark Mode Support (if needed) */
@media (prefers-color-scheme: dark) {
    .route-box {
        background: #1a1a1a;
        border-color: #2d2d2d;
    }

    .route-box:hover {
        border-color: #3a3a3a;
    }

    .route-header {
        background: linear-gradient(135deg, #1f1f1f 0%, #1a1a1a 100%);
        border-bottom-color: #2d2d2d;
    }

    .route-title {
        color: #fff;
    }

    .provider-badge {
        background: rgba(52, 80, 156, 0.2);
        color: #a8b2d1;
        border-color: rgba(52, 80, 156, 0.3);
    }

    .connection-grid {
        border-bottom-color: #252525;
    }

    .connection-grid:hover {
        background-color: #1f1f1f;
    }

    .info-item {
        color: #a8b2d1;
    }

    .logo-cell img {
        filter: brightness(0.9) grayscale(20%);
    }

    .connection-grid:hover .logo-cell img {
        filter: brightness(1) grayscale(0%);
    }
}

/* Print Styles */
@media print {
    .route-box {
        break-inside: avoid;
        box-shadow: none;
        border: 1px solid #ddd;
    }

    .route-box:hover {
        transform: none;
    }

    .btn-book {
        background: white !important;
        color: var(--bs-primary) !important;
        border: 1px solid var(--bs-primary) !important;
    }
}

/* Accessibility */
.route-box:focus-within {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

.btn-book:focus-visible {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

/* Loading State */
.route-box.loading {
    position: relative;
    opacity: 0.6;
    pointer-events: none;
}

.route-box.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 2rem;
    height: 2rem;
    border: 2px solid var(--bs-primary);
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Animation for entry */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.route-box {
    animation: fadeInUp 0.4s ease-out;
}

.route-box:nth-child(n+2) {
    animation-delay: 0.1s;
}

.route-box:nth-child(n+3) {
    animation-delay: 0.2s;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .route-box,
    .btn-book,
    .connection-grid,
    .logo-cell img {
        transition: none;
    }
    
    .route-box {
        animation: none;
    }
    
    .route-box:hover,
    .btn-book:hover {
        transform: none;
    }
}