/**
 * Retail Module Styles
 * 供應商出貨查詢系統樣式表
 *
 * 2026/01/15 paul [樓下好市集]供應商訂單零售模組_0115 [零售模組]
 */

/* === CSS Variables - Design System === */
:root {
    /* Primary Colors - Trust Blue */
    --color-primary: #3B82F6;
    --color-primary-hover: #2563EB;
    --color-primary-light: #60A5FA;

    /* CTA - Accent Orange */
    --color-cta: #F97316;
    --color-cta-hover: #EA580C;

    /* Neutral Colors */
    --color-bg: #F8FAFC;
    --color-bg-elevated: #FFFFFF;
    --color-text: #1E293B;
    --color-text-muted: #64748B;
    --color-border: #E2E8F0;
    --color-border-hover: #CBD5E1;

    /* Semantic Colors */
    --color-success: #10B981;
    --color-success-bg: #D1FAE5;
    --color-warning: #F59E0B;
    --color-warning-bg: #FEF3C7;
    --color-error: #EF4444;
    --color-error-bg: #FEE2E2;
    --color-info: #3B82F6;
    --color-info-bg: #DBEAFE;

    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 24px rgba(0, 0, 0, 0.12);

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-base: 200ms ease;
    --transition-slow: 300ms ease;

    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

/* === Reset & Base === */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Microsoft JhengHei', 'Segoe UI', 'Helvetica Neue', sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.6;
}

/* === Navbar === */
.navbar {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
    color: white;
    padding: 0 20px;
    display: flex;
    align-items: center;
    height: 60px;
    box-shadow: var(--shadow-md);
}

.navbar-brand {
    font-size: 18px;
    font-weight: bold;
    margin-right: 40px;
}

.navbar-nav {
    list-style: none;
    display: flex;
    gap: 5px;
}

.navbar-nav li a {
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
}

.navbar-nav li a:hover,
.navbar-nav li.active a {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.navbar-user {
    margin-left: auto;
    font-size: 14px;
}

/* === Container === */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 30px 20px;
}

/* === Typography === */
h1 {
    font-size: 24px;
    color: var(--color-text);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--color-primary);
}

h2 {
    font-size: 18px;
    color: var(--color-text-muted);
    margin: 25px 0 15px;
}

/* === Filter Bar === */
.filter-bar {
    background: var(--color-bg-elevated);
    padding: 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    margin-bottom: 20px;
    border: 1px solid var(--color-border);
}

.date-filter {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-wrap: wrap;
}

.date-filter label {
    font-weight: 500;
    color: var(--color-text-muted);
}

.date-filter input[type="date"],
.date-filter select {
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: border-color var(--transition-base);
}

.date-filter input[type="date"]:focus,
.date-filter select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* === Buttons === */
.btn {
    display: inline-block;
    padding: 8px 16px;
    font-size: 14px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    text-decoration: none;
    transition: all var(--transition-base);
    font-weight: 500;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-hover) 100%);
    color: white;
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    box-shadow: var(--shadow-md);
    /* Removed transform to avoid layout shift */
}

.btn-secondary {
    background: var(--color-text-muted);
    color: white;
}

.btn-secondary:hover {
    background: var(--color-text);
    box-shadow: var(--shadow-sm);
}

.btn-cta {
    background: var(--color-cta);
    color: white;
}

.btn-cta:hover {
    background: var(--color-cta-hover);
    box-shadow: var(--shadow-md);
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 12px;
}

/* === Summary Cards === */
.summary-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.summary-card {
    background: var(--color-bg-elevated);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    text-align: center;
    transition: all var(--transition-base);
}

.summary-card:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--color-primary-light);
}

.card-title {
    font-size: 14px;
    color: var(--color-text-muted);
    margin-bottom: 10px;
    font-weight: 500;
}

.card-value {
    font-size: 36px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-light) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* === Data Table === */
.data-table {
    width: 100%;
    background: var(--color-bg-elevated);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
}

.data-table th,
.data-table td {
    padding: 12px 15px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.data-table th {
    background: var(--color-bg);
    font-weight: 600;
    color: var(--color-text-muted);
    font-size: 13px;
}

.data-table tbody tr {
    transition: background-color var(--transition-fast);
}

.data-table tbody tr:hover {
    background: rgba(59, 130, 246, 0.04);
    cursor: default;
}

.data-table tbody tr:nth-child(even) {
    background: rgba(248, 250, 252, 0.5);
}

.data-table tbody tr:nth-child(even):hover {
    background: rgba(59, 130, 246, 0.06);
}

.data-table tr:last-child td {
    border-bottom: none;
}

/* Right align numeric columns */
.data-table td:last-child,
.data-table th:last-child {
    text-align: right;
}

/* Table wrapper for responsive scroll */
.data-table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* === Alerts === */
.alert {
    padding: 15px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    border: 1px solid transparent;
}

.alert-info {
    background: var(--color-info-bg);
    color: var(--color-primary-hover);
    border-color: var(--color-primary-light);
}

.alert-success {
    background: var(--color-success-bg);
    color: #065F46;
    border-color: var(--color-success);
}

.alert-error {
    background: var(--color-error-bg);
    color: #991B1B;
    border-color: var(--color-error);
}

/* === Forms === */
.form-container {
    background: var(--color-bg-elevated);
    padding: 30px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    max-width: 400px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--color-text);
}

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: 14px;
    transition: border-color var(--transition-base);
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-text {
    font-size: 12px;
    color: var(--color-text-muted);
    margin-top: 5px;
}

/* === Pagination === */
.pagination {
    display: flex;
    justify-content: center;
    gap: 5px;
    margin-top: 20px;
}

.page-link {
    padding: 8px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    text-decoration: none;
    color: var(--color-text);
    background: var(--color-bg-elevated);
    transition: all var(--transition-base);
    cursor: pointer;
}

.page-link:hover {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
    box-shadow: var(--shadow-sm);
}

.page-link.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

/* === Result Info === */
.result-info {
    margin-bottom: 15px;
    color: var(--color-text-muted);
    font-size: 14px;
}

/* === Footer === */
.footer {
    text-align: center;
    padding: 20px;
    color: var(--color-text-muted);
    font-size: 12px;
    margin-top: 30px;
}

/* === Accordion / Expand Button === */
.expand-btn {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: color var(--transition-base);
    font-weight: 500;
    color: var(--color-text);
}

.expand-btn:hover {
    color: var(--color-primary);
}

.expand-btn .icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: 2px solid currentColor;
    border-radius: var(--radius-sm);
    font-weight: bold;
    font-size: 14px;
    line-height: 1;
    transition: transform var(--transition-base);
}

/* Rotate icon when expanded */
.expand-btn[aria-expanded="true"] .icon {
    transform: rotate(90deg);
}

/* Details row - use display for table rows (max-height doesn't work on tr) */
.details-row {
    display: none;
    background-color: rgba(248, 250, 252, 0.5);
}

.details-row.expanded {
    display: table-row;
}

.details-row td {
    border-top: none;
}

.details-container {
    padding: 15px;
    border: 1px solid var(--color-border);
    border-top: none;
    background: var(--color-bg-elevated);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

/* === Loading Spinner === */
.loading-text {
    color: var(--color-text-muted);
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 8px;
}

.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* === Date Group Header === */
.date-group {
    margin-bottom: 20px;
}

.date-group-header {
    background-color: var(--color-bg);
    padding: 12px 16px;
    margin: 0 0 12px 0;
    border-left: 4px solid var(--color-primary);
    border-radius: var(--radius-sm);
    font-weight: 600;
    color: var(--color-text);
    font-size: 15px;
}

/* === Section Header === */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.action-buttons {
    display: flex;
    gap: 8px;
}

/* === Text Utilities === */
.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

/* === Responsive === */
@media (max-width: 768px) {
    .navbar {
        flex-wrap: wrap;
        height: auto;
        padding: 10px 15px;
    }

    .navbar-nav {
        order: 3;
        width: 100%;
        margin-top: 10px;
        flex-wrap: wrap;
    }

    .date-filter {
        flex-direction: column;
        align-items: stretch;
    }

    .date-filter input[type="date"] {
        width: 100%;
    }

    /* Table responsive scroll */
    .data-table {
        min-width: 600px;
    }

    .summary-cards {
        grid-template-columns: 1fr;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
