/**
 * Tokyo/Osaka Trip - Architecture Enhancement Styles
 * Adds all missing standard features styling
 */

/* ============================================================================
   1. SKIP LINK (Accessibility)
   ============================================================================ */

.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--primary-blue);
    color: white;
    padding: 8px 16px;
    text-decoration: none;
    z-index: 10000;
    border-radius: 0 0 4px 0;
    font-weight: 600;
    transition: top 0.2s;
}

.skip-link:focus {
    top: 0;
    outline: 2px solid white;
    outline-offset: 2px;
}

/* ============================================================================
   2. FOCUS VISIBLE STATES (WCAG 2.1 AA)
   ============================================================================ */

/* Enhanced focus styles for all interactive elements */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:not([tabindex="-1"]):focus-visible {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
    border-radius: 4px;
}

.day-tab:focus-visible {
    outline: 2px solid var(--primary-blue);
    outline-offset: 2px;
}

.menu-nav a:focus-visible {
    outline: 2px solid var(--primary-blue);
    outline-offset: -2px;
}

/* Remove default outline (we're using focus-visible) */
*:focus:not(:focus-visible) {
    outline: none;
}

/* ============================================================================
   3. TOAST NOTIFICATIONS
   ============================================================================ */

#toast-container {
    position: fixed;
    top: 80px;
    right: 16px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-width: 400px;
}

@media (max-width: 640px) {
    #toast-container {
        right: 8px;
        left: 8px;
        max-width: none;
        top: 70px;
    }
}

.toast {
    background: white;
    border-radius: 8px;
    padding: 12px 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    min-height: 48px;
    border-left: 4px solid var(--gray-400);
    transform: translateX(120%);
    transition: transform 0.3s ease-out;
    opacity: 0;
}

.toast-visible {
    transform: translateX(0);
    opacity: 1;
}

.toast-icon {
    font-size: 20px;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.toast-message {
    flex: 1;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-primary);
}

.toast-close {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    flex-shrink: 0;
    transition: background 0.2s;
}

.toast-close:hover {
    background: var(--gray-100);
    color: var(--text-primary);
}

/* Toast types */
.toast-success {
    border-left-color: #10b981;
}

.toast-success .toast-icon {
    background: #d1fae5;
    color: #10b981;
}

.toast-error {
    border-left-color: #ef4444;
}

.toast-error .toast-icon {
    background: #fee2e2;
    color: #ef4444;
}

.toast-warning {
    border-left-color: #f59e0b;
}

.toast-warning .toast-icon {
    background: #fef3c7;
    color: #f59e0b;
}

.toast-info {
    border-left-color: #3b82f6;
}

.toast-info .toast-icon {
    background: #dbeafe;
    color: #3b82f6;
}

/* ============================================================================
   4. LOADING STATES & SKELETONS
   ============================================================================ */

/* Loading overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(2px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
}

.loading-spinner {
    text-align: center;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--gray-200);
    border-top-color: var(--primary-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

.loading-text {
    font-size: 16px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Button loading state */
.btn-loading {
    position: relative;
    color: transparent !important;
}

.btn-spinner {
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

/* Skeleton screens */
@keyframes shimmer {
    0% {
        background-position: -468px 0;
    }
    100% {
        background-position: 468px 0;
    }
}

.skeleton-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 16px;
    border: 1px solid var(--border-light);
}

.skeleton-header {
    width: 60%;
    height: 24px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 468px 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 12px;
}

.skeleton-text {
    height: 16px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 468px 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 8px;
}

.skeleton-title {
    width: 80%;
    height: 20px;
    margin-bottom: 12px;
}

.skeleton-line {
    width: 100%;
}

.skeleton-line.short {
    width: 60%;
}

.skeleton-footer {
    width: 40%;
    height: 36px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 468px 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 8px;
    margin-top: 16px;
}

/* ============================================================================
   5. SEARCH & FILTER BAR
   ============================================================================ */

.search-filter-bar {
    background: white;
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}

.search-box {
    position: relative;
    margin-bottom: 12px;
}

.search-input {
    width: 100%;
    padding: 12px 40px 12px 12px;
    border: 2px solid var(--border-medium);
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.2s;
    background: white;
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.search-clear {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--gray-200);
    border: none;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    font-size: 20px;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.search-clear:hover {
    background: var(--gray-300);
    color: var(--text-primary);
}

.filter-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.filter-select {
    flex: 1;
    min-width: 140px;
    padding: 10px 12px;
    border: 2px solid var(--border-medium);
    border-radius: 8px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-blue);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.filter-select:hover {
    border-color: var(--primary-blue);
}

/* ============================================================================
   6. EMPTY STATE
   ============================================================================ */

.empty-state {
    text-align: center;
    padding: 64px 24px;
}

.empty-state-content {
    max-width: 400px;
    margin: 0 auto;
}

.empty-state-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state h3 {
    font-size: 24px;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

/* ============================================================================
   7. TOUCH TARGET IMPROVEMENTS (Mobile)
   ============================================================================ */

@media (max-width: 768px) {
    /* Ensure all interactive elements meet 44×44px minimum */
    button,
    a,
    .day-tab,
    .menu-nav a {
        min-height: 44px;
        min-width: 44px;
    }
    
    .hamburger-btn {
        min-width: 48px;
        min-height: 48px;
    }
}

/* ============================================================================
   8. REDUCED MOTION SUPPORT (Accessibility)
   ============================================================================ */

@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;
    }
    
    .skeleton-text,
    .skeleton-header,
    .skeleton-footer {
        animation: none;
        background: #f0f0f0;
    }
}

/* ============================================================================
   9. HIGH CONTRAST MODE SUPPORT
   ============================================================================ */

@media (prefers-contrast: high) {
    :root {
        --border-light: #000;
        --border-medium: #000;
    }
    
    button,
    .btn {
        border: 2px solid currentColor;
    }
    
    .day-tab {
        border-width: 3px;
    }
}

/* ============================================================================
   10. RESPONSIVE IMPROVEMENTS
   ============================================================================ */

/* Tablet optimization (768-1023px) */
@media (min-width: 768px) and (max-width: 1023px) {
    .search-filter-bar {
        padding: 20px;
    }
    
    .filter-controls {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 12px;
    }
    
    .day-tabs {
        gap: 12px;
    }
}

/* Extra large desktop (1536px+) - max-width container */
@media (min-width: 1536px) {
    .desktop-layout,
    .content-section,
    .search-filter-bar {
        max-width: 1440px;
        margin-left: auto;
        margin-right: auto;
    }
}

/* ============================================================================
   11. ENHANCED ARIA LIVE REGION
   ============================================================================ */

[aria-live] {
    position: relative;
}

[aria-busy="true"] {
    opacity: 0.7;
    pointer-events: none;
}

/* ============================================================================
   12. PRINT STYLES (Bonus)
   ============================================================================ */

@media print {
    .skip-link,
    .hamburger-btn,
    .hamburger-menu,
    .menu-overlay,
    #toast-container,
    #loading-overlay,
    .search-filter-bar,
    .btn,
    .get-directions-btn {
        display: none !important;
    }
    
    .timeline-day {
        page-break-inside: avoid;
    }
    
    body {
        background: white;
    }
}
