/**
 * InTime Public Tracking - Modern Design
 * Matches site form styling with horizontal progress timeline
 */

/* ==========================================================================
   Base Container
   ========================================================================== */
.it-tracking {
    --it-black: #000000;
    --it-dark: #1a202c;
    --it-gray-dark: #2d3748;
    --it-gray: #4a5568;
    --it-gray-light: #6c757d;
    --it-gray-muted: #9ca3af;
    --it-border: #e9ecef;
    --it-bg: #f8f9fa;
    --it-white: #ffffff;
    --it-success: #10b981;
    --it-success-bg: #ecfdf5;
    --it-error: #ef4444;
    --it-error-bg: #fef2f2;
    --it-warning: #f59e0b;
    --it-warning-bg: #fffbeb;

    max-width: 800px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--it-gray-dark);
}

.it-tracking *,
.it-tracking *::before,
.it-tracking *::after {
    box-sizing: border-box;
}

/* ==========================================================================
   Form Card
   ========================================================================== */
.it-form {
    background: linear-gradient(135deg, var(--it-bg) 0%, var(--it-white) 100%);
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--it-border);
}

.it-form-title {
    font-weight: 700;
    font-size: 28px;
    line-height: 1.2;
    color: var(--it-dark);
    padding-bottom: 20px;
    border-bottom: 2px solid var(--it-border);
    margin: 0 0 20px 0;
    text-align: center;
}

.it-form-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 0;
}

.it-form-field {
    display: flex;
    flex-direction: column;
}

.it-form-field label {
    font-weight: 600;
    display: block;
    margin-bottom: 8px;
    color: var(--it-dark);
    font-size: 16px;
}

.it-form-field input {
    width: 100%;
    padding: 16px 24px;
    background: var(--it-white);
    border: 2px solid var(--it-border);
    border-radius: 12px;
    font-size: 16px;
    font-family: inherit;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    color: var(--it-gray-dark);
}

.it-form-field input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.18);
    transform: translateY(-2px);
}

.it-form-field input:hover {
    border-color: var(--it-gray-light);
}

.it-form-field input::placeholder {
    color: var(--it-gray-muted);
    opacity: 1;
    font-weight: 400;
}

.it-form-actions {
    grid-column: 1 / -1;
}

.it-form-submit {
    width: 100%;
    height: 56px;
    background: linear-gradient(135deg, var(--it-black) 0%, var(--it-gray-dark) 100%);
    color: var(--it-white);
    padding: 14px 20px;
    margin: 24px 0 0 0;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    font-size: 16px;
    font-family: inherit;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.it-form-submit:focus-visible {
    outline: none;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2), 0 0 0 3px rgba(59, 130, 246, 0.22);
}

.it-form-submit:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--it-dark) 0%, var(--it-black) 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2), 0 0 0 3px rgba(59, 130, 246, 0.14);
}

.it-form-submit:active:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 3px 12px rgba(0, 0, 0, 0.18);
}

.it-form-submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

.it-form-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--it-white);
    border-radius: 50%;
    animation: it-spin 0.8s linear infinite;
    display: none;
}

.it-form-submit.is-loading .it-form-spinner {
    display: block;
}

.it-form-submit.is-loading .it-form-submit-text {
    opacity: 0.7;
}

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

/* Form Messages */
.it-form-message {
    margin-top: 20px;
    padding: 16px;
    border-radius: 8px;
    font-weight: 500;
    text-align: center;
    display: none;
}

.it-form-message.is-visible {
    display: block;
}

.it-form-message.is-error {
    color: var(--it-error);
    background: var(--it-error-bg);
    border: 1px solid var(--it-error);
}

.it-form-message.is-info {
    color: var(--it-success);
    background: var(--it-success-bg);
    border: 1px solid var(--it-success);
}

/* ==========================================================================
   Results Container
   ========================================================================== */
.it-results {
    margin-top: 22px;
}

/* Empty State */
.it-empty {
    text-align: center;
    padding: 48px 24px;
    background: linear-gradient(135deg, var(--it-bg) 0%, var(--it-white) 100%);
    border: 2px dashed var(--it-border);
    border-radius: 16px;
}

.it-empty-icon {
    font-size: 56px;
    margin-bottom: 16px;
}

.it-empty-title {
    font-size: 20px;
    font-weight: 700;
    color: var(--it-dark);
    margin: 0 0 8px;
}

.it-empty-text {
    margin: 0;
    font-size: 16px;
    color: var(--it-gray);
}

/* ==========================================================================
   Tab Navigation
   ========================================================================== */
.it-tabs {
    display: flex;
    gap: 8px;
    padding: 6px;
    background: var(--it-bg);
    border-radius: 12px;
    border: 1px solid var(--it-border);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.it-tabs::-webkit-scrollbar {
    display: none;
}

.it-tabs[hidden] {
    display: none;
}

.it-tab {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 600;
    color: var(--it-gray);
    background: transparent;
    border: 2px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    white-space: nowrap;
    font-family: inherit;
    text-align: center;
}

.it-tab-label {
    width: 100%;
    text-align: center;
}

.it-tab:focus-visible {
    outline: none;
    border-color: rgba(59, 130, 246, 0.7);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.14);
}

.it-tab:hover:not(.is-active) {
    color: var(--it-gray-dark);
    background: var(--it-white);
    border-color: var(--it-border);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.it-tab.is-active {
    color: var(--it-white);
    background: var(--it-black);
    border-color: #3b82f6;
    box-shadow: 0 6px 14px rgba(59, 130, 246, 0.14);
}

/* Tab status dot removed (tabs are just "Shipment #N"). */

/* ==========================================================================
   Dropdown Navigation (for 4+ shipments)
   ========================================================================== */
.it-dropdown {
    margin-bottom: 20px;
}

.it-dropdown-select {
    width: 100%;
    padding: 16px 48px 16px 20px;
    font-size: 16px;
    font-weight: 600;
    font-family: inherit;
    color: var(--it-dark);
    background-color: var(--it-white);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%231a202c'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 20px;
    border: 2px solid var(--it-border);
    border-radius: 12px;
    cursor: pointer;
    box-sizing: border-box;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.it-dropdown-select:hover {
    border-color: var(--it-gray-light);
}

.it-dropdown-select:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.16);
}

/* ==========================================================================
   Tab Panels
   ========================================================================== */
.it-panels {
    margin-top: 20px;
}

.it-panel {
    display: none;
}

.it-panel.is-active {
    display: block;
    animation: it-fade-in 0.3s ease;
}

/* Stacked mode: show all shipments one under another (no tabs/dropdown). */
.it-panels[data-stack-mode="1"] .it-panel {
    display: block;
    margin-top: 20px;
    animation: none;
}

.it-panels[data-stack-mode="1"] .it-panel:first-child {
    margin-top: 0;
}

@keyframes it-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Shipment Card
   ========================================================================== */
.it-shipment {
    background: linear-gradient(135deg, var(--it-bg) 0%, var(--it-white) 100%);
    border: 1px solid var(--it-border);
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
}

.it-shipment-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 24px;
    border-bottom: 2px solid var(--it-border);
    background: var(--it-white);
}

.it-destination-line {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 18px;
    padding: 12px 16px;
    background: var(--it-white);
    border: 1px solid var(--it-border);
    border-radius: 12px;
}

.it-destination-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--it-gray-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.it-destination-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--it-gray-dark);
}

.it-tracking-number {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.it-tracking-number .it-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--it-gray-light);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.it-tracking-number .it-value {
    font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
    font-size: 18px;
    font-weight: 700;
    color: var(--it-black);
    text-decoration: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.it-tracking-number a.it-value:hover {
    color: var(--it-gray-dark);
    text-decoration: underline;
}

/* Status Badge */
.it-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 100px;
    max-width: 60%;
    min-width: 0;
}

.it-badge::before {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.it-badge-text {
    min-width: 0;
    white-space: normal;
    overflow-wrap: anywhere;
    line-height: 1.25;
}

.it-badge--pending {
    background: var(--it-bg);
    color: var(--it-gray);
}
.it-badge--pending::before { background: var(--it-gray-muted); }

.it-badge--confirmed {
    background: #eff6ff;
    color: #1d4ed8;
}
.it-badge--confirmed::before { background: #3b82f6; }

.it-badge--intransit {
    background: var(--it-warning-bg);
    color: #b45309;
}
.it-badge--intransit::before { background: var(--it-warning); }

.it-badge--delivered {
    background: var(--it-success-bg);
    color: #047857;
}
.it-badge--delivered::before { background: var(--it-success); }

.it-badge--cancelled {
    background: var(--it-error-bg);
    color: var(--it-error);
}
.it-badge--cancelled::before { background: var(--it-error); }

/* ==========================================================================
   Shipment Body
   ========================================================================== */
.it-shipment-body {
    padding: 24px;
}

/* ==========================================================================
   Horizontal Progress Timeline
   ========================================================================== */
.it-progress {
    margin-bottom: 15px;
}

.it-progress-steps {
    display: flex;
    justify-content: space-between;
    position: relative;
    padding: 0;
    margin: 0;
    list-style: none;
}

/* Progress line background */
.it-progress-steps::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 40px;
    right: 40px;
    height: 4px;
    background: var(--it-border);
    border-radius: 2px;
    z-index: 0;
}

/* Progress line filled */
.it-progress-steps::after {
    content: '';
    position: absolute;
    top: 20px;
    left: 40px;
    height: 4px;
    background: var(--it-success);
    border-radius: 2px;
    z-index: 1;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    width: var(--progress-width, 0%);
}

.it-progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    z-index: 2;
    flex: 1;
}

.it-progress-dot {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--it-white);
    border: 4px solid var(--it-border);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    margin-bottom: 12px;
}

.it-progress-dot svg {
    width: 18px;
    height: 18px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.it-progress-step.is-completed .it-progress-dot {
    background: var(--it-success);
    border-color: var(--it-success);
}

.it-progress-step.is-completed .it-progress-dot svg {
    opacity: 1;
    fill: var(--it-white);
}

.it-progress-step.is-current .it-progress-dot {
    background: var(--it-white);
    border-color: var(--it-success);
    box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.18);
}

.it-progress-step.is-current .it-progress-dot::after {
    content: '';
    width: 12px;
    height: 12px;
    background: var(--it-success);
    border-radius: 50%;
}

.it-progress-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--it-gray-muted);
    text-align: center;
    transition: color 0.3s ease;
}

.it-progress-step.is-completed .it-progress-label,
.it-progress-step.is-current .it-progress-label {
    color: var(--it-dark);
}

/* ==========================================================================
   Items Section
   ========================================================================== */
.it-items {
    margin-bottom: 24px;
    border: 2px solid var(--it-border);
    border-radius: 12px;
    overflow: hidden;
}

.it-items summary {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    font-size: 15px;
    font-weight: 600;
    color: var(--it-dark);
    cursor: pointer;
    list-style: none;
    user-select: none;
    background: var(--it-white);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.it-items summary::-webkit-details-marker {
    display: none;
}

.it-items summary:hover {
    background: var(--it-bg);
}

.it-items summary::before {
    content: '';
    width: 20px;
    height: 20px;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20' fill='%231a202c'%3E%3Cpath fill-rule='evenodd' d='M5.23 7.21a.75.75 0 011.06.02L10 11.168l3.71-3.938a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z' clip-rule='evenodd'/%3E%3C/svg%3E");
    background-size: contain;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.it-items[open] summary::before {
    transform: rotate(180deg);
}

.it-items-list {
    list-style: none;
    margin: 0;
    padding: 0;
    background: var(--it-bg);
}

.it-items-list li {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: 14px 20px;
    font-size: 15px;
    color: var(--it-gray-dark);
    border-top: 1px solid var(--it-border);
}

.it-item-name {
    flex: 1;
    min-width: 0;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    word-break: keep-all;
    overflow-wrap: normal;
}

.it-item-qty {
    flex-shrink: 0;
    margin-left: 16px;
    font-weight: 700;
    color: #1d4ed8;
    background: #eff6ff;
    padding: 4px 12px;
    border-radius: 100px;
    font-size: 13px;
    border: 1px solid rgba(59, 130, 246, 0.28);
}

/* ==========================================================================
   Events History
   ========================================================================== */
.it-events-section {
    border-top: 2px solid var(--it-border);
    padding-top: 24px;
}

.it-events-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--it-dark);
    margin: 0 0 16px;
}

.it-events-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.it-event {
    display: flex;
    gap: 16px;
    padding: 16px;
    background: var(--it-white);
    border: 2px solid var(--it-border);
    border-radius: 12px;
    margin-bottom: 12px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.it-event:last-child {
    margin-bottom: 0;
}

.it-event:hover {
    border-color: var(--it-gray-light);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.it-event--latest {
    background: var(--it-bg);
    border-color: var(--it-border);
    border-left-color: #3b82f6;
    border-left-width: 4px;
}

.it-event--latest:hover {
    border-color: var(--it-border);
    border-left-color: #1d4ed8;
    background: var(--it-white);
}

.it-event-date {
    font-size: 13px;
    font-weight: 600;
    color: var(--it-gray-light);
    white-space: nowrap;
    min-width: 140px;
}

.it-event--latest .it-event-date {
    color: var(--it-dark);
}

.it-event-content {
    flex: 1;
}

.it-event-status {
    font-size: 15px;
    font-weight: 600;
    color: var(--it-dark);
    display: block;
}

.it-event--latest .it-event-status {
    color: var(--it-black);
}

.it-event-reason {
    font-size: 14px;
    color: var(--it-gray);
    margin-top: 4px;
    display: block;
}

.it-event--latest .it-event-reason {
    color: var(--it-gray-dark);
}

.it-events-empty {
    text-align: center;
    padding: 32px;
    background: var(--it-white);
    border: 2px dashed var(--it-border);
    border-radius: 12px;
    color: var(--it-gray);
    font-size: 15px;
}

/* ==========================================================================
   Mobile Responsive
   ========================================================================== */
@media (max-width: 768px) {
    .it-form {
        padding: 24px;
        margin: 16px;
    }

    .it-form-title {
        font-size: 24px;
    }

    .it-form-fields {
        grid-template-columns: 1fr;
        gap: 16px;
    }

    .it-shipment-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
        padding: 20px;
    }

    .it-shipment-body {
        padding: 20px;
    }

    /* Progress timeline mobile */
    .it-progress-steps::before,
    .it-progress-steps::after {
        left: 20px;
        right: 20px;
    }

    .it-progress-dot {
        width: 32px;
        height: 32px;
    }

    .it-progress-dot svg {
        width: 14px;
        height: 14px;
    }

    .it-progress-step.is-current .it-progress-dot::after {
        width: 10px;
        height: 10px;
    }

    .it-progress-label {
        font-size: 11px;
    }

    .it-event {
        flex-direction: column;
        gap: 8px;
    }

    .it-event-date {
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .it-form {
        padding: 12px;
        margin: 0px;
        border-radius: 12px;
    }

    .it-form-title {
        font-size: 20px;
    }

    .it-form-field input {
        padding: 12px 16px;
        font-size: 14px;
    }

    .it-form-submit {
        height: 50px;
        font-size: 14px;
        margin-top: 5px;
    }

    .it-tabs {
        gap: 4px;
        padding: 4px;
    }

    .it-tab {
        padding: 10px 14px;
        font-size: 13px;
    }

    .it-dropdown-select {
        /* On small screens, prefer the native select UI (avoids clipping/truncation quirks). */
        padding: 12px 16px;
        font-size: 14px;
        max-width: 100%;
        background-image: none;
        appearance: auto;
        -webkit-appearance: menulist;
        -moz-appearance: auto;
    }

    .it-shipment {
        border-radius: 12px;
    }

    .it-shipment-header,
    .it-shipment-body {
        padding: 16px;
    }

    .it-tracking-number .it-value {
        font-size: 16px;
    }

    .it-badge {
        padding: 6px 12px;
        font-size: 12px;
        max-width: 100%;
    }

    /* Progress timeline small mobile */
    .it-progress-steps {
        gap: 4px;
    }

    .it-progress-steps::before,
    .it-progress-steps::after {
        top: 14px;
        left: 14px;
        right: 14px;
        height: 3px;
    }

    .it-progress-dot {
        width: 28px;
        height: 28px;
        border-width: 3px;
    }

    .it-progress-dot svg {
        width: 12px;
        height: 12px;
    }

    .it-progress-step.is-current .it-progress-dot::after {
        width: 8px;
        height: 8px;
    }

    .it-progress-label {
        font-size: 10px;
        max-width: 70px;
    }

    .it-items summary,
    .it-items-list li {
        padding: 12px 16px;
        font-size: 14px;
    }

    .it-events-title {
        font-size: 15px;
    }

    .it-event {
        padding: 14px;
    }

    .it-event-status {
        font-size: 14px;
    }

    .it-event-reason {
        font-size: 13px;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */
@media print {
    .it-tracking {
        max-width: none;
    }

    .it-form {
        display: none;
    }

    .it-tabs {
        display: none;
    }

    .it-dropdown {
        display: none;
    }

    .it-panel {
        display: block !important;
        page-break-inside: avoid;
    }

    .it-shipment {
        box-shadow: none;
        border: 1px solid #ddd;
        margin-bottom: 20px;
    }

    .it-event:hover {
        transform: none;
        box-shadow: none;
    }
}
