/* سامانه رهگیری تیپاکس — #00784a | #f5c400 */
:root {
    --brand: #00784a;
    --brand-dark: #005a38;
    --accent: #f5c400;
    --bg-page: #f4f6f9;
    --bg-white: #ffffff;
    --text: #1a1a2e;
    --text-muted: #5a6478;
    --border: #d8dee8;
    --error: #c0392b;
    --error-bg: #fdf0ef;
    --success: #059669;
    --success-bg: #ecfdf5;
    --radius: 6px;
    --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(--brand);
    border-bottom: 4px solid var(--accent);
}

.header-inner {
    max-width: var(--max-w);
    margin: 0 auto;
    padding: 14px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.site-logo {
    height: 52px;
    width: auto;
    object-fit: contain;
}

.header-text h1 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 800;
    color: #fff;
}

.header-text p {
    margin: 2px 0 0;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.75);
}

/* ── Main ── */
.site-main {
    flex: 1;
    max-width: var(--max-w);
    width: 100%;
    margin: 0 auto;
    padding: 32px 24px 48px;
}

/* ── Search Section ── */
.search-section {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 28px 32px;
    margin-bottom: 28px;
}

.search-section h2 {
    margin: 0 0 6px;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--brand);
}

.search-section .hint {
    margin: 0 0 24px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.form-row { margin-bottom: 18px; }

.form-row label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-row > input[type="text"] {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text);
    background: var(--bg-white);
    transition: border-color 0.15s;
}

.form-row input:focus {
    border-color: var(--brand);
    outline: 2px solid rgba(0, 120, 74, 0.12);
    outline-offset: 0;
}

.form-row input.is-valid {
    border: 2px solid var(--success);
    background: var(--success-bg);
}

.form-row input.is-invalid {
    border: 2px solid var(--error);
    background: var(--error-bg);
}

.form-row .field-error {
    font-size: 0.78rem;
    color: var(--error);
    margin-top: 6px;
    display: none;
}

.form-row .field-error.show { display: block; }


.field-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.search-type-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.type-option {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 8px;
    border: 2px solid var(--border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg-white);
    transition: border-color 0.15s, background 0.15s, color 0.15s;
    text-align: center;
}

.type-option input { display: none; }

.type-option:has(input:checked) {
    border-color: var(--brand);
    background: #e8f5ee;
    color: var(--brand);
}

.api-badge {
    margin: 14px 0 0;
    font-size: 0.75rem;
    color: var(--brand);
    background: #e8f5ee;
    border: 1px solid #b8dfc8;
    padding: 6px 12px;
    border-radius: var(--radius);
    text-align: center;
}

.form-row input.tracking-input {
    direction: ltr;
    text-align: left;
    letter-spacing: 0.5px;
}

.captcha-frame img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.captcha-frame .captcha-placeholder {
    font-size: 0.7rem;
    color: var(--text-muted);
    padding: 0 6px;
    text-align: center;
}

.btn-submit {
    width: 100%;
    padding: 13px;
    background: var(--brand);
    color: #fff;
    border: none;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 6px;
    transition: background 0.15s;
}

.btn-submit:hover:not(:disabled) { background: var(--brand-dark); }

.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); } }

/* ── 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; margin-top: 1px; }

.hidden { display: none !important; }

/* ── Results ── */
#result-container { margin-top: 0; }

.result-panel {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.result-topbar {
    background: var(--brand);
    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: 4px;
    font-size: 0.82rem;
    direction: ltr;
    letter-spacing: 0.5px;
    white-space: nowrap;
}

.btn-close-result {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--error);
    border: none;
    color: #fff;
    padding: 7px 14px;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.78rem;
    font-weight: 700;
    font-family: inherit;
    flex-shrink: 0;
    transition: background 0.15s;
}

.btn-close-result:hover { background: #a93226; }

.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: #004d30;
    padding: 16px 24px;
    border-bottom: 3px solid var(--accent);
}

.status-strip .label {
    font-size: 0.72rem;
    color: rgba(255,255,255,0.6);
    margin-bottom: 4px;
}

.status-strip .value {
    font-size: 0.92rem;
    font-weight: 600;
    color: #fff;
    line-height: 1.55;
}

.status-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 10px;
}

.chip {
    font-size: 0.75rem;
    background: rgba(255,255,255,0.1);
    color: rgba(255,255,255,0.9);
    padding: 4px 10px;
    border-radius: 4px;
    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);
    margin: 0 0 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--accent);
    display: inline-block;
}

/* Parcel grid */
.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: var(--radius);
    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;
}

/* Timeline */
.timeline { padding: 0; }

.chip svg,
.tag svg,
.btn-courier svg {
    width: 11px;
    height: 11px;
    flex-shrink: 0;
}

.tl-date {
    font-size: 0.82rem;
    font-weight: 700;
    color: var(--brand);
    background: #e8f5ee;
    padding: 5px 12px;
    border-radius: 4px;
    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);
    border-color: var(--brand);
    color: #fff;
}

.tl-body {
    flex: 1;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 12px 14px;
    background: var(--bg-white);
}

.tl-item.is-latest .tl-body {
    border-color: var(--brand);
    border-right: 3px solid var(--accent);
}

.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: 4px;
    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(--accent);
    color: var(--brand);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.78rem;
    font-weight: 700;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s;
}

.btn-courier:hover {
    background: var(--accent);
}

.btn-courier svg { width: 13px; height: 13px; flex-shrink: 0; }

/* Loading */
.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);
}

.loading-box .spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin: 0 auto 12px;
}

/* ── Modal ── */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 40, 25, 0.55);
    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);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid var(--accent);
}

.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: 4px;
    cursor: pointer;
    font-size: 1.1rem;
    font-family: inherit;
    line-height: 1;
}

.modal-head button:hover { background: rgba(255,255,255,0.12); }

.modal-content { padding: 24px 20px; }

.courier-card { text-align: center; }

.courier-badge {
    display: inline-block;
    background: var(--accent);
    color: var(--brand);
    font-size: 0.72rem;
    font-weight: 800;
    padding: 3px 12px;
    border-radius: 4px;
    margin-bottom: 14px;
}

.courier-card img {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--accent);
    margin-bottom: 12px;
}

.courier-card .name {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--brand);
}

.detail-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-page);
    border-radius: var(--radius);
    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;
    line-height: 1.7;
}

/* ── Footer ── */
.site-footer {
    background: var(--brand);
    color: rgba(255,255,255,0.65);
    text-align: center;
    padding: 14px 24px;
    font-size: 0.78rem;
    border-top: 3px solid var(--accent);
}

/* ── Print FAB ── */
.btn-print-fab {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 900;
    display: none;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    min-width: max-content;
    white-space: nowrap;
    background: var(--brand);
    color: #fff;
    border: 2px solid var(--accent);
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0,0,0,0.18);
    transition: background 0.15s;
    overflow: visible;
    line-height: 1;
}

.btn-print-fab:hover { background: var(--brand-dark); }

.btn-print-fab.visible { display: inline-flex; }

.btn-print-fab svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    display: block;
}

/* ── Print styles ── */
@media print {
    @page {
        size: A4 portrait;
        margin: 12mm;
    }

    body {
        background: #fff !important;
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .site-header,
    .search-section,
    .site-footer,
    .btn-print-fab,
    .modal-backdrop {
        display: none !important;
    }

    .site-main {
        max-width: 100% !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    #result-container {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .result-panel {
        border: none !important;
        box-shadow: none !important;
        width: 100% !important;
        overflow: visible !important;
    }

    .result-topbar,
    .status-strip {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    .btn-close-result,
    .btn-courier {
        display: none !important;
    }

    .tl-item::before { display: none; }

    .tl-body,
    .tl-item {
        break-inside: avoid;
        page-break-inside: avoid;
    }
}

/* ── Responsive ── */
@media (max-width: 600px) {
    .site-main { padding: 20px 14px 80px; }
    .search-section { padding: 20px 16px; }
    .search-type-row { grid-template-columns: 1fr; }
    .result-topbar, .status-strip, .result-body { padding-left: 16px; padding-right: 16px; }
    .header-inner { padding: 12px 16px; }
    .site-logo { height: 40px; }
    .btn-print-fab {
        bottom: 14px;
        left: 14px;
        right: auto;
        padding: 10px 14px;
        font-size: 0.75rem;
    }
}
