/**
 * Bostam SMM Platform — Order Tracking & History (Apple-Inspired Standard)
 * Feature: ORD-03 & Self-Service Actions
 * Path: assets/css/orders.css
 */

/* ==========================================================================
   Page Container & Layout
   ========================================================================== */
.orders-page-container {
    width: 100%;
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 0 var(--space-2xl) 0;
    min-width: 0;
    box-sizing: border-box;
}

.orders-page-header {
    margin-bottom: var(--space-xl);
}

.orders-page-header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--color-brand-green);
    letter-spacing: -0.02em;
    margin: 0 0 var(--space-xs) 0;
    line-height: 1.25;
}

.orders-page-header p {
    font-size: var(--font-size-base);
    color: var(--color-text-muted);
    margin: 0;
    line-height: 1.45;
}

/* ==========================================================================
   Apple-Style Segmented Control Filter Tabs
   ========================================================================== */
.orders-filter-wrapper {
    margin-bottom: var(--space-xl);
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 2px 2px 6px 2px;
}

.orders-filter-wrapper::-webkit-scrollbar {
    display: none;
}

.orders-segmented-control {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    padding: 4px;
    border-radius: var(--radius-pill);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
    min-width: max-content;
}

.filter-tab-btn {
    appearance: none;
    background: transparent;
    border: 1px solid transparent;
    color: var(--color-text-muted);
    font-family: inherit;
    font-size: var(--font-size-sm);
    font-weight: 600;
    padding: 0.5rem 1.15rem;
    border-radius: var(--radius-pill);
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    white-space: nowrap;
    line-height: 1.2;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.filter-tab-btn:hover:not(.active) {
    color: var(--color-brand-green);
    background: var(--color-surface-subtle, #FAF8F5);
}

.filter-tab-btn.active {
    background: var(--color-brand-green);
    color: #FFFFFF;
    box-shadow: 0 2px 8px rgba(13, 59, 46, 0.22);
}

/* ==========================================================================
   Order Feed List & Inset White Cards (16px)
   ========================================================================== */
.orders-feed {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    width: 100%;
}

.order-card {
    background: #FFFFFF;
    border: 1px solid var(--color-border);
    border-radius: 16px;
    padding: 1.25rem 1.25rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    position: relative;
    overflow: hidden;
    box-sizing: border-box;
    width: 100%;
}

.order-card:hover {
    border-color: rgba(13, 59, 46, 0.2);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.06);
}

/* Card Header */
.order-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: var(--space-sm);
    padding-bottom: var(--space-sm);
    border-bottom: 1px solid var(--color-border-light, #F0ECE4);
    flex-wrap: wrap;
}

.order-header-left {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
    flex: 1 1 auto;
}

.order-kicker {
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    line-height: 1.2;
}

.order-title {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-brand-green);
    margin: 0;
    line-height: 1.35;
    word-break: break-word;
}

/* Status Indicator with Dot */
.order-status-wrap {
    display: inline-flex;
    align-items: center;
    gap: 0.45rem;
    padding: 0.35rem 0.75rem;
    border-radius: var(--radius-pill);
    background: var(--color-surface-subtle, #FAF8F5);
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1;
    flex-shrink: 0;
    margin-left: auto;
}

.order-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Status Variations */
.order-status-completed {
    color: var(--color-brand-green);
    background: #EBF7F2;
}
.order-status-completed .order-status-dot {
    background: var(--color-brand-green);
    box-shadow: 0 0 0 2px rgba(13, 59, 46, 0.15);
}

.order-status-processing {
    color: var(--color-accent-orange);
    background: #FFF4EC;
}
.order-status-processing .order-status-dot {
    background: var(--color-accent-orange);
    box-shadow: 0 0 0 2px rgba(232, 89, 12, 0.15);
}

.order-status-pending {
    color: #B45309;
    background: #FEF3C7;
}
.order-status-pending .order-status-dot {
    background: #F59E0B;
    box-shadow: 0 0 0 2px rgba(245, 158, 11, 0.18);
}

.order-status-canceled {
    color: #B91C1C;
    background: #FEE2E2;
}
.order-status-canceled .order-status-dot {
    background: #EF4444;
    box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.15);
}

.order-status-under-review {
    color: #7C2D12;
    background: #FFEDD5;
}
.order-status-under-review .order-status-dot {
    background: #F97316;
}

/* Card Body Grid (2 cols on mobile, 4 cols on tablet+) */
.order-details-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-md);
    width: 100%;
}

.order-detail-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
    overflow: hidden;
}

.order-detail-label {
    font-size: 0.6875rem;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--color-text-muted);
    line-height: 1.2;
}

.order-detail-value {
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--color-text-main);
    word-break: break-all;
    overflow-wrap: anywhere;
    line-height: 1.35;
}

.order-detail-value a {
    color: var(--color-brand-green);
    text-decoration: underline;
    text-underline-offset: 2px;
}

.order-detail-value a:hover {
    color: var(--color-accent-orange);
}

/* Card Footer & Self-Service Actions */
.order-card-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: var(--space-sm);
    padding-top: var(--space-sm);
    border-top: 1px solid var(--color-border-light, #F0ECE4);
    flex-wrap: wrap;
}

.order-card-actions {
    display: inline-flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
    margin-left: auto;
}

.order-action-btn {
    appearance: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    padding: 0.45rem 1rem;
    border-radius: var(--radius-pill);
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.2;
    cursor: pointer;
    transition: all 0.18s ease;
    border: 1px solid var(--color-border);
    background: transparent;
    -webkit-tap-highlight-color: transparent;
    min-height: 34px;
}

/* Refill Action Button */
.order-action-refill {
    color: var(--color-brand-green);
    border-color: rgba(13, 59, 46, 0.25);
    background: #FFFFFF;
}

.order-action-refill:hover:not(:disabled) {
    background: #EBF7F2;
    border-color: var(--color-brand-green);
    color: var(--color-brand-green);
    transform: translateY(-1px);
}

/* Cancel Action Button */
.order-action-cancel {
    color: #DC2626;
    border-color: #FECACA;
    background: #FFFFFF;
}

.order-action-cancel:hover:not(:disabled) {
    background: #FEF2F2;
    border-color: #DC2626;
    color: #DC2626;
    transform: translateY(-1px);
}

/* Button Loading & Disabled States */
.order-action-btn:disabled {
    opacity: 0.65;
    cursor: not-allowed;
    transform: none !important;
}

.order-action-btn.is-success {
    background: #EBF7F2;
    color: var(--color-brand-green);
    border-color: var(--color-brand-green);
}

.order-action-btn.is-canceled-state {
    background: #FEE2E2;
    color: #B91C1C;
    border-color: #EF4444;
}

/* Mini Inline Spinner for Action Buttons */
.order-btn-spinner {
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: orderBtnSpin 0.6s linear infinite;
    display: inline-block;
    flex-shrink: 0;
}

@keyframes orderBtnSpin {
    to {
        transform: rotate(360deg);
    }
}

/* Notification/Feedback Banner inside Card */
.order-action-feedback {
    width: 100%;
    font-size: 0.78rem;
    padding: 0.4rem 0.75rem;
    border-radius: var(--radius-sm);
    margin-top: 0.25rem;
    display: none;
}

.order-action-feedback.is-error {
    display: block;
    background: #FEE2E2;
    color: #B91C1C;
    border: 1px solid #FECACA;
}

.order-action-feedback.is-success {
    display: block;
    background: #EBF7F2;
    color: var(--color-brand-green);
    border: 1px solid #A7F3D0;
}

/* ==========================================================================
   Empty State (Apple-Style Inset)
   ========================================================================== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 1.5rem;
    background: #FFFFFF;
    border-radius: 16px;
    border: 1px dashed var(--color-border);
    margin: var(--space-lg) 0;
    box-sizing: border-box;
    width: 100%;
}

.empty-state svg {
    margin: 0 auto 1.25rem auto;
    color: var(--color-text-muted);
    width: 52px;
    height: 52px;
    opacity: 0.8;
}

.empty-state h4 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--color-brand-green);
    margin: 0 0 0.5rem 0;
}

.empty-state p {
    font-size: 0.9375rem;
    color: var(--color-text-muted);
    max-width: 360px;
    margin: 0 auto 1.5rem auto;
    line-height: 1.5;
}

.empty-state .btn {
    min-width: 200px;
}

/* ==========================================================================
   Progressive Enhancement Breakpoints
   ========================================================================== */
@media (max-width: 480px) {
    .order-card {
        padding: 1rem;
    }
    .order-title {
        font-size: 0.95rem;
    }
    .order-status-wrap {
        font-size: 0.75rem;
        padding: 0.3rem 0.6rem;
    }
    .order-action-btn {
        width: 100%;
        min-height: 38px;
    }
    .order-card-actions {
        width: 100%;
    }
}

@media (min-width: 768px) {
    .orders-page-header {
        display: flex;
        justify-content: space-between;
        align-items: flex-end;
    }

    .orders-page-header h1 {
        font-size: 1.875rem;
    }

    .order-card {
        padding: 1.5rem 1.75rem;
    }

    .order-details-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: var(--space-lg);
    }

    .order-status-wrap {
        margin-left: 0;
    }
}
