/* Custom styles for Paper Route Manager */

:root {
    --route-indicator-size: 12px;
    --fab-size: 56px;
    --shadow-elevation-1: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.24);
    --shadow-elevation-2: 0 3px 6px rgba(0,0,0,0.16), 0 3px 6px rgba(0,0,0,0.23);
    --shadow-elevation-3: 0 10px 20px rgba(0,0,0,0.19), 0 6px 6px rgba(0,0,0,0.23);
}

/* Route color indicators */
.route-color-indicator {
    display: inline-block;
    width: var(--route-indicator-size);
    height: var(--route-indicator-size);
    border-radius: 50%;
    margin-right: 0.5rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
    vertical-align: middle;
}

/* Statistics styling */
.stat {
    padding: 0.5rem;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--bs-primary);
    line-height: 1;
    margin: 0.25rem 0;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--bs-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 500;
}

/* Route cards */
.route-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    border: none;
    box-shadow: var(--shadow-elevation-1);
}

.route-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-elevation-2);
}

.route-card .card-header {
    background: var(--bs-body-bg);
    border-bottom: 1px solid var(--bs-border-color);
    padding: 1rem;
}

.route-card .card-footer {
    padding: 0.75rem 1rem;
}

/* Address table styling */
.address-row {
    transition: background-color 0.15s ease;
}

.address-row:hover {
    background-color: var(--bs-secondary-bg);
}

.address-info {
    line-height: 1.4;
}

.address-info strong {
    color: var(--bs-body-color);
}

/* Mobile Floating Action Button */
.fab-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.fab {
    width: var(--fab-size);
    height: var(--fab-size);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-elevation-3);
    border: none;
    font-size: 1.25rem;
    text-decoration: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.fab:hover {
    transform: scale(1.1);
    box-shadow: var(--shadow-elevation-3);
}

.fab:focus {
    outline: none;
    box-shadow: var(--shadow-elevation-3), 0 0 0 3px rgba(13, 110, 253, 0.25);
}

/* Feather icon sizing */
.feather-xs {
    width: 14px;
    height: 14px;
}

.feather-sm {
    width: 16px;
    height: 16px;
}

.feather-lg {
    width: 48px;
    height: 48px;
}

/* Form enhancements */
.form-control:focus {
    border-color: var(--bs-primary);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
}

.form-control-color {
    width: 60px;
    height: 38px;
    padding: 0.25rem;
}

/* Alert styling */
.alert {
    border: none;
    border-radius: 0.5rem;
}

.alert .feather-sm {
    vertical-align: middle;
}

/* Print-specific styles */
@media print {
    .no-print {
        display: none !important;
    }
    
    .fab-container {
        display: none !important;
    }
    
    .card {
        break-inside: avoid;
        margin-bottom: 1rem;
    }
    
    .table {
        font-size: 0.875rem;
    }
    
    .route-color-indicator {
        border: 1px solid #000 !important;
    }
}

/* Viewport rotation fix */
html {
    height: 100%;
    overflow-x: hidden;
}

body {
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Fix for viewport rotation issues */
@supports (-webkit-touch-callout: none) {
    body {
        height: -webkit-fill-available;
        min-height: -webkit-fill-available;
    }
}

/* Container responsiveness fix */
.container,
.container-fluid {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    /* Force recalculation on orientation change */
    * {
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
    
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
        width: 100%;
        max-width: 100%;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .stat-value {
        font-size: 1.25rem;
    }
    
    .btn-group {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }
    
    .btn-group .btn {
        width: 100%;
    }
    
    /* Make tables more mobile-friendly */
    .table-responsive {
        font-size: 0.875rem;
        width: 100%;
        overflow-x: auto;
    }
    
    .address-info {
        font-size: 0.875rem;
    }
    
    /* Adjust form layouts for mobile */
    .row.g-3 > .col-md-6,
    .row.g-3 > .col-md-3 {
        margin-bottom: 1rem;
    }
    
    /* Fix for cards and rows */
    .row {
        width: 100%;
        margin-left: 0;
        margin-right: 0;
    }
    
    .col,
    [class*="col-"] {
        width: 100%;
        max-width: 100%;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .route-color-indicator {
        border-width: 3px;
    }
    
    .card {
        border-width: 2px;
    }
    
    .btn {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .route-card,
    .fab,
    .address-row {
        transition: none;
    }
    
    .fab:hover {
        transform: none;
    }
    
    .route-card:hover {
        transform: none;
    }
}

/* Dark mode adjustments */
[data-bs-theme="dark"] {
    .route-card {
        background: var(--bs-body-bg);
    }
    
    .stat-value {
        color: var(--bs-info);
    }
    
    .address-row:hover {
        background-color: rgba(255, 255, 255, 0.05);
    }
}

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

.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--bs-primary);
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

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

/* Badge improvements */
.badge {
    font-weight: 500;
    font-size: 0.75rem;
}

/* Card footer improvements */
.card-footer.bg-transparent {
    background-color: var(--bs-secondary-bg) !important;
    border-top: 1px solid var(--bs-border-color);
}

/* Navigation improvements */
.navbar-brand {
    font-weight: 600;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Utility classes */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
}

.border-start-primary {
    border-left: 3px solid var(--bs-primary) !important;
}

.bg-gradient-primary {
    background: linear-gradient(135deg, var(--bs-primary) 0%, var(--bs-primary-dark) 100%);
}

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

/* Focus indicators */
.btn:focus,
.form-control:focus,
.form-select:focus {
    outline: 2px solid var(--bs-primary);
    outline-offset: 2px;
}

/* Skip to content link */
.skip-link {
    position: absolute;
    top: -40px;
    left: 6px;
    background: var(--bs-primary);
    color: white;
    padding: 8px;
    text-decoration: none;
    z-index: 1000;
}

.skip-link:focus {
    top: 6px;
}
