/**
 * BHS Logistics - Tracking Widget Styles
 *
 * Injected into all static HTML pages for header tracking search.
 * Designed to blend seamlessly with existing Elementor/Astra styling.
 */

/* Widget Container - Fixed position in header area */
.bhs-tracking-widget {
    position: fixed;
    top: 10px;
    right: 20px;
    z-index: 99999;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Search Form */
.bhs-tracking-widget .bhs-track-form {
    display: flex;
    align-items: center;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 25px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    overflow: hidden;
    transition: all 0.3s ease;
    max-width: 280px;
}

.bhs-tracking-widget .bhs-track-form:focus-within {
    box-shadow: 0 4px 15px rgba(217, 73, 72, 0.3);
}

.bhs-tracking-widget .bhs-track-input {
    border: none;
    padding: 10px 15px;
    font-size: 13px;
    font-family: inherit;
    width: 160px;
    outline: none;
    background: transparent;
    color: #011627;
}

.bhs-tracking-widget .bhs-track-input::placeholder {
    color: #999;
}

.bhs-tracking-widget .bhs-track-btn {
    background: #d94948;
    color: #fff;
    border: none;
    padding: 10px 18px;
    font-size: 13px;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 5px;
}

.bhs-tracking-widget .bhs-track-btn:hover {
    background: #c43c3b;
}

.bhs-tracking-widget .bhs-track-btn i {
    font-size: 12px;
}

/* Collapsed state for mobile */
.bhs-tracking-widget.collapsed .bhs-track-form {
    width: auto;
}

.bhs-tracking-widget.collapsed .bhs-track-input {
    width: 0;
    padding: 10px 0;
    opacity: 0;
}

.bhs-tracking-widget.collapsed .bhs-track-btn {
    border-radius: 25px;
}

/* Toggle button for collapsed state */
.bhs-tracking-widget .bhs-track-toggle {
    display: none;
    background: #d94948;
    color: #fff;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    transition: all 0.3s;
}

.bhs-tracking-widget .bhs-track-toggle:hover {
    background: #c43c3b;
    transform: scale(1.05);
}

.bhs-tracking-widget .bhs-track-toggle i {
    font-size: 16px;
}

/* Expanded state when toggle is clicked */
.bhs-tracking-widget.expanded .bhs-track-form {
    display: flex;
}

.bhs-tracking-widget.expanded .bhs-track-toggle {
    display: none;
}

/* Responsive adjustments */
@media (max-width: 921px) {
    .bhs-tracking-widget {
        top: auto;
        bottom: 20px;
        right: 20px;
    }

    .bhs-tracking-widget .bhs-track-form {
        display: none;
    }

    .bhs-tracking-widget .bhs-track-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .bhs-tracking-widget.expanded .bhs-track-form {
        position: fixed;
        bottom: 70px;
        right: 20px;
        display: flex;
        flex-direction: column;
        max-width: calc(100vw - 40px);
        border-radius: 10px;
    }

    .bhs-tracking-widget.expanded .bhs-track-input {
        width: 100%;
        padding: 12px 15px;
    }

    .bhs-tracking-widget.expanded .bhs-track-btn {
        width: 100%;
        justify-content: center;
        padding: 12px;
        border-radius: 0 0 10px 10px;
    }

    .bhs-tracking-widget.expanded .bhs-track-toggle {
        display: flex;
        background: #011627;
    }
}

/* Hide widget on tracking page */
body[class*="tracking"] .bhs-tracking-widget,
.tracking-page .bhs-tracking-widget {
    display: none;
}

/* Adjust for transparent header */
.ast-theme-transparent-header .bhs-tracking-widget .bhs-track-form {
    background: rgba(255, 255, 255, 0.9);
}

/* Sticky header adjustment */
.admin-bar .bhs-tracking-widget {
    top: 42px;
}

@media (max-width: 782px) {
    .admin-bar .bhs-tracking-widget {
        top: auto;
    }
}

/* Dark mode support (if site uses it) */
@media (prefers-color-scheme: dark) {
    .bhs-tracking-widget .bhs-track-form {
        background: rgba(1, 22, 39, 0.95);
    }

    .bhs-tracking-widget .bhs-track-input {
        color: #fff;
    }
}

/* Animation for appearance */
@keyframes bhs-widget-appear {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bhs-tracking-widget {
    animation: bhs-widget-appear 0.3s ease-out;
}

/* Loading state */
.bhs-tracking-widget.loading .bhs-track-btn {
    pointer-events: none;
    opacity: 0.7;
}

.bhs-tracking-widget.loading .bhs-track-btn i::before {
    content: "\f110"; /* fa-spinner */
    animation: fa-spin 1s infinite linear;
}

@keyframes fa-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* =============================================================================
   RESULTS WRAPPER (for existing form takeover)
   ============================================================================= */

.bhs-results-wrapper {
    width: 100%;
    margin: 0;
    padding: 40px 0;
    background: #f9f8f8;
}

.bhs-results-wrapper .elementor-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.bhs-results-wrapper .bhs-tracking-results,
.bhs-results-wrapper .bhs-tracking-error,
.bhs-results-wrapper .bhs-tracking-loading {
    max-width: 900px;
    margin: 0 auto;
}

/* =============================================================================
   INLINE TRACKING FORM (for Track and Trace page)
   ============================================================================= */

/* Main container - matches Elementor section styling */
.bhs-inline-tracking {
    padding: 60px 0;
    background: linear-gradient(135deg, #f9f8f8 0%, #fff 100%);
}

.bhs-inline-tracking .elementor-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Tracking box */
.bhs-tracking-box {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    padding: 40px;
    text-align: center;
}

.bhs-tracking-header {
    margin-bottom: 30px;
}

.bhs-tracking-header i {
    font-size: 48px;
    color: #d94948;
    margin-bottom: 15px;
    display: block;
}

.bhs-tracking-header h2 {
    font-family: 'Montserrat', sans-serif;
    font-size: 28px;
    font-weight: 700;
    color: #011627;
    margin: 0 0 10px;
}

.bhs-tracking-header p {
    color: rgba(1, 22, 39, 0.7);
    font-size: 16px;
    margin: 0;
}

/* Form styling */
.bhs-inline-track-form {
    max-width: 600px;
    margin: 0 auto;
}

.bhs-form-group {
    display: flex;
    gap: 0;
    border: 2px solid #e0e0e0;
    border-radius: 100px;
    overflow: hidden;
    transition: border-color 0.3s, box-shadow 0.3s;
}

.bhs-form-group:focus-within {
    border-color: #d94948;
    box-shadow: 0 0 0 4px rgba(217, 73, 72, 0.15);
}

.bhs-form-input {
    flex: 1;
    border: none;
    padding: 18px 25px;
    font-size: 16px;
    font-family: 'Montserrat', sans-serif;
    outline: none;
    background: transparent;
    color: #011627;
}

.bhs-form-input::placeholder {
    color: #999;
}

.bhs-form-button {
    background: #d94948;
    color: #fff;
    border: none;
    padding: 18px 35px;
    font-size: 16px;
    font-weight: 600;
    font-family: 'Montserrat', sans-serif;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
}

.bhs-form-button:hover {
    background: #c43c3b;
}

/* Loading state */
.bhs-tracking-loading {
    padding: 40px;
    text-align: center;
}

.bhs-tracking-loading i {
    font-size: 40px;
    color: #d94948;
    margin-bottom: 15px;
    display: block;
}

.bhs-tracking-loading p {
    color: #666;
    font-size: 16px;
    margin: 0;
}

/* Error state */
.bhs-tracking-error {
    padding: 40px;
    text-align: center;
    background: #fff5f5;
    border-radius: 12px;
    margin-top: 30px;
}

.bhs-tracking-error i {
    font-size: 48px;
    color: #dc3545;
    margin-bottom: 15px;
    display: block;
}

.bhs-tracking-error p {
    color: #dc3545;
    font-size: 16px;
    margin: 0;
}

/* =============================================================================
   TRACKING RESULTS
   ============================================================================= */

.bhs-tracking-results {
    margin-top: 30px;
    text-align: left;
}

/* Result card */
.bhs-result-card {
    background: #f9f8f8;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
}

.bhs-result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid #e0e0e0;
}

.bhs-result-tracking .label {
    display: block;
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.bhs-result-tracking .value {
    font-size: 20px;
    font-weight: 700;
    color: #011627;
    font-family: 'Montserrat', sans-serif;
}

.bhs-result-status {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--status-color, #6c757d);
    color: #fff;
    padding: 10px 20px;
    border-radius: 25px;
    font-weight: 600;
    font-size: 14px;
}

.bhs-result-status i {
    font-size: 16px;
}

/* Route display */
.bhs-result-route {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.bhs-route-point {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bhs-route-point i {
    font-size: 24px;
    color: #d94948;
}

.bhs-route-point.destination i {
    color: #28a745;
}

.bhs-route-point .label {
    display: block;
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
}

.bhs-route-point .value {
    font-size: 16px;
    font-weight: 600;
    color: #011627;
}

.bhs-route-arrow {
    font-size: 24px;
    color: #ccc;
}

/* Current location */
.bhs-current-location {
    background: #e8f5e9;
    border-radius: 8px;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 20px;
}

.bhs-current-location i {
    font-size: 20px;
    color: #28a745;
}

.bhs-current-location .label {
    color: #666;
}

.bhs-current-location .value {
    font-weight: 600;
    color: #011627;
}

/* Meta info */
.bhs-result-meta {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    font-size: 14px;
    color: #666;
}

.bhs-result-meta span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.bhs-result-meta .eta {
    color: #d94948;
    font-weight: 600;
}

/* Timeline card */
.bhs-timeline-card {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    padding: 25px;
    margin-bottom: 20px;
}

.bhs-timeline-title {
    font-size: 18px;
    font-weight: 700;
    color: #011627;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.bhs-timeline-title i {
    color: #d94948;
}

/* Timeline */
.bhs-timeline {
    position: relative;
    padding-left: 30px;
}

.bhs-timeline::before {
    content: '';
    position: absolute;
    left: 12px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e0e0e0;
}

.bhs-timeline-item {
    position: relative;
    padding-bottom: 25px;
}

.bhs-timeline-item:last-child {
    padding-bottom: 0;
}

.bhs-timeline-marker {
    position: absolute;
    left: -30px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 12px;
    z-index: 1;
}

.bhs-timeline-item.latest .bhs-timeline-marker {
    width: 32px;
    height: 32px;
    left: -33px;
    font-size: 14px;
    box-shadow: 0 0 0 4px rgba(217, 73, 72, 0.2);
}

.bhs-timeline-content {
    background: #f9f8f8;
    border-radius: 8px;
    padding: 15px;
}

.bhs-timeline-item.latest .bhs-timeline-content {
    background: #fff;
    border: 2px solid #d94948;
}

.bhs-timeline-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.bhs-timeline-status {
    font-weight: 700;
    font-size: 14px;
}

.bhs-timeline-date {
    font-size: 13px;
    color: #666;
}

.bhs-timeline-location {
    font-size: 14px;
    color: #666;
    margin-bottom: 5px;
}

.bhs-timeline-location i {
    color: #d94948;
    margin-right: 5px;
}

.bhs-timeline-desc {
    font-size: 14px;
    color: #011627;
}

.bhs-no-events {
    text-align: center;
    color: #666;
    padding: 20px;
}

/* Action buttons */
.bhs-result-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.bhs-btn-secondary {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 25px;
    background: #fff;
    border: 2px solid #d94948;
    color: #d94948;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    font-family: 'Montserrat', sans-serif;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
}

.bhs-btn-secondary:hover {
    background: #d94948;
    color: #fff;
}

/* Responsive for inline tracking */
@media (max-width: 768px) {
    .bhs-tracking-box {
        padding: 25px 20px;
    }

    .bhs-tracking-header h2 {
        font-size: 22px;
    }

    .bhs-form-group {
        flex-direction: column;
        border-radius: 12px;
    }

    .bhs-form-input {
        padding: 15px 20px;
        text-align: center;
    }

    .bhs-form-button {
        justify-content: center;
        border-radius: 0 0 10px 10px;
    }

    .bhs-result-header {
        flex-direction: column;
        text-align: center;
    }

    .bhs-result-route {
        flex-direction: column;
    }

    .bhs-route-arrow {
        transform: rotate(90deg);
    }

    .bhs-timeline-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }
}

/* Print styles */
@media print {
    .bhs-tracking-widget,
    .bhs-inline-track-form,
    .bhs-result-actions {
        display: none !important;
    }

    .bhs-tracking-results {
        margin: 0;
    }

    .bhs-result-card,
    .bhs-timeline-card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}
