/**
 * RouteMe Custom Styles
 * Improved UX Design
 */

/* Language Switcher */
.language-switcher {
    display: flex;
    gap: 0.25rem;
    background: white;
    padding: 0.25rem;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.lang-btn {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: #6b7280;
    background: transparent;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    transition: all 0.2s;
}

.lang-btn:hover {
    background: #f3f4f6;
    color: #374151;
}

.lang-btn.active {
    background: #2563eb;
    color: white;
}

/* Address Cards */
.address-card {
    background: white;
    border-radius: 0.75rem;
    padding: 1.25rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    transition: box-shadow 0.2s;
}

.address-card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06);
}

@media (min-width: 640px) {
    .address-card {
        padding: 1.5rem;
    }
}

/* Location Icons */
.location-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: 0.5rem;
    flex-shrink: 0;
}

.start-icon {
    background: #d1fae5;
    color: #059669;
}

.stop-icon {
    background: #fef3c7;
    color: #d97706;
}

.destination-icon {
    background: #fee2e2;
    color: #dc2626;
}

/* Address Input */
.address-input {
    width: 100%;
    padding: 0.875rem 1rem;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    font-size: 0.9375rem;
    outline: none;
    transition: all 0.2s;
    background: #fafafa;
}

.address-input:focus {
    border-color: #2563eb;
    background: white;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.address-input::placeholder {
    color: #9ca3af;
}

@media (min-width: 640px) {
    .address-input {
        font-size: 1rem;
    }
}

/* Add Stop Button */
.add-stop-btn {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #2563eb;
    background: #eff6ff;
    border: none;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.add-stop-btn:hover {
    background: #dbeafe;
    color: #1d4ed8;
}

.add-stop-btn:active {
    transform: scale(0.97);
}

/* Primary Button */
.btn-primary {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px rgba(37, 99, 235, 0.3);
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    box-shadow: 0 6px 8px rgba(37, 99, 235, 0.4);
    transform: translateY(-1px);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    background: #e5e7eb;
    box-shadow: none;
    cursor: not-allowed;
    opacity: 0.6;
}

@media (min-width: 640px) {
    .btn-primary {
        font-size: 1.125rem;
    }
}

/* Secondary Button */
.btn-secondary {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.875rem 1.5rem;
    font-size: 0.9375rem;
    font-weight: 600;
    color: #374151;
    background: white;
    border: 2px solid #d1d5db;
    border-radius: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover:not(:disabled) {
    background: #f9fafb;
    border-color: #9ca3af;
}

.btn-secondary:active:not(:disabled) {
    transform: scale(0.98);
}

.btn-secondary:disabled {
    background: #f3f4f6;
    border-color: #e5e7eb;
    color: #9ca3af;
    cursor: not-allowed;
}

/* Autocomplete Dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 50;
    margin-top: 0.5rem;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    max-height: 320px;
    overflow-y: auto;
}

.autocomplete-item {
    padding: 0.875rem 1rem;
    cursor: pointer;
    transition: background-color 0.15s ease;
    border-bottom: 1px solid #f3f4f6;
}

.autocomplete-item:first-child {
    border-radius: 0.75rem 0.75rem 0 0;
}

.autocomplete-item:last-child {
    border-bottom: none;
    border-radius: 0 0 0.75rem 0.75rem;
}

.autocomplete-item:hover,
.autocomplete-item-active {
    background-color: #eff6ff;
}

.autocomplete-item:active {
    background-color: #dbeafe;
}

.autocomplete-item-main {
    font-size: 0.9375rem;
    font-weight: 600;
    color: #111827;
    line-height: 1.4;
    margin-bottom: 0.25rem;
}

.autocomplete-item-detail {
    font-size: 0.8125rem;
    color: #6b7280;
    line-height: 1.3;
}

.autocomplete-item-empty {
    padding: 1rem;
    color: #9ca3af;
    font-style: italic;
    font-size: 0.875rem;
    text-align: center;
}

.autocomplete-section-header {
    padding: 0.625rem 1rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    background: #f9fafb;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.autocomplete-section-header:first-child {
    border-radius: 0.75rem 0.75rem 0 0;
}

.autocomplete-clear-btn {
    font-size: 0.75rem;
    font-weight: 600;
    color: #2563eb;
    background: none;
    border: none;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    border-radius: 0.25rem;
    transition: all 0.15s;
}

.autocomplete-clear-btn:hover {
    background: #eff6ff;
    color: #1d4ed8;
}

.autocomplete-item-recent {
    position: relative;
}

.autocomplete-item-recent::before {
    content: '🕐';
    margin-right: 0.5rem;
    font-size: 0.875rem;
}

/* Touch-friendly tap targets */
@media (max-width: 640px) {
    .autocomplete-item {
        padding: 1rem;
    }

    .autocomplete-item-main {
        font-size: 1rem;
    }

    .autocomplete-item-detail {
        font-size: 0.875rem;
    }
}

/* Drag Handle */
.drag-handle {
    -webkit-tap-highlight-color: transparent;
    touch-action: none;
}

.drag-handle:active {
    opacity: 0.6;
}

/* Sortable Animations */
.sortable-ghost {
    opacity: 0.5;
    background: #dbeafe;
    border-radius: 0.5rem;
}

.sortable-drag {
    opacity: 1;
}

.stop-item {
    transition: transform 0.2s ease;
    background: #fafafa;
    padding: 0.75rem;
    border-radius: 0.5rem;
}

.stop-item:hover {
    background: #f3f4f6;
}

/* Smooth animations for adding/removing stops */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.stop-item {
    animation: slideIn 0.3s ease;
}

/* Button active states for better mobile feedback */
button:active:not(:disabled) {
    transform: scale(0.98);
}

/* Focus styles for accessibility */
input:focus,
button:focus {
    outline: 2px solid transparent;
    outline-offset: 2px;
}

/* Custom scrollbar for autocomplete dropdown */
.autocomplete-dropdown::-webkit-scrollbar {
    width: 8px;
}

.autocomplete-dropdown::-webkit-scrollbar-track {
    background: #f3f4f6;
    border-radius: 0 0.75rem 0.75rem 0;
}

.autocomplete-dropdown::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 4px;
}

.autocomplete-dropdown::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Loading state animation */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.loading {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* Touch target size enforcement for mobile */
@media (max-width: 640px) {
    .drag-handle,
    .remove-stop {
        min-width: 44px;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Prevent text selection during drag */
.sortable-ghost * {
    user-select: none;
    -webkit-user-select: none;
}

/* Mobile Safari input zoom fix */
@media screen and (max-width: 640px) {
    input[type="text"] {
        font-size: 16px !important;
    }
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .stop-item,
    .sortable-ghost,
    .autocomplete-item,
    button,
    .address-card {
        animation: none !important;
        transition: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .autocomplete-dropdown {
        border: 2px solid #000;
    }

    .autocomplete-item-active {
        background-color: #0066cc;
        color: white;
    }

    .btn-primary {
        border: 2px solid #000;
    }
}
