/* =================================
   PREMIUM ORDERS PAGE STYLES (v3.1 - Final Refined)
   ================================= */
:root {
    --bg-main: #f8fafc;
    --bg-panel: #ffffff;
    --primary-color: #A3C86C; /* Fresh Avocado Green */
    --primary-dark: #7D9A4D; /* Deep Olive Green */
    --accent-color: #FF5722; /* Price Color */
    --text-primary: #2c3e50; /* Richer dark text */
    --text-secondary: #7f8c8d;
    --text-light: #aeb6bf;
    --border-color: #e2e8f0;
    --border-light: #f1f5f9;
    --shadow: 0 4px 10px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 8px 20px rgba(0, 0, 0, 0.1);
    --radius: 12px;
    --radius-lg: 16px;
    --font-family: 'Poppins', sans-serif;
}

* {
    box-sizing: border-box;
}

body {
    background: var(--bg-main);
    color: var(--text-primary);
    overflow-x: hidden; 
}

.orders-page-container {
    max-width: 900px;
    margin: 3rem auto 5rem;
    padding: 0 1.5rem;
}

/* Header */
.page-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary-dark);
    margin-bottom: 0.5rem;
}

.page-header p {
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
}

/* Search Bar (Removed) */
.search-filter-section {
    display: block; 
    margin-bottom: 2rem;
}

.search-box {
    position: relative;
}

.search-box i {
    left: 1rem;
    color: var(--text-secondary);
    transition: color 0.3s ease;
}

.search-box input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 0.95rem;
    background: var(--bg-panel);
    color: var(--text-primary);
    transition: all 0.3s ease;
    min-height: 52px;
    box-shadow: var(--shadow);
}
.search-box input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(163, 200, 108, 0.3);
}


/* Statistics Cards - CORE FIX APPLIED HERE */
.orders-stats {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
    flex-wrap: nowrap; /* ★ FIX: Prevents cards from wrapping to a new line ★ */
    overflow-x: auto; /* Allows horizontal scroll on very small screens if needed */
    padding-bottom: 5px; /* Space for scrollbar */
}

.stat-card {
    background: var(--bg-panel);
    padding: 1.5rem;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow);
    flex: 1 1 0; /* ★ FIX: Ensures equal distribution and forces side-by-side ★ */
    min-width: 150px; /* Minimum width to prevent crushing */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-hover);
}

.stat-icon {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary-color) 100%); 
    flex-shrink: 0;
}

.stat-info h3 {
    font-size: 2rem;
    font-weight: 700;
    margin: 0;
}

.stat-info p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin: 0;
}

/* Order Card - Refined Aesthetics */
.orders-list {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.order-card {
    background: var(--bg-panel);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-light);
    transition: all 0.3s ease;
    cursor: pointer;
}

.order-card:hover {
    transform: translateY(-2px);
    border-color: var(--primary-color);
    box-shadow: 0 4px 15px rgba(125, 154, 77, 0.1);
}

.order-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px dashed var(--border-color);
}

.order-id {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary-dark);
}

.order-date {
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
}

.order-status {
    padding: 0.4rem 1rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: 1px solid transparent;
}

.status-completed { background: #d1f3e0; color: #10b981; border-color: #a7f3d0; }
.status-processing { background: #fffbe6; color: #f59e0b; border-color: #fde68a; }
.status-cancelled { background: #ffe4e6; color: #ef4444; border-color: #fecaca; }
.status-received { background: #e0f2f1; color: #008080; border-color: #b2dfdb; }

/* Order Details Grid */
.order-details-grid {
    grid-template-columns: 1.5fr 1fr 1.5fr; 
    gap: 1.5rem; 
    align-items: center;
}

.items-summary {
    font-size: 0.95rem; 
    color: var(--text-secondary);
}

.items-summary .item-count {
    font-weight: 700;
    color: var(--text-primary);
    display: block;
    font-size: 1.1rem;
    margin-bottom: 0.25rem;
}

.items-summary .item-names {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: block;
}

.order-type-info {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-align: center;
}
.order-type-info strong {
    display: block;
    color: var(--text-primary);
    font-size: 1rem;
    margin-bottom: 0.2rem;
}

.amount-summary {
    text-align: right;
}

.amount-summary .order-total {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-color);
    margin: 0;
}

.amount-summary .discount {
    font-size: 0.8rem;
    color: #10b981; 
}

/* Empty/Loading/Error States */
.loading-state, .empty-state, .error-state {
    text-align: center;
    padding: 4rem 2rem;
}
.loading-state .spinner {
    width: 48px;
    height: 48px;
    border: 3px solid var(--border-light);
    border-left: 3px solid var(--primary-dark);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1.5rem;
}
@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

.empty-state i { font-size: 4rem; margin-bottom: 1.5rem; color: var(--primary-light); opacity: 0.7; }
.empty-state h3 { font-size: 1.5rem; margin-bottom: 1rem; color: var(--text-primary);}
.action-button { background: var(--primary-dark); color: white; padding: 1rem 2rem; border-radius: var(--radius); text-decoration: none; display: inline-block; font-weight: 600; }

/* Responsive Design */
@media (max-width: 768px) {
    .orders-page-container { margin: 1rem auto; padding: 0 1rem; }
    .page-header h1 { font-size: 2rem; }
    
    .search-filter-section { 
        padding-bottom: 1rem; 
    } 
    .search-box {
        max-width: 100%;
    }
    
    /* FIX: Ensure cards stay side-by-side even on small screens */
    .orders-stats { 
        flex-direction: row; /* Ensure it stays a row */
    } 
    
    .stat-card { 
        /* Ensure card fills available width and shrinks equally */
        flex: 1 1 0; 
        min-width: 45%; 
    }
    
    /* Order card changes on small screen */
    .order-card { padding: 1rem; }
    
    .order-details-grid { 
        grid-template-columns: 1fr; 
        gap: 0.8rem; 
    }
    .items-summary { text-align: left; }
    .order-type-info { text-align: left; }
    .amount-summary { text-align: right; }
    .order-header { flex-direction: column; align-items: flex-start; gap: 0.5rem; }
    .order-header .order-status { 
        align-self: flex-end; 
        margin-top: -30px; 
    }
}


/* --- MODAL STYLES --- */
.modal-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.6); z-index: 2000; display: flex; align-items: center; justify-content: center; opacity: 0; visibility: hidden; transition: all 0.3s ease; }
.modal-overlay.active { opacity: 1; visibility: visible; }
.modal-content { background: var(--bg-panel); width: 90%; max-width: 500px; max-height: 80vh; border-radius: var(--radius); overflow-y: auto; transform: scale(0.9); transition: all 0.3s ease; }
.modal-overlay.active .modal-content { transform: scale(1); }
.modal-header { display: flex; justify-content: space-between; align-items: center; padding: 15px; border-bottom: 1px solid var(--border-color); background: var(--bg-panel); }
.modal-header h3 { margin: 0; font-size: 1.2rem; color: var(--primary-dark);}
.modal-close-btn { background: none; border: none; font-size: 1.5rem; cursor: pointer; color: var(--text-secondary); }
.modal-body { padding: 20px; }
.detail-group { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 20px; }
.detail-item { background: var(--bg-main); padding: 10px; border-radius: 8px; border: 1px solid var(--border-color); }
.detail-item h5 { margin: 0 0 5px 0; font-size: 0.8rem; color: var(--text-secondary); }
.detail-item p { margin: 0; font-weight: 600; color: var(--text-primary); }
.detail-section { margin-bottom: 20px; }
.detail-section h4 { margin: 0 0 10px 0; font-size: 1.1rem; color: var(--primary-dark); border-bottom: 1px solid var(--border-color); padding-bottom: 5px; }
.order-item-list { list-style: none; padding: 0; }
.order-item-list li { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--border-color); font-size: 0.95rem; }
.order-item-list li:last-child { border-bottom: none; }
.order-summary-details p { display: flex; justify-content: space-between; margin: 8px 0; }
.order-summary-details p strong { font-weight: 700; color: var(--accent-color); }