/* سامانه رهگیری چاپار — #153D8A | #D20A18 | #004595 */
:root {
    --brand-blue: #153D8A;
    --brand-blue-dark: #003366;
    --brand-blue-hero: #004595;
    --brand-red: #D20A18;
    --brand-red-dark: #a80813;
    --bg-page: #f5f7fa;
    --bg-white: #ffffff;
    --text: #1a2b4a;
    --text-muted: #5a6478;
    --border: #d8dee8;
    --error: #c0392b;
    --error-bg: #fdf0ef;
    --success: #059669;
    --success-bg: #ecfdf5;
    --radius: 12px;
    --max-w: 960px;
}

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

html { scroll-behavior: smooth; }

body {
    font-family: 'Vazirmatn', Tahoma, Arial, sans-serif;
    background: var(--bg-page);
    color: var(--text);
    margin: 0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
}

/* ── Header (سفید مثل سایت اصلی) ── */
.site-header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 8px rgba(21, 61, 138, 0.06);
}

.header-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.site-logo {
    height: 48px;
    width: auto;
    object-fit: contain;
}

.header-text h1 {
    margin: 0;
    font-size: 1rem;
    font-weight: 800;
    color: var(--brand-blue);
}

.header-text p {
    margin: 2px 0 0;
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ── Hero آبی ── */
.hero-wrap {
    position: relative;
    flex: 1;
}

.hero-band {
    background: linear-gradient(135deg, var(--brand-blue-hero) 0%, var(--brand-blue) 100%);
    padding: 48px 24px 88px;
    position: relative;
    overflow: hidden;
}

.hero-band::before {
    content: '';
    position: absolute;
    left: -80px;
    top: 50%;
    transform: translateY(-50%);
    width: 320px;
    height: 320px;
    border-radius: 50%;
    border: 28px solid rgba(210, 10, 24, 0.25);
    box-shadow:
        0 0 0 28px rgba(210, 10, 24, 0.12),
        0 0 0 56px rgba(210, 10, 24, 0.06);
    pointer-events: none;
}

.hero-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

.hero-kicker {
    margin: 0 0 8px;
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.85);
}

.hero-title {
    margin: 0 0 12px;
    font-size: clamp(1.5rem, 4vw, 2rem);
    font-weight: 800;
    color: #fff;
    line-height: 1.4;
}

.hero-title span {
    color: #fff;
    font-weight: 800;
}

.hero-desc {
    margin: 0;
    max-width: 560px;
    font-size: 0.88rem;
    color: rgba(255, 255, 255, 0.82);
    line-height: 1.8;
}

/* ── Main ── */
.site-main {
    max-width: var(--max-w);
    width: 100%;
    margin: -56px auto 0;
    padding: 0 24px 48px;
    position: relative;
    z-index: 2;
}

/* ── کارت جستجو ── */
.search-section {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px 28px 20px;
    margin-bottom: 28px;
    box-shadow: 0 8px 32px rgba(21, 61, 138, 0.12);
}

.search-label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.search-row {
    display: flex;
    gap: 10px;
    align-items: stretch;
}

.search-row .tracking-input {
    flex: 1;
    min-width: 0;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text);
    background: var(--bg-white);
    direction: ltr;
    text-align: left;
    letter-spacing: 0.5px;
    transition: border-color 0.15s;
}

.search-row .tracking-input:focus {
    border-color: var(--brand-blue);
    outline: 2px solid rgba(21, 61, 138, 0.12);
    outline-offset: 0;
}

.search-row .tracking-input.is-valid {
    border-color: var(--success);
    background: var(--success-bg);
}

.search-row .tracking-input.is-invalid {
    border-color: var(--error);
    background: var(--error-bg);
}

.field-error {
    font-size: 0.78rem;
    color: var(--error);
    margin-top: 8px;
    display: none;
}

.field-error.show { display: block; }

.btn-submit {
    flex-shrink: 0;
    padding: 12px 20px;
    background: var(--brand-blue-dark);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    white-space: nowrap;
    transition: background 0.15s;
}

.btn-submit:hover:not(:disabled) { background: var(--brand-blue); }

.btn-submit:disabled {
    background: #9aa5b4;
    cursor: not-allowed;
}

.btn-submit .spinner {
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

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

.hidden { display: none !important; }

/* ── Alerts ── */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    margin-top: 12px;
}

.alert-error {
    background: var(--error-bg);
    border: 1px solid #f5c6c3;
    color: var(--error);
}

.alert svg { width: 18px; height: 18px; flex-shrink: 0; }

/* ── Results ── */
#result-container { margin-top: 0; }

.result-panel {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(21, 61, 138, 0.08);
}

.result-topbar {
    background: var(--brand-blue);
    color: #fff;
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 16px;
}

.result-topbar h3 {
    margin: 0 0 4px;
    font-size: 1rem;
    font-weight: 700;
}

.result-topbar .meta {
    font-size: 0.8rem;
    opacity: 0.8;
}

.tracking-code {
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.2);
    padding: 5px 12px;
    border-radius: 8px;
    font-size: 0.82rem;
    direction: ltr;
    letter-spacing: 0.5px;
    white-space: nowrap;
    color: var(--brand-red);
    background: #fff;
    font-weight: 700;
}

.btn-close-result {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--brand-red);
    border: none;
    color: #fff;
    padding: 7px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 700;
    font-family: inherit;
    flex-shrink: 0;
    transition: background 0.15s;
}

.btn-close-result:hover { background: var(--brand-red-dark); }

.btn-close-result svg { width: 14px; height: 14px; flex-shrink: 0; }

.result-topbar-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.status-strip {
    background: #f0f4fa;
    padding: 16px 24px;
    border-bottom: 3px solid var(--brand-red);
}

.status-strip .label {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.status-strip .value {
    font-size: 0.92rem;
    font-weight: 700;
    color: var(--brand-blue);
    line-height: 1.55;
}

.status-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.chip {
    font-size: 0.75rem;
    background: #fff;
    color: var(--text);
    border: 1px solid var(--border);
    padding: 4px 10px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.chip svg { width: 11px; height: 11px; opacity: 0.85; flex-shrink: 0; }

.result-body { padding: 24px; }

.section-heading {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--brand-blue);
    margin: 0 0 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--brand-red);
    display: inline-block;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 10px;
    margin-bottom: 28px;
}

.info-cell {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    background: var(--bg-page);
}

.info-cell .k {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.info-cell .v {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
}

/* ── نقشه ── */
.map-wrap { margin-bottom: 28px; }

.map-legend {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.legend-item {
    font-size: 0.78rem;
    font-weight: 700;
    padding: 4px 12px;
    border-radius: 14px;
    color: #fff;
}

.legend-item.delivery { background: var(--brand-red); }
.legend-item.distribution { background: var(--brand-blue); }

#trackingMap {
    height: 340px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: #e8edf3;
}

.map-marker-wrap {
    background: transparent !important;
    border: none !important;
}

.map-marker {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.map-marker-label {
    font-size: 11px;
    font-weight: 800;
    white-space: nowrap;
    padding: 4px 10px;
    border-radius: 14px;
    margin-bottom: 5px;
    font-family: 'Vazirmatn', Tahoma, sans-serif;
    box-shadow: 0 2px 8px rgba(0,0,0,0.18);
    line-height: 1.3;
}

.map-marker-label.delivery {
    background: var(--brand-red);
    color: #fff;
}

.map-marker-label.distribution {
    background: var(--brand-blue);
    color: #fff;
}

.map-marker-pin {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.35);
}

/* ── Timeline ── */
.timeline { padding: 0; }

.tl-date {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--brand-blue);
    background: #e8eef8;
    padding: 5px 12px;
    border-radius: 8px;
    display: inline-block;
    margin: 20px 0 12px;
}

.tl-date:first-child { margin-top: 0; }

.tl-item {
    display: flex;
    gap: 14px;
    padding-bottom: 18px;
    position: relative;
}

.tl-item::before {
    content: '';
    position: absolute;
    right: 13px;
    top: 28px;
    bottom: 0;
    width: 2px;
    background: var(--border);
}

.tl-item:last-child::before { display: none; }

.tl-num {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--bg-white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    font-weight: 800;
    color: var(--text-muted);
    flex-shrink: 0;
    z-index: 1;
}

.tl-item.is-latest .tl-num {
    background: var(--brand-blue);
    border-color: var(--brand-blue);
    color: #fff;
}

.tl-body {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    background: var(--bg-white);
}

.tl-item.is-latest .tl-body {
    border-color: var(--brand-blue);
    border-right: 3px solid var(--brand-red);
}

.tl-status {
    font-size: 0.88rem;
    font-weight: 600;
    margin-bottom: 8px;
    line-height: 1.55;
}

.tl-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.tag {
    font-size: 0.75rem;
    color: var(--text-muted);
    background: var(--bg-page);
    border: 1px solid var(--border);
    padding: 3px 8px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.tag svg { width: 11px; height: 11px; flex-shrink: 0; }

.btn-courier {
    margin-top: 10px;
    padding: 7px 14px;
    background: var(--bg-white);
    border: 1px solid var(--brand-blue);
    color: var(--brand-blue);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s, color 0.15s;
}

.btn-courier:hover {
    background: var(--brand-blue);
    color: #fff;
}

.loading-box {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
    font-size: 0.9rem;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 4px 20px rgba(21, 61, 138, 0.08);
}

.loading-box .spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--brand-blue);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto 12px;
}

/* ── Modal ── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(21, 61, 138, 0.45);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal {
    background: var(--bg-white);
    border-radius: var(--radius);
    width: 100%;
    max-width: 380px;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0,0,0,0.18);
}

.modal-head {
    background: var(--brand-blue);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid var(--brand-red);
}

.modal-head h4 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
}

.modal-head button {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff;
    width: 30px;
    height: 30px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1rem;
    font-family: inherit;
    line-height: 1;
}

.modal-content { padding: 24px 20px; }

.signature-img {
    width: 100%;
    max-width: 280px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    display: block;
    margin: 0 auto 12px;
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-page);
    border-radius: 8px;
    margin-bottom: 6px;
    font-size: 0.85rem;
}

.detail-row .k { color: var(--text-muted); }
.detail-row .v { font-weight: 600; }

.modal-msg {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.88rem;
}

/* ── Footer ── */
.site-footer {
    background: var(--brand-blue);
    color: rgba(255,255,255,0.7);
    text-align: center;
    padding: 14px 24px;
    font-size: 0.78rem;
    border-top: 3px solid var(--brand-red);
}

/* ── Print FAB ── */
.btn-print-fab {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 900;
    display: none;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: var(--brand-blue-dark);
    color: #fff;
    border: 2px solid var(--brand-red);
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.18);
}

.btn-print-fab.visible { display: inline-flex; }

.btn-print-fab svg { width: 16px; height: 16px; }

@media print {
    @page {
        size: A4 portrait;
        margin: 10mm;
    }

    html, body {
        background: #fff !important;
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }

    .site-header,
    .hero-band,
    .search-section,
    .site-footer,
    .btn-print-fab,
    .modal-backdrop,
    .map-wrap,
    .map-legend {
        display: none !important;
    }

    .hero-wrap,
    .site-main,
    #result-container,
    #printArea,
    .result-panel,
    .result-body,
    .result-topbar,
    .status-strip {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        overflow: hidden !important;
        box-sizing: border-box !important;
    }

    .result-topbar {
        flex-wrap: wrap !important;
        padding: 14px 12px !important;
    }

    .result-topbar-actions {
        width: 100% !important;
        margin-top: 8px !important;
    }

    .tracking-code {
        max-width: 100% !important;
        word-break: break-all !important;
        white-space: normal !important;
    }

    .status-strip,
    .result-body {
        padding: 14px 12px !important;
    }

    .info-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 8px !important;
    }

    .info-cell,
    .tl-body {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .tl-item.is-latest .tl-body {
        border-right: none !important;
        border-left: 3px solid var(--brand-red) !important;
    }

    .tl-item::before { display: none !important; }

    .result-topbar,
    .status-strip {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .btn-close-result,
    .btn-courier { display: none !important; }
}

@media (max-width: 600px) {
    .hero-band { padding: 32px 16px 72px; }
    .site-main { padding: 0 14px 80px; }
    .search-section { padding: 18px 16px; }
    .search-row { flex-direction: column; }
    .btn-submit { width: 100%; }
    .result-topbar, .status-strip, .result-body { padding-left: 16px; padding-right: 16px; }
    .header-inner { padding: 12px 16px; }
    .site-logo { height: 40px; }
    #trackingMap { height: 280px; }
}
