/**
 * Orders Management Styles
 * 
 * Imports unified table styles and provides orders-specific styling.
 * Shared table styling is in ../css/shared-tables.css
 * 
 * Table of Contents:
 * 1. CSS Variables & Defaults
 * 2. Dashboard Layout
 * 3. Tab Navigation
 * 4. Order Card Styling
 * 5. Status Badges & Colors
 * 6. Order Forms & Inputs
 * 7. Order Items List
 * 8. Order Details Modal
 * 9. Order Items Table
 * 10. Order Status History
 * 11. Buttons
 * 12. Messages & States
 * 13. Responsive Design
 * 14. Utility Classes
 */

@import url('../../css/shared-tables.css');

/* ============================================================
   1. CSS VARIABLES & DEFAULTS
   ============================================================ */
:root {
    --primary-color: #1ec677;
    --primary-dark: #17a659;
    --text-color: #23282d;
    --border-color: #e0e0e0;
    --bg-light: #f9f9f9;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* ============================================================
   2. DASHBOARD LAYOUT
   ============================================================ */

.orders-dashboard {
    background: #fff;
    padding: 0;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin: 20px 0;
}

.orders-dashboard .search-filter-bar {
    padding: 25px;
    padding-bottom: 0;
    margin-bottom: 0;
}

.orders-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: #fff;
    border-radius: 8px 8px 0 0;
}

.orders-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.orders-header .button {
    margin: 0;
}

/* ============================================================
   3. TAB NAVIGATION
   ============================================================ */

.orders-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    background: var(--bg-light);
    padding: 0 25px;
    gap: 5px;
}

.tab-button {
    padding: 15px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
    margin: 0;
}

.tab-button:hover {
    color: var(--primary-color);
}

.tab-button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.orders-container {
    padding: 25px;
    min-height: 400px;
}

/* ============================================================
   4. ORDER CARD STYLING
   ============================================================ */

.orders-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(500px, 1fr));
    gap: 20px;
    margin-top: 20px;
}

.order-card {
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    transition: all 0.3s ease;
    box-shadow: var(--shadow);
}

.order-card:hover {
    box-shadow: var(--shadow-hover);
    border-color: var(--primary-color);
}

.order-card-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.order-number {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin: 0;
}

.order-info {
    margin-bottom: 15px;
}

.order-info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 14px;
    color: #666;
}

.order-info-label {
    font-weight: 600;
    color: #333;
}

.order-customer {
    font-size: 16px;
    font-weight: 600;
    color: #333;
    margin-bottom: 8px;
}

.order-items-count {
    font-size: 13px;
    color: #999;
    padding: 8px 0;
}

.order-card-actions {
    display: flex;
    gap: 10px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.order-card-actions .button {
    flex: 1;
    padding: 8px 12px;
    font-size: 13px;
    text-align: center;
}

/* ============================================================
   5. STATUS BADGES & COLORS
   ============================================================ */

.badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    background: #f5f5f5;
    color: #666;
    display: inline-block;
}

.status-badge,
.order-status-badge {
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    display: inline-block;
}

.status-badge.draft,
.order-status-badge.draft {
    background: #f5f5f5;
    color: #999;
}

.status-badge.waiting_for_warehouse_invoice,
.order-status-badge.waiting_for_warehouse_invoice {
    background: #f3e5f5;
    color: #7b1fa2;
}

.status-badge.warehouse_invoice_ready,
.order-status-badge.warehouse_invoice_ready {
    background: #e3f2fd;
    color: #1565c0;
}

.status-badge.pending,
.order-status-badge.pending {
    background: #e3f2fd;
    color: #1976d2;
}

.status-badge.packing,
.order-status-badge.packing {
    background: #fff3e0;
    color: #f57c00;
}

.status-badge.shipment_ready,
.order-status-badge.shipment_ready {
    background: #f1f8e9;
    color: #558b2f;
}

.status-badge.shipped,
.order-status-badge.shipped {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-badge.cancelled,
.order-status-badge.cancelled {
    background: #ffebee;
    color: #c62828;
}

/* ============================================================
   6. ORDER FORMS & INPUTS
   ============================================================ */

.form-section {
    margin-bottom: 30px;
    padding: 20px;
    background: var(--bg-light);
    border-radius: 6px;
    border-left: 4px solid var(--primary-color);
}

.form-section h4 {
    margin: 0 0 15px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.section-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.section-header .button-small {
    padding: 6px 12px;
    font-size: 13px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.form-group strong {
    color: #000;
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    transition: all 0.3s;
    background: #fff;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(30, 198, 119, 0.1);
}

.form-control small {
    display: block;
    margin-top: 5px;
    color: #999;
    font-size: 12px;
}

/* ============================================================
   7. ORDER ITEMS LIST
   ============================================================ */

.order-items-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.order-item-row {
    display: grid;
    grid-template-columns: 1.5fr 1fr 0.8fr 80px;
    gap: 12px;
    align-items: end;
    padding: 15px;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 6px;
}

.order-item-row .form-group {
    margin-bottom: 0;
}

.order-item-row .form-group label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 5px;
    color: #666;
}

.order-item-row .form-control {
    width: 100%;
}

.order-item-row .remove-item-btn {
    padding: 8px 12px;
    background: #ff6b6b;
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

.order-item-row .remove-item-btn:hover {
    background: #d63031;
}

/* ============================================================
   8. ORDER DETAILS MODAL
   ============================================================ */

.order-details-container {
    padding: 0;
}

.order-details-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: #fff;
    padding: 20px;
    margin: -30px -30px 20px -30px;
    border-radius: 0;
}

.order-details-header h3 {
    margin: 0 0 10px 0;
    font-size: 22px;
}

.order-details-header .order-status-info {
    font-size: 13px;
    opacity: 0.9;
}

/* Order Sections */
.order-section {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.order-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.order-section h4 {
    margin: 0 0 15px 0;
    font-size: 15px;
    font-weight: 600;
    color: #333;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Order Details Table */
.order-details-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.order-details-table tr {
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s ease;
}

.order-details-table tr:last-child {
    border-bottom: none;
}

.order-details-table tr:hover {
    background-color: rgba(30, 198, 119, 0.03);
}

.order-details-table td {
    padding: 14px 16px;
    font-size: 14px;
    line-height: 1.6;
}

.order-details-table .label {
    font-weight: 600;
    color: #23282d;
    width: 35%;
    vertical-align: top;
    background-color: #f9f9f9;
    min-width: 150px;
}

.order-details-table .value {
    color: #666;
    word-break: break-word;
    vertical-align: top;
}

.order-details-table .value a {
    color: var(--primary-color);
    text-decoration: none;
}

.order-details-table .value a:hover {
    text-decoration: underline;
}

/* Legacy support */
.details-table {
    width: 100%;
    margin-bottom: 30px;
}

.details-table tr {
    border-bottom: 1px solid var(--border-color);
}

.details-table td {
    padding: 12px 0;
    font-size: 14px;
}

.details-table .label {
    font-weight: 600;
    color: #333;
    width: 30%;
    vertical-align: top;
}

.details-table .value {
    color: #666;
    word-break: break-word;
}

/* ============================================================
   9. ORDER ITEMS TABLE
   ============================================================ */

.order-items-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    background: #fff;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    overflow: hidden;
}

.order-items-table thead {
    background: linear-gradient(135deg, #f8f9fa 0%, #f0f1f2 100%);
    border-bottom: 2px solid var(--border-color);
}

.order-items-table th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    color: #23282d;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.order-items-table tbody tr {
    transition: all 0.2s ease;
}

.order-items-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    color: #666;
}

.order-items-table tbody tr:last-child td {
    border-bottom: none;
}

.order-items-table td.qty-cell {
    text-align: center;
    font-weight: 600;
    color: #23282d;
    background-color: rgba(30, 198, 119, 0.05);
}

.order-items-table tbody tr:hover {
    background: rgba(30, 198, 119, 0.05);
}

.order-items-table tbody tr:hover td.qty-cell {
    background-color: rgba(30, 198, 119, 0.1);
}

/* ============================================================
   10. ORDER STATUS HISTORY
   ============================================================ */

.status-history {
    margin: 0;
    padding: 0;
}

.status-history h4 {
    margin: 0 0 20px 0;
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.history-item {
    margin-bottom: 15px;
    padding: 15px;
    background: #f9f9f9;
    border-left: 3px solid var(--primary-color);
    border-radius: 4px;
}

.history-item .status-transition {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 5px;
}

.history-item .history-time {
    font-size: 12px;
    color: #999;
    margin-bottom: 3px;
}

.history-item .history-user {
    font-size: 12px;
    color: #666;
    font-weight: 500;
    margin-bottom: 8px;
}

.history-item .history-notes {
    font-size: 13px;
    color: #555;
    padding: 10px;
    border-top: 1px solid #ddd;
    margin-top: 10px;
    padding-top: 10px;
    border-top: none;
}

.history-item .history-tracking {
    font-size: 12px;
    color: #555;
    padding: 10px 0 0 0;
    border-top: 1px solid #ddd;
    margin-top: 10px;
    padding-top: 10px;
    line-height: 1.6;
}

.history-item::before {
    content: '';
    position: absolute;
    left: -37px;
    top: 4px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary-color);
    border: 3px solid #fff;
}

.history-item:last-child {
    padding-bottom: 0;
}

.history-status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.history-status-badge {
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    background: #f5f5f5;
    color: #666;
}

.history-time {
    font-size: 12px;
    color: #999;
    font-weight: 600;
}

.history-user {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

.history-notes {
    font-size: 13px;
    color: #666;
    margin-top: 8px;
    padding: 10px;
    background: var(--bg-light);
    border-radius: 4px;
    border-left: 3px solid var(--primary-color);
}

.history-tracking {
    font-size: 12px;
    color: #666;
    margin-top: 8px;
    padding: 10px;
    background: #f0f8ff;
    border-radius: 4px;
    border-left: 3px solid #0066cc;
}

/* ============================================================
   11. BUTTONS
   ============================================================ */

.button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
    display: inline-block;
    text-align: center;
    text-decoration: none;
    background: #e0e0e0;
    color: #333;
}

.button:hover {
    background: #d0d0d0;
}

.button.button-primary {
    background: var(--primary-color);
    color: #fff;
}

.button.button-primary:hover {
    background: var(--primary-dark);
}

.button.button-small {
    padding: 6px 12px;
    font-size: 13px;
}

.button.button-large {
    padding: 12px 24px;
    font-size: 15px;
    width: 100%;
}

.button.button-danger {
    background: #ff6b6b;
    color: #fff;
}

.button.button-danger:hover {
    background: #d63031;
}

.button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Button Loading Spinner - Inline spinner within button */
.button-loading-spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: button-spinner 0.8s linear infinite;
    vertical-align: middle;
}

@keyframes button-spinner {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================================
   12. MESSAGES & STATES
   ============================================================ */

.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #999;
}

.empty-state p {
    margin: 0;
    font-size: 16px;
}

.error-message {
    background: #ffebee;
    color: #c62828;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
    border-left: 4px solid #c62828;
}

.success-message {
    background: #e8f5e9;
    color: #2e7d32;
    padding: 15px;
    border-radius: 4px;
    margin-bottom: 20px;
    border-left: 4px solid #2e7d32;
}

.info-box {
    background: #e3f2fd;
    color: #1976d2;
    padding: 15px;
    border-radius: 4px;
    border-left: 4px solid #1976d2;
}

.info-box p {
    margin: 0 0 10px 0;
}

.info-box ol {
    margin: 0;
    padding-left: 20px;
}

.info-box li {
    margin-bottom: 5px;
}

/* ============================================================
   13. RESPONSIVE DESIGN
   ============================================================ */

@media (max-width: 768px) {
    .orders-list {
        grid-template-columns: 1fr;
    }

    .order-item-row {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .orders-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }

    .orders-header h2 {
        font-size: 20px;
    }

    .orders-header .button {
        width: 100%;
    }

    .orders-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
    }

    .tab-button {
        white-space: nowrap;
        padding: 12px 15px;
    }
}

/* ============================================================
   14. UTILITY CLASSES
   ============================================================ */

.text-center {
    text-align: center;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

/* ============================================================
   PAYMENT MODAL
   ============================================================ */

.payment-info-section {
    background: #fff;
}

.payment-info-row {
    padding: 10px 0;
}

.payment-info-row label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #666;
    margin-bottom: 5px;
}

.payment-info-row strong {
    font-size: 16px;
    color: #333;
}

#payment-amount-display {
    font-size: 32px !important;
    font-weight: bold !important;
    color: #1ec677 !important;
    margin-top: 10px;
}

#payment-invoice-details {
    background: #f9f9f9;
    padding: 15px;
    border-radius: 5px;
    border-left: 4px solid #1ec677;
    margin-top: 10px;
    line-height: 1.6;
    font-size: 14px;
    color: #333;
}

/* ============================================================
   LOADING INDICATOR
   ============================================================ */

.loading-indicator {
    text-align: center;
    padding: 50px 20px;
    color: var(--primary-color);
    font-weight: 500;
}

.loading-indicator .spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    margin-bottom: 15px;
}

.loading-indicator .spinner::after {
    content: '';
    display: block;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 4px solid var(--primary-color);
    border-color: var(--primary-color) transparent var(--primary-color) transparent;
    animation: spinner 1.2s linear infinite;
}

@keyframes spinner {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.loading-indicator p {
    margin: 0;
    font-size: 16px;
}