/* 1. Stat Cards: Premium Elevation */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}


/* Order stats grid */
.order-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 30px;
}

.order-stats-card {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95), #fff);
    padding: 15px;
    border-radius: 16px;
    border: 1px solid var(--border);
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.05);
    transition: transform 0.22s ease, box-shadow 0.22s ease;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.order-stats-card .stat-top {
    display: flex;
    align-items: center;
    gap: 10px
}

.order-stats-card .stat-icon {
    font-size: 1.1rem;
    color: var(--brand-navy);
    background: rgba(0, 0, 0, 0.03);
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px
}

.order-stats-card .label {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 700
}

.order-stats-card .count {
    font-size: 1.9rem;
    font-weight: 700;
    color: var(--brand-navy);
    display: block
}

.order-stats-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 20px rgba(6, 15, 40, 0.09);
}


.stat-card .label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    color: var(--text-muted);
    margin-top: 8px;
    display: block;
}





/* 2. Table Controls: Sophisticated Filters */
.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    background: #FFFFFF;
    padding: 10px;
    border-radius: 16px;
    border: 1px solid rgba(10, 20, 40, 0.04);
    box-shadow: 0 6px 18px rgba(6, 15, 40, 0.04);
}

.filter-tabs {
    display: flex;
    gap: 8px;
    align-items: center;
}

.filter-pill {
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-muted);
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.18s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-pill span {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 8px;
    border-radius: 6px;
    font-size: 0.75rem;
}

.filter-pill.active {
    background: var(--brand-navy);
    color: #ffff;
    box-shadow: 0 6px 18px rgba(34, 197, 94, 0.06);
    border-color: rgba(0, 0, 0, 0.04);
}

/* Search, view toggle and small helper controls inside the table-controls */
.table-controls .left {
    display: flex;
    align-items: center;
    gap: 10px;
}

.table-search {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #FFFFFF;
    padding: 6px 8px;
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
}

.table-search .icon {
    color: var(--text-muted);
    font-size: 1rem;
    margin-left: 4px
}

.table-search input {
    border: none;
    outline: none;
    background: transparent;
    padding: 6px 8px;
    min-width: 220px;
    font-size: 0.95rem;
    color: var(--text-main);
}

.view-toggle {
    display: flex;
    gap: 8px;
    align-items: center;
}

.view-toggle .toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 10px;
    background: transparent;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all .16s ease;
}

.view-toggle .toggle-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(6, 15, 40, 0.04);
}

.view-toggle .toggle-btn.active {
    background: #FFFFFF;
    border-color: var(--border-subtle);
    box-shadow: 0 8px 20px rgba(6, 15, 40, 0.04);
}

.results-count {
    font-weight: 700;
    color: var(--text-muted);
    background: rgba(0, 0, 0, 0.03);
    padding: 6px 10px;
    border-radius: 12px;
    margin-left: 8px
}

/* Responsive adjustments for the controls */
@media (max-width: 820px) {
    .order-stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .table-controls {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .table-controls .left {
        width: 100%;
        justify-content: space-between
    }

    .table-search input {
        min-width: 140px;
    }
}

@media (max-width: 420px) {
    .order-stats-grid {
        grid-template-columns: 1fr;
    }

    .filter-tabs {
        flex-wrap: wrap;
        gap: 6px
    }

    .table-search input {
        min-width: 100px
    }
}

/* 3. The Table: Ultra-Clean & Spaced */
.orders-table-wrapper {
    background: #FFFFFF;
    border-radius: 28px;
    border: 1px solid var(--border-subtle);
    box-shadow: var(--premium-shadow);
    overflow: hidden;
}

.orders-table {
    width: 100%;
    border-collapse: collapse;
}

.orders-table thead th {
    background: var(--brand-navy);
    color: rgba(255, 255, 255, 0.9);
    text-align: left;
    padding: 20px 24px;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-weight: 800;
}

.orders-table tbody tr {
    transition: background 0.2s;
}

.orders-table tbody tr:hover {
    background: #F8FAFF;
}

.orders-table td {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    font-size: 0.89rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* Responsive: allow horizontal scroll for medium screens */
@media (max-width: 900px) {
    .orders-table-wrapper { overflow-x: auto; }
    .orders-table { min-width: 900px; }
}

/* Responsive: stacked card layout for small screens */
@media (max-width: 600px) {
    .orders-table thead { display: none; }
    .orders-table { border-collapse: separate; }
    .orders-table tbody tr { display: block; margin-bottom: 14px; border: 1px solid var(--border); border-radius: 12px; padding: 12px; background: #fff; }
    .orders-table td { display: flex; justify-content: space-between; padding: 10px 12px; border-bottom: none; }
    .orders-table td + td { margin-top: 6px; }

    .orders-table td:nth-child(1)::before { content: 'Order ID'; font-weight:700; color:var(--text-muted); margin-right:8px; }
    .orders-table td:nth-child(2)::before { content: 'Product'; font-weight:700; color:var(--text-muted); margin-right:8px; }
    .orders-table td:nth-child(3)::before { content: 'Purchased'; font-weight:700; color:var(--text-muted); margin-right:8px; }
    .orders-table td:nth-child(4)::before { content: 'Expires'; font-weight:700; color:var(--text-muted); margin-right:8px; }
    .orders-table td:nth-child(5)::before { content: 'Price'; font-weight:700; color:var(--text-muted); margin-right:8px; }
    .orders-table td:nth-child(6)::before { content: 'Status'; font-weight:700; color:var(--text-muted); margin-right:8px; }
    .orders-table td:nth-child(7)::before { content: 'Actions'; font-weight:700; color:var(--text-muted); margin-right:8px; }

    .product-info strong { font-size: 0.95rem; }
    .action-icon { width: 36px; height: 36px; }
}

.order-id {
    font-family: 'JetBrains Mono', monospace;
    /* Professional tech feel */
    font-weight: 600;
    color: var(--brand-navy);
    font-size: 0.9rem;
}

.product-info strong {
    display: block;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-main);
    margin-bottom: 1px;
}

.product-info span {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 500;
}

.price {
    font-weight: 600;
    color: var(--text-main);
    font-size: 1rem;
}

/* Status Badges: Pill Style */
.status-badge {
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.status-badge::before {
    content: '';
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-badge.active {
    background: #F1F5F9;
    color: var(--brand-teal);
    border: 1px solid var(--brand-teal);
}

.status-badge.active::before {
    background: var(--brand-teal);
}

.status-badge.expired {
    background: #ffe3dc;
    color: var(--text-muted);
}

.status-badge.expired::before {
    background: #d14f4f;
}

/* Premium Action Buttons */
.action-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    border: 1px solid var(--border-subtle);
    background: #FFFFFF;
    color: var(--brand-navy);
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 8px;
}

.action-icon:hover {
    background: var(--brand-navy);
    color: #FFFFFF;
    border-color: var(--brand-navy);
    transform: scale(1.1);
}

/* 4. Support Banner: Soft Gradient */
.support-banner {
    margin-top: 40px;
    background: linear-gradient(90deg, #F8FAFC 0%, #FFFFFF 100%);
    border: 1px dashed var(--border-subtle);
    border-radius: 20px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 20px;
}

.banner-icon {
    width: 50px;
    height: 50px;
    background: #FFFFFF;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand-navy);
    font-size: 1.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.support-banner p {
    font-size: 0.95rem;
    color: var(--text-muted);
    line-height: 1.6;
}

.support-banner strong {
    color: var(--brand-navy);
}

/* Enhanced modal visuals */
.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(12, 16, 24, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 180ms ease;
    z-index: 1200;
}
.modal.open { opacity: 1; pointer-events: auto; }
.modal .modal-dialog {
    background: linear-gradient(180deg, #ffffff, #fbfdff);
    border-radius: 14px;
    width: 600px;
    max-width: calc(100% - 40px);
    box-shadow: 0 24px 60px rgba(6, 15, 40, 0.16);
    overflow: hidden;
    transform: translateY(6px) scale(.995);
    animation: modalPop 180ms ease forwards;
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid rgba(12,18,30,0.04);
    background: linear-gradient(90deg, rgba(250,252,255,0.7), rgba(246,252,255,0.9));
}
.modal-title-wrap { display:flex; align-items:center; }
.modal-header h2 { margin: 0; font-size: 18px; font-weight:700; color:var(--brand-navy); }
.modal-body { padding: 18px; color: var(--text-muted, #333); line-height:1.55 }
.modal-body p { margin: 8px 0; }
.modal-footer { display:flex; gap:10px; justify-content:flex-end; padding:12px 16px; border-top:1px solid #f4f7fb }
.modal-close { background: transparent; border: none; font-size: 22px; cursor: pointer; color:var(--text-muted) }
.confirm-download { box-shadow: 0 8px 18px rgba(34,197,94,0.08) }
.modal .btn { padding: 8px 14px; border-radius: 10px; color: var(--text-main); font-weight: 600; transition: background 0.15s; }
body.modal-open { overflow: hidden; }

@keyframes modalPop {
    from { transform: translateY(12px) scale(.98); opacity: 0 }
    to { transform: translateY(0) scale(1); opacity: 1 }
}

/* Responsive */
@media (max-width: 520px) {
    .modal .modal-dialog { width: 94%; border-radius: 12px }
    .modal-body { padding: 12px }
}