/**
 * Real-Time Shipment Tracker Frontend Styles
 */

/* Tracking Widget Styles */
.rtst-tracking-widget,
.rtst-tracking-widget-shortcode {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Distinguish between order page and account page tracking */
.rtst-tracking-section.rtst-account-tracking {
    border-left: 4px solid #28a745;
    background: #f8fff9;
}

.rtst-tracking-section:not(.rtst-account-tracking) {
    border-left: 4px solid #0073aa;
    background: #f8f9ff;
}

/* Debug info for development */
.rtst-tracking-section::before {
    content: attr(id);
    display: block;
    font-size: 10px;
    color: #999;
    font-family: monospace;
    margin-bottom: 10px;
    padding: 2px 5px;
    background: #f0f0f0;
    border-radius: 3px;
}

/* Tracking Content Styles */
.rtst-tracking-content {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

.tracking-header h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 1.3em;
    border-bottom: 2px solid #0073aa;
    padding-bottom: 8px;
}

.tracking-header p {
    margin: 5px 0;
    color: #666;
}

.tracking-status-current,
.tracking-location,
.tracking-delivery {
    margin: 20px 0;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 6px;
    border-left: 4px solid #0073aa;
}

.tracking-status-current h4,
.tracking-location h4,
.tracking-delivery h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 1.1em;
}

.tracking-status-current p {
    margin: 0;
    font-weight: bold;
    color: #0073aa;
}

.tracking-location p,
.tracking-delivery p {
    margin: 0;
    color: #666;
}

/* Timeline Styles */
.tracking-timeline {
    margin: 20px 0;
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.tracking-timeline h4 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 1.3em;
    text-align: center;
    padding-bottom: 10px;
    border-bottom: 2px solid #0073aa;
}

.timeline-events {
    position: relative;
    max-height: 600px;
    overflow-y: auto;
    padding-right: 10px;
}

.timeline-events::-webkit-scrollbar {
    width: 6px;
}

.timeline-events::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.timeline-events::-webkit-scrollbar-thumb {
    background: #0073aa;
    border-radius: 3px;
}

.timeline-events::-webkit-scrollbar-thumb:hover {
    background: #005a87;
}

.timeline-events::before {
    content: '';
    position: absolute;
    left: 30px;
    top: 0;
    bottom: 0;
    width: 3px;
    background: linear-gradient(to bottom, #0073aa, #28a745, #ffc107, #dc3545);
    border-radius: 2px;
}

.timeline-event {
    position: relative;
    margin: 25px 0;
    padding-left: 70px;
    transition: all 0.3s ease;
}

/* Responsive design */
@media (max-width: 768px) {
    .timeline-event {
        padding-left: 60px;
        margin: 20px 0;
    }
    
    .timeline-events::before {
        left: 25px;
    }
    
    .timeline-event::before {
        left: 20px;
        width: 14px;
        height: 14px;
    }
    
    .event-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .event-status {
        min-width: auto;
        font-size: 1em;
    }
    
    .tracking-timeline {
        padding: 15px;
        margin: 15px 0;
    }
    
    .timeline-events {
        max-height: 500px;
    }
}

/* Tracking Page Styles */
.rtst-tracking-page {
    padding: 40px 0;
    background: #f8f9fa;
    min-height: 80vh;
}

.rtst-tracking-page .container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.tracking-header {
    text-align: center;
    margin-bottom: 40px;
    background: #fff;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.tracking-header h1 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 2.5em;
    font-weight: 300;
}

.tracking-info-summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.tracking-number,
.carrier-info,
.order-info {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

.tracking-number strong,
.carrier-info strong,
.order-info strong {
    display: block;
    color: #6c757d;
    font-size: 0.9em;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.tracking-number span,
.carrier-info span,
.order-info span {
    display: block;
    color: #333;
    font-size: 1.2em;
    font-weight: 600;
    font-family: monospace;
}

.tracking-content {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 30px;
    overflow: hidden;
}

.tracking-actions {
    text-align: center;
    margin-top: 30px;
}

.tracking-actions .button {
    display: inline-block;
    margin: 0 10px;
    padding: 12px 24px;
    background: #0073aa;
    color: #fff;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s ease;
    border: 2px solid #0073aa;
}

.tracking-actions .button:hover {
    background: #005a87;
    border-color: #005a87;
    color: #fff;
    transform: translateY(-2px);
}

.tracking-error {
    text-align: center;
    background: #fff;
    padding: 40px;
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.tracking-error p {
    color: #dc3545;
    font-size: 1.1em;
    margin-bottom: 20px;
}

/* Responsive design for tracking page */
@media (max-width: 768px) {
    .rtst-tracking-page {
        padding: 20px 0;
    }
    
    .tracking-header h1 {
        font-size: 2em;
    }
    
    .tracking-info-summary {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .tracking-actions .button {
        display: block;
        margin: 10px auto;
        max-width: 200px;
    }
}

.timeline-event:hover {
    transform: translateX(5px);
}

.timeline-event.latest-event {
    margin-top: 0;
}

.timeline-event::before {
    content: '';
    position: absolute;
    left: 25px;
    top: 12px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    border: 3px solid #0073aa;
    box-shadow: 0 0 0 3px #fff, 0 2px 4px rgba(0,0,0,0.2);
    z-index: 2;
}

.timeline-event.latest-event::before {
    border-color: #28a745;
    background: #28a745;
    box-shadow: 0 0 0 3px #fff, 0 0 0 6px rgba(40, 167, 69, 0.2), 0 2px 4px rgba(0,0,0,0.2);
}

.timeline-event.status-delivered::before {
    border-color: #28a745;
    background: #28a745;
}

.timeline-event.status-in-transit::before {
    border-color: #007bff;
    background: #007bff;
}

.timeline-event.status-out-for-delivery::before {
    border-color: #ffc107;
    background: #ffc107;
}

.timeline-event.status-pending::before {
    border-color: #6c757d;
    background: #6c757d;
}

.timeline-event.status-manifested::before {
    border-color: #17a2b8;
    background: #17a2b8;
}

.timeline-event.status-exception::before {
    border-color: #dc3545;
    background: #dc3545;
}

.event-marker {
    position: absolute;
    left: 0;
    top: 0;
    width: 60px;
    text-align: center;
}

.latest-indicator {
    background: #28a745;
    color: #fff;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
}

.event-content {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #e9ecef;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    transition: all 0.3s ease;
}

.timeline-event:hover .event-content {
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-color: #0073aa;
}

.event-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.event-status {
    font-weight: bold;
    font-size: 1.1em;
    padding: 4px 12px;
    border-radius: 20px;
    color: #fff;
    text-align: center;
    min-width: 100px;
}

.event-time {
    font-size: 0.9em;
    color: #666;
    background: #f8f9fa;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: monospace;
}

.event-location {
    color: #495057;
    font-size: 1em;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.location-icon {
    font-size: 1.2em;
}

.event-remarks {
    color: #333;
    font-size: 1em;
    font-weight: 500;
    margin-bottom: 8px;
    line-height: 1.4;
}

.event-details {
    color: #6c757d;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 8px;
}

.details-label {
    font-weight: 500;
    color: #495057;
}

.details-value {
    background: #e9ecef;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: monospace;
}

/* Track Button Styles */
.rtst-track-button {
    background: #0073aa !important;
    color: #fff !important;
    border-color: #0073aa !important;
    margin-right: 10px !important;
    transition: all 0.3s ease !important;
}

.rtst-track-button:hover {
    background: #005a87 !important;
    border-color: #005a87 !important;
    color: #fff !important;
}

/* External Link */
.tracking-external-link {
    margin: 20px 0;
    text-align: center;
}

.tracking-external-link .button {
    display: inline-block;
    padding: 10px 20px;
    background: #0073aa;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    transition: background 0.3s ease;
}

.tracking-external-link .button:hover {
    background: #005a87;
    color: #fff;
}

/* Status Colors */
.status-delivered {
    background: #28a745 !important;
    color: #fff !important;
}

.status-in-transit {
    background: #007bff !important;
    color: #fff !important;
}

.status-out-for-delivery {
    background: #ffc107 !important;
    color: #000 !important;
}

.status-pending {
    background: #6c757d !important;
    color: #fff !important;
}

.status-exception {
    background: #dc3545 !important;
    color: #fff !important;
}

.status-manifested {
    background: #17a2b8 !important;
    color: #fff !important;
}

.status-default {
    background: #6c757d !important;
    color: #fff !important;
}

/* Status-specific hover effects */
.timeline-event.status-delivered:hover .event-content {
    border-color: #28a745;
}

.timeline-event.status-in-transit:hover .event-content {
    border-color: #007bff;
}

.timeline-event.status-out-for-delivery:hover .event-content {
    border-color: #ffc107;
}

.timeline-event.status-pending:hover .event-content {
    border-color: #6c757d;
}

.timeline-event.status-manifested:hover .event-content {
    border-color: #17a2b8;
}

.timeline-event.status-exception:hover .event-content {
    border-color: #dc3545;
}

.rtst-tracking-widget h2,
.rtst-tracking-widget h3,
.rtst-tracking-widget-shortcode h3 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 1.5em;
    border-bottom: 2px solid #0073aa;
    padding-bottom: 10px;
}

/* Loading State */
.loading {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-style: italic;
}

.loading:before {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #ddd;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

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

/* Tracking Summary */
.tracking-summary {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 6px;
    margin-bottom: 20px;
}

.tracking-summary > div {
    margin-bottom: 10px;
    display: flex;
    align-items: center;
}

.tracking-summary > div:last-child {
    margin-bottom: 0;
}

.tracking-summary strong {
    min-width: 120px;
    color: #555;
    font-weight: 600;
}

.tracking-summary .status-text {
    font-weight: 600;
    color: #0073aa;
}

/* Tracking Timeline */
.tracking-timeline {
    margin: 20px 0;
}

.tracking-timeline h4 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 1.2em;
}

.timeline {
    position: relative;
    padding-left: 30px;
}

.timeline:before {
    content: '';
    position: absolute;
    left: 15px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #ddd;
}

.timeline-item {
    position: relative;
    margin-bottom: 20px;
    padding-left: 20px;
}

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

.timeline-item.current .timeline-marker {
    background: #0073aa;
    border-color: #0073aa;
}

.timeline-marker {
    position: absolute;
    left: -22px;
    top: 5px;
    width: 12px;
    height: 12px;
    border: 2px solid #ddd;
    border-radius: 50%;
    background: #fff;
    z-index: 1;
}

.timeline-content {
    background: #fff;
    padding: 15px;
    border-radius: 6px;
    border: 1px solid #eee;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.event-status {
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.event-location {
    color: #666;
    font-size: 0.9em;
    margin-bottom: 5px;
}

.event-time {
    color: #999;
    font-size: 0.8em;
    margin-bottom: 5px;
}

.event-details {
    color: #777;
    font-size: 0.85em;
    font-style: italic;
}

/* Tracking Actions */
.tracking-actions {
    margin: 20px 0;
    padding: 15px 0;
    border-top: 1px solid #eee;
    text-align: center;
}

.rtst-refresh-btn,
.rtst-external-btn {
    display: inline-block;
    padding: 10px 20px;
    margin: 0 10px;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.rtst-refresh-btn {
    background: #0073aa;
    color: #fff;
    border: 1px solid #0073aa;
}

.rtst-refresh-btn:hover {
    background: #005a87;
    border-color: #005a87;
}

.rtst-external-btn {
    background: #fff;
    color: #0073aa;
    border: 1px solid #0073aa;
}

.rtst-external-btn:hover {
    background: #0073aa;
    color: #fff;
}

/* Tracking Footer */
.tracking-footer {
    text-align: center;
    padding: 15px 0;
    border-top: 1px solid #eee;
    color: #999;
    font-size: 0.9em;
}

/* Progress Bar */
.rtst-progress-bar {
    margin: 20px 0;
}

.progress-track {
    width: 100%;
    height: 8px;
    background: #eee;
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #0073aa, #00a0d2);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.progress-text {
    text-align: center;
    color: #666;
    font-size: 0.9em;
}

/* Status Classes */
.status-delivered .status-text {
    color: #28a745;
}

.status-out-for-delivery .status-text {
    color: #ffc107;
}

.status-in-transit .status-text {
    color: #0073aa;
}

.status-picked-up .status-text {
    color: #6f42c1;
}

.status-shipped .status-text {
    color: #17a2b8;
}

.status-unknown .status-text {
    color: #6c757d;
}

/* Error States */
.rtst-error {
    background: #f8d7da;
    color: #721c24;
    padding: 15px;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    margin: 10px 0;
}

/* Tracking Form Styles */
.rtst-tracking-form-shortcode {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 25px;
    margin: 20px 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.rtst-tracking-form-shortcode h3 {
    margin: 0 0 20px 0;
    color: #333;
    font-size: 1.4em;
    text-align: center;
}

.rtst-tracking-form .form-row {
    margin-bottom: 20px;
}

.rtst-tracking-form label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.rtst-tracking-form input[type="text"],
.rtst-tracking-form select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.rtst-tracking-form input[type="text"]:focus,
.rtst-tracking-form select:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0,115,170,0.2);
}

.rtst-track-btn {
    width: 100%;
    padding: 15px;
    background: #0073aa;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s ease;
}

.rtst-track-btn:hover {
    background: #005a87;
}

/* Modal Styles */
.rtst-modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
}

.rtst-modal-content {
    background-color: #fff;
    margin: 5% auto;
    padding: 30px;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    position: relative;
    box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}

.rtst-close {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    color: #aaa;
    transition: color 0.3s ease;
}

.rtst-close:hover {
    color: #333;
}

.rtst-modal h2 {
    margin: 0 0 25px 0;
    color: #333;
    text-align: center;
}

.rtst-modal .rtst-tracking-form {
    margin-bottom: 20px;
}

.rtst-modal .rtst-tracking-form .form-row {
    margin-bottom: 15px;
}

.rtst-modal .rtst-tracking-form input,
.rtst-modal .rtst-tracking-form select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.rtst-modal .rtst-track-btn {
    width: 100%;
    padding: 12px;
    font-size: 14px;
}

/* Notification Styles */
.rtst-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 6px;
    color: #fff;
    font-weight: 500;
    z-index: 1001;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    max-width: 300px;
}

.rtst-notification.show {
    transform: translateX(0);
}

.rtst-notification.rtst-success {
    background: #28a745;
}

.rtst-notification.rtst-error {
    background: #dc3545;
}

.rtst-notification.rtst-warning {
    background: #ffc107;
    color: #333;
}

.rtst-notification.rtst-info {
    background: #17a2b8;
}

/* Responsive Design */
@media (max-width: 768px) {
    .rtst-tracking-widget,
    .rtst-tracking-widget-shortcode {
        padding: 15px;
        margin: 15px 0;
    }
    
    .rtst-tracking-widget h2,
    .rtst-tracking-widget h3,
    .rtst-tracking-widget-shortcode h3 {
        font-size: 1.3em;
    }
    
    .tracking-summary > div {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .tracking-summary strong {
        min-width: auto;
        margin-bottom: 5px;
    }
    
    .timeline {
        padding-left: 20px;
    }
    
    .timeline:before {
        left: 10px;
    }
    
    .timeline-item {
        padding-left: 15px;
    }
    
    .timeline-marker {
        left: -17px;
        width: 10px;
        height: 10px;
    }
    
    .rtst-modal-content {
        margin: 10% auto;
        padding: 20px;
        width: 95%;
    }
    
    .rtst-notification {
        right: 10px;
        left: 10px;
        max-width: none;
    }
}

@media (max-width: 480px) {
    .tracking-actions {
        text-align: center;
    }
    
    .rtst-refresh-btn,
    .rtst-external-btn {
        display: block;
        margin: 10px auto;
        width: 100%;
        max-width: 200px;
    }
    
    .rtst-tracking-form input[type="text"],
    .rtst-tracking-form select {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Print Styles */
@media print {
    .rtst-tracking-widget,
    .rtst-tracking-widget-shortcode {
        border: none;
        box-shadow: none;
        margin: 0;
        padding: 0;
    }
    
    .tracking-actions,
    .rtst-modal {
        display: none !important;
    }
    
    .timeline:before {
        background: #000;
    }
    
    .timeline-marker {
        border-color: #000;
        background: #fff;
    }
}
