/* ========================================
   快递查询系统 - 主样式表
   ======================================== */

/* ---- Reset & Base ---- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #4f6ef7;
    --primary-dark: #3b54db;
    --primary-light: #eef1ff;
    --success: #27ae60;
    --warning: #f39c12;
    --danger: #e74c3c;
    --text: #2c3e50;
    --text-secondary: #7f8c8d;
    --text-light: #b0b8c1;
    --bg: #f5f7fa;
    --bg-white: #ffffff;
    --border: #e8ecf1;
    --border-light: #f0f2f5;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);
    --radius-sm: 6px;
    --radius: 10px;
    --radius-lg: 14px;
    --transition: 0.2s ease;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
                 "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 960px;
    margin: 0 auto;
    padding: 0 20px;
}

/* ---- Header ---- */
.header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 60px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--primary);
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.header-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-date {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* ---- Main ---- */
.main {
    flex: 1;
    padding: 28px 0 40px;
}

/* ---- Stats Row ---- */
.stats-row {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--bg-white);
    border-radius: var(--radius);
    padding: 20px 24px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon-total {
    background: #eef1ff;
    color: var(--primary);
}

.stat-icon-transit {
    background: #fff8e6;
    color: var(--warning);
}

.stat-icon-signed {
    background: #e8f8ef;
    color: var(--success);
}

.stat-content {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 2px;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
    line-height: 1.2;
}

/* ---- Card ---- */
.card {
    background: var(--bg-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
    overflow: visible;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-light);
    border-radius: var(--radius) var(--radius) 0 0;
}

.card-header h2 {
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text);
}

.card-header h2 svg {
    color: var(--primary);
}

.card-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.list-count {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

/* ---- Search Box ---- */
.search-box {
    position: relative;
    display: flex;
    align-items: center;
}

.search-box svg {
    position: absolute;
    left: 12px;
    color: var(--text-light);
    pointer-events: none;
}

.search-box input {
    width: 240px;
    height: 34px;
    padding: 0 36px 0 36px;
    border: 1.5px solid var(--border);
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text);
    background: var(--bg);
    outline: none;
    transition: all var(--transition);
}

.search-box input:focus {
    border-color: var(--primary);
    background: var(--bg-white);
    box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.1);
}

.search-box input::placeholder {
    color: var(--text-light);
}

.search-clear {
    position: absolute;
    right: 4px;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.search-clear:hover {
    color: var(--text);
    background: var(--border);
}

.card-body {
    padding: 24px;
}

.form-card {
    margin-bottom: 20px;
}

/* ---- Form ---- */
.form-inline {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
}

.form-group {
    flex: 1;
    min-width: 200px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-group input {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    color: var(--text);
    background: var(--bg-white);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
}

.form-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.1);
}

.form-group input::placeholder {
    color: var(--text-light);
}

/* ---- Select ---- */
.form-group select {
    width: 100%;
    height: 44px;
    padding: 0 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    color: var(--text);
    background: var(--bg-white);
    transition: border-color var(--transition), box-shadow var(--transition);
    outline: none;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%237f8c8d' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.1);
}

.form-group-sm {
    flex: 0 0 190px !important;
    min-width: 170px !important;
    overflow: visible;
}

/* ---- Custom Select (可输入可搜索下拉框) ---- */
.custom-select {
    position: relative;
    user-select: none;
}

.custom-select > input[type="text"] {
    width: 100%;
    height: 44px;
    padding: 0 36px 0 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    color: var(--text);
    background: var(--bg-white);
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.custom-select > input[type="text"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 110, 247, 0.1);
}

.custom-select > input[type="text"]::placeholder {
    color: var(--text-light);
}

.custom-select-arrow {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-light);
    cursor: pointer;
    transition: transform var(--transition);
    z-index: 2;
}

.custom-select-arrow:hover {
    color: var(--primary);
}

.custom-select.open .custom-select-arrow {
    transform: translateY(-50%) rotate(180deg);
}

.custom-select-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 4px;
    background: var(--bg-white);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 500;
    overflow: hidden;
}

.custom-select.open .custom-select-dropdown {
    display: block;
    animation: scaleIn 0.15s ease;
}

.custom-select-options {
    max-height: 220px;
    overflow-y: auto;
    padding: 4px 0;
}

.custom-select-option {
    padding: 9px 14px;
    font-size: 0.88rem;
    color: var(--text);
    cursor: pointer;
    transition: background var(--transition);
}

.custom-select-option:hover,
.custom-select-option.highlight {
    background: var(--primary-light);
    color: var(--primary);
}

.custom-select-option.selected {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.custom-select-empty {
    padding: 16px;
    text-align: center;
    font-size: 0.82rem;
    color: var(--text-light);
}

.form-hint {
    font-size: 0.78rem;
    color: var(--text-light);
}

/* ---- Express Courier Badge ---- */
.express-courier-badge {
    font-size: 0.7rem;
    color: var(--primary);
    background: var(--primary-light);
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    text-transform: uppercase;
}

/* ---- Express Item Action Buttons ---- */
.btn-track,
.btn-refresh-item {
    background: none;
    border: 1.5px solid var(--border);
    color: var(--text-light);
    cursor: pointer;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.btn-track:hover {
    color: var(--primary);
    border-color: var(--primary);
    background: var(--primary-light);
}

.btn-refresh-item:hover {
    color: var(--success);
    border-color: var(--success);
    background: #e8f8ef;
}

/* ---- Buttons ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 44px;
    padding: 0 22px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    white-space: nowrap;
    text-decoration: none;
    font-family: inherit;
    outline: none;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 12px rgba(79, 110, 247, 0.35);
}

.btn-primary:disabled {
    background: #a0b4f8;
    cursor: not-allowed;
    box-shadow: none;
}

.btn-outline {
    background: var(--bg-white);
    color: var(--text-secondary);
    border: 1.5px solid var(--border);
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: var(--primary-light);
}

.btn-danger {
    background: var(--danger);
    color: #fff;
}

.btn-danger:hover {
    background: #c0392b;
}

.btn-sm {
    height: 34px;
    padding: 0 14px;
    font-size: 0.8rem;
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: var(--radius-sm);
}

/* ---- Express List ---- */
.express-list {
    display: flex;
    flex-direction: column;
}

.express-item {
    display: flex;
    align-items: center;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-light);
    gap: 16px;
    transition: background var(--transition);
}

.express-item:last-child {
    border-bottom: none;
}

.express-item:hover {
    background: #fafbfc;
    margin: 0 -24px;
    padding-left: 24px;
    padding-right: 24px;
    border-radius: var(--radius-sm);
}

.express-icon-wrap {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--primary-light);
    color: var(--primary);
}

.express-icon-wrap.status-transit {
    background: #fff8e6;
    color: var(--warning);
}

.express-icon-wrap.status-signed {
    background: #e8f8ef;
    color: var(--success);
}

.express-icon-wrap.status-error {
    background: #fde8e8;
    color: var(--danger);
}

.express-info {
    flex: 1;
    min-width: 0;
}

.express-info-top {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 4px;
}

.express-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text);
}

.express-number {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: "SF Mono", "Monaco", "Menlo", "Consolas", monospace;
    background: var(--bg);
    padding: 2px 8px;
    border-radius: 4px;
}

.express-status-text {
    font-size: 0.82rem;
    color: var(--text-secondary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.express-status-badge {
    flex-shrink: 0;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-transit {
    background: #fff8e6;
    color: #b8860b;
}

.status-signed {
    background: #e8f8ef;
    color: #1e7e34;
}

.status-error {
    background: #fde8e8;
    color: #c0392b;
}

.express-time {
    flex-shrink: 0;
    font-size: 0.78rem;
    color: var(--text-light);
    white-space: nowrap;
    width: 100px;
    text-align: right;
}

.express-actions {
    flex-shrink: 0;
    display: flex;
    gap: 6px;
}

.btn-delete {
    background: none;
    border: 1.5px solid var(--border);
    color: var(--text-light);
    cursor: pointer;
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.btn-delete:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: #fde8e8;
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 48px 20px;
    color: var(--text-secondary);
}

.empty-state svg {
    margin-bottom: 16px;
}

.empty-state p {
    font-size: 0.95rem;
    margin-bottom: 4px;
}

.empty-hint {
    font-size: 0.82rem !important;
    color: var(--text-light) !important;
}

/* ---- Loading ---- */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 20px;
    gap: 12px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ---- Modal ---- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.modal {
    background: var(--bg-white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 420px;
    max-width: 90vw;
    overflow: hidden;
    animation: scaleIn 0.2s ease;
}

.modal-lg {
    width: 580px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px 24px 0;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-light);
    padding: 4px;
    border-radius: 4px;
    transition: all var(--transition);
}

.modal-close:hover {
    color: var(--text);
    background: var(--bg);
}

.modal-body {
    padding: 20px 24px;
    text-align: center;
}

.modal-body-scroll {
    text-align: left;
    overflow-y: auto;
    max-height: 60vh;
}

.modal-body svg {
    margin-bottom: 12px;
}

.modal-body p {
    font-size: 0.95rem;
    color: var(--text-secondary);
}

.modal-detail {
    font-size: 0.82rem !important;
    color: var(--text-light) !important;
    margin-top: 6px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 24px;
    background: var(--bg);
    border-top: 1px solid var(--border-light);
}

/* ---- Toast ---- */
.toast {
    position: fixed;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 28px;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    color: #fff;
    z-index: 2000;
    box-shadow: var(--shadow-lg);
    animation: slideDown 0.3s ease;
    max-width: 90vw;
    text-align: center;
}

.toast-success {
    background: var(--success);
}

.toast-error {
    background: var(--danger);
}

/* ---- Logistics Detail ---- */
.logistics-header-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-bottom: 16px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border-light);
}

.logistics-header-info span:first-child {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);
}

.logistics-header-info span:last-child {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ---- Timeline ---- */
.timeline {
    position: relative;
    padding-left: 24px;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 7px;
    top: 4px;
    bottom: 4px;
    width: 2px;
    background: var(--border);
}

.timeline-item {
    position: relative;
    padding-bottom: 18px;
}

.timeline-item:last-child {
    padding-bottom: 0;
}

.timeline-dot {
    position: absolute;
    left: -24px;
    top: 6px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: var(--bg-white);
    border: 2px solid var(--border);
    z-index: 1;
}

.timeline-dot-active {
    background: var(--primary);
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 110, 247, 0.15);
}

.timeline-item-latest .timeline-context {
    color: var(--primary);
    font-weight: 500;
}

.timeline-context {
    font-size: 0.88rem;
    color: var(--text);
    line-height: 1.5;
    margin-bottom: 4px;
}

.timeline-meta {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.timeline-time {
    font-size: 0.75rem;
    color: var(--text-light);
}

.timeline-status-tag {
    font-size: 0.7rem;
    padding: 1px 8px;
    border-radius: 10px;
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}

.timeline-location {
    font-size: 0.72rem;
    color: var(--text-light);
    background: var(--bg);
    padding: 1px 6px;
    border-radius: 4px;
}

.timeline-empty {
    text-align: center;
    padding: 32px 20px;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* ---- Animations ---- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

/* ---- Footer ---- */
.footer {
    background: var(--bg-white);
    border-top: 1px solid var(--border);
    padding: 20px 0;
    text-align: center;
}

.footer p {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* ---- Responsive ---- */
@media (max-width: 768px) {
    .stats-row {
        grid-template-columns: repeat(3, 1fr);
        gap: 10px;
    }

    .stat-card {
        padding: 14px 16px;
        gap: 10px;
    }

    .stat-icon {
        width: 38px;
        height: 38px;
    }

    .stat-icon svg {
        width: 18px;
        height: 18px;
    }

    .stat-value {
        font-size: 1.35rem;
    }

    .form-inline {
        flex-direction: column;
    }

    .form-group {
        min-width: 100%;
    }

    .express-time {
        display: none;
    }

    .express-actions {
        flex-direction: column;
    }

    .express-item {
        flex-wrap: wrap;
        gap: 10px;
    }

    .search-box input {
        width: 160px;
    }
}

@media (max-width: 480px) {
    .stats-row {
        grid-template-columns: 1fr;
    }

    .header-inner {
        height: 52px;
    }

    .logo h1 {
        font-size: 1rem;
    }

    .card-body {
        padding: 16px;
    }

    .express-item:hover {
        margin: 0 -16px;
        padding-left: 16px;
        padding-right: 16px;
    }

    .search-box input {
        width: 130px;
    }

    .card-actions {
        gap: 8px;
        flex-wrap: wrap;
    }
}
