/* Shared styles for order lists (orders, user orders, dashboard). Builds on product_list.css and customers.css. */

/* ---------- Status tabs ---------- */
.or-tabs {
    display: flex;
    gap: 4px;
    padding: 4px;
    overflow-x: auto;
    background: #f1f3f7;
    border-radius: 10px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
}

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

.or-tab {
    display: inline-flex;
    flex: 1 0 auto;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #4b5563;
    font-size: .8125rem;
    font-weight: 600;
    white-space: nowrap;
    transition: background-color .15s, color .15s, box-shadow .15s;
}

.or-tab:hover {
    color: var(--sp-text);
}

.or-tab.is-active {
    background: #fff;
    color: var(--sp-text);
    box-shadow: 0 1px 3px rgba(16, 24, 40, .14);
}

.or-tab:focus-visible {
    outline: 2px solid var(--sp-primary);
    outline-offset: -2px;
}

.or-tab .or-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.or-tab .is-placed { color: #2f6bd4; }
.or-tab .is-shipped { color: #dc8a00; }
.or-tab .is-delivered { color: #12b76a; }
.or-tab .is-cancelled { color: #f04438; }

/* Full-width segmented control when it sits alone in a toolbar. */
.sp-toolbar > .or-tabs {
    flex: 1 1 100%;
}

/* ---------- Filter bar ---------- */
.or-filters {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--sp-border);
}

.or-filter-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
}

.or-dates {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.or-dates .form-control {
    width: 150px;
}

.or-dates-sep {
    color: var(--sp-muted);
    font-size: .8125rem;
}

.or-date-error {
    font-size: .75rem;
    color: var(--sp-danger);
}

.or-date-error:empty {
    display: none;
}

.or-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--sp-border);
    background: #fafbfc;
    font-size: .75rem;
    color: var(--sp-muted);
}

.or-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 4px 3px 10px;
    border: 1px solid var(--sp-border);
    border-radius: 999px;
    background: #fff;
    font-size: .75rem;
    font-weight: 600;
    color: var(--sp-text);
}

.or-chip button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--sp-muted);
}

.or-chip button:hover {
    background: #f1f3f7;
    color: var(--sp-text);
}

/* ---------- Status pill ---------- */
.or-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: .72rem;
    font-weight: 700;
    white-space: nowrap;
}

.or-status::before {
    content: "";
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.or-status.is-placed { background: #eff4ff; color: #1d4ed8; }
.or-status.is-shipped { background: #fffaeb; color: #b54708; }
.or-status.is-delivered { background: #ecfdf3; color: #067647; }
.or-status.is-cancelled { background: #fef3f2; color: #b42318; }
.or-status.is-unknown { background: #f1f3f7; color: #4b5563; }

/* ---------- Order list + card ---------- */
.or-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 16px;
}

.or-list.cu-is-loading {
    opacity: .55;
    pointer-events: none;
}

.or-card {
    min-width: 0;
    border: 1px solid var(--sp-border);
    border-radius: 12px;
    background: #fff;
    transition: border-color .15s, box-shadow .15s;
}

.or-card:hover {
    border-color: #d5dae6;
    box-shadow: 0 6px 16px -10px rgba(16, 24, 40, .25);
}

.or-card.sp-flash {
    animation: sp-flash 2.6s ease-out;
}

.or-card.is-updating {
    opacity: .6;
    pointer-events: none;
}

.or-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
}

.or-who {
    flex: 1;
    min-width: 0;
}

.or-name {
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    font-weight: 700;
    line-height: 1.35;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--sp-text);
    text-decoration: none;
    vertical-align: bottom;
}

a.or-name:hover {
    color: var(--sp-primary);
}

.or-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 2px 10px;
    margin-top: 2px;
    font-size: .8125rem;
    color: var(--sp-muted);
}

.or-id {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: .75rem;
    font-weight: 600;
    color: #4b5563;
}

.or-id .cu-copy {
    width: 24px;
    height: 24px;
    font-size: .85rem;
}

.or-sum {
    display: flex;
    flex: none;
    flex-direction: column;
    align-items: flex-end;
    gap: 6px;
    text-align: right;
}

.or-amount {
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
}

.or-details {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px 16px;
    margin: 0;
    padding: 12px 16px;
    border-top: 1px dashed var(--sp-border);
}

.or-details > div {
    min-width: 0;
}

.or-details .is-wide {
    grid-column: span 2;
}

.or-details dt {
    margin-bottom: 2px;
    font-size: .68rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: var(--sp-muted);
}

.or-details dd {
    display: flex;
    align-items: center;
    gap: 2px;
    margin: 0;
    font-size: .8125rem;
    color: var(--sp-text);
    word-break: break-word;
}

.or-details dd a {
    color: var(--sp-text);
    text-decoration: none;
}

.or-details dd a:hover {
    color: var(--sp-primary);
}

.or-details dd .cu-copy {
    width: 24px;
    height: 24px;
    font-size: .85rem;
}

.or-details .is-address dd {
    display: block;
    line-height: 1.5;
}

.or-foot {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 16px;
    border-top: 1px solid var(--sp-border);
    border-radius: 0 0 12px 12px;
    background: #fafbfc;
}

.or-status-field {
    display: flex;
    align-items: center;
    gap: 8px;
}

.or-status-field label {
    margin: 0;
    font-size: .75rem;
    font-weight: 700;
    color: var(--sp-muted);
    white-space: nowrap;
}

.sp .or-status-field .form-select {
    width: 170px;
    height: 36px;
    font-size: .8125rem;
}

.or-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.btn.sp-btn-whatsapp {
    background: #25d366;
    color: #fff;
}

.btn.sp-btn-whatsapp:hover,
.btn.sp-btn-whatsapp:focus-visible {
    background: #1da851;
    color: #fff;
}

.or-skel {
    padding: 16px;
    border: 1px solid var(--sp-border);
    border-radius: 12px;
}

.or-list > .cu-state {
    border: 1px dashed var(--sp-border);
    border-radius: 12px;
}

.or-list > .cu-state .btn {
    margin-top: 14px;
}

/* ---------- Responsive ---------- */
@media (max-width: 1199.98px) {
    .or-details {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 991.98px) {
    .or-filters {
        grid-template-columns: minmax(0, 1fr);
    }
}

@media (max-width: 575.98px) {
    .or-list {
        padding: 12px;
        gap: 10px;
    }

    .or-head,
    .or-details,
    .or-foot {
        padding-left: 14px;
        padding-right: 14px;
    }

    .or-head .cu-avatar {
        display: none;
    }

    .or-details {
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .or-details .is-wide {
        grid-column: 1 / -1;
    }

    .or-status-field {
        width: 100%;
    }

    .sp .or-status-field .form-select {
        flex: 1;
        width: auto;
        height: 40px;
    }

    .or-actions {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .or-actions .btn.sp-btn {
        min-height: 40px;
    }

    .or-filters {
        padding: 12px;
    }

    .or-dates {
        flex: 1 1 100%;
    }

    .or-dates .form-control {
        flex: 1 1 0;
        width: 0;
        min-width: 0;
        padding-left: 10px;
        padding-right: 10px;
    }

    .or-filter-row > .btn.sp-btn {
        flex: 1;
    }

    .or-tab {
        flex: 0 0 auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .or-tab,
    .or-card {
        transition: none !important;
    }

    .or-card.sp-flash {
        animation: none !important;
    }
}
