:root {
    --primary-red: #D32F2F;
    --light-red: #FFEBEE;
    --white: #ffffff;
    --border: #ddd;
    --text-dark: #333;
}

* { box-sizing: border-box; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
    color: var(--text-dark);
    margin: 0;
    padding: 0;
}

header {
    background-color: var(--primary-red);
    color: var(--white);
    padding: 1rem 2rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}
header h1 { margin: 0; font-size: 1.5rem; }
header .subtitle { font-size: 0.9rem; opacity: 0.9; }

.container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 20px;
}

.card {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.step-title-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}
.step-title-row .step-title {
    color: var(--primary-red);
    font-size: 1.1rem;
    font-weight: bold;
    border-left: 4px solid var(--primary-red);
    padding-left: 10px;
    margin-bottom: 0;
}

/* Standalone step title (used outside step-title-row) */
.step-title {
    color: var(--primary-red);
    font-size: 1.1rem;
    font-weight: bold;
    border-left: 4px solid var(--primary-red);
    padding-left: 10px;
    margin-bottom: 15px;
}
.btn-switch {
    background-color: #fff;
    border: 2px solid var(--primary-red);
    color: var(--primary-red);
    padding: 6px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: bold;
    text-decoration: none;
    transition: all 0.2s;
}
.btn-switch:hover {
    background-color: var(--primary-red);
    color: white;
}

select {
    padding: 10px 14px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
    background-color: #fff;
    min-width: 180px;
    max-width: 200px;
    flex-shrink: 0;
}

/* Excel-style table */
.excel-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.excel-table th {
    background-color: var(--primary-red);
    color: white;
    padding: 10px 6px;
    text-align: center;
    font-size: 0.8rem;
    position: sticky;
    top: 0;
    z-index: 10;
}
.excel-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #eee;
    text-align: center;
    vertical-align: middle;
}
.excel-table tr:hover td {
    background-color: #fafafa;
}

.excel-table input[type="number"],
.excel-table input[type="date"] {
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 0.85rem;
    width: 100%;
}
.excel-table input[type="number"]:focus,
.excel-table input[type="date"]:focus {
    border-color: var(--primary-red);
    outline: none;
}

.sku-cell {
    text-align: left;
    font-weight: 600;
    font-size: 0.9rem;
    white-space: nowrap;
}
.sku-cell .sku-cn {
    font-weight: normal;
    color: #888;
    font-size: 0.8rem;
}
.sku-cell .sku-size {
    font-weight: bold;
    color: var(--primary-red);
    font-size: 0.85rem;
}

/* Mobile responsive: make SKU column compact */
@media (max-width: 600px) {
    .excel-table th:first-child {
        width: 90px !important;
        min-width: 90px;
        padding: 8px 4px !important;
        font-size: 0.7rem;
    }
    .excel-table td:first-child {
        width: 90px;
        min-width: 90px;
        max-width: 90px;
        padding: 6px 4px;
    }
    .sku-cell {
        white-space: normal;
        font-size: 0.75rem;
        line-height: 1.3;
        word-break: break-word;
    }
    .sku-cell .sku-cn {
        font-size: 0.7rem;
    }
    .sku-cell .sku-size {
        font-size: 0.75rem;
    }
    .item-num {
        font-size: 0.7rem;
    }
    .input-stack {
        min-width: auto;
        gap: 4px;
    }
    .input-stack .input-row {
        gap: 4px;
    }
    .input-stack .input-row .field-label {
        width: 36px;
        font-size: 0.7rem;
    }
    .excel-table input[type="number"],
    .excel-table input[type="date"] {
        padding: 4px 5px;
        font-size: 0.8rem;
    }
    .btn-submit-cell {
        padding: 6px 14px;
        font-size: 0.8rem;
    }
}

.size-cell {
    font-size: 0.85rem;
    color: #555;
    font-weight: 600;
}

.cat-header-row {
    background-color: #f0f0f0;
    font-weight: bold;
    font-size: 0.9rem;
    color: #555;
}
.cat-header-row td {
    padding: 8px 10px;
    border-top: 2px solid #ccc;
    text-align: left;
}

.input-stack {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 140px;
}
.input-stack .input-row {
    display: flex;
    gap: 6px;
    align-items: center;
}
.input-stack .input-row input {
    flex: 1;
}
.input-stack .input-row .field-label {
    font-size: 0.75rem;
    color: #666;
    width: 42px;
    text-align: right;
    flex-shrink: 0;
    font-weight: 600;
}

.btn-submit-cell {
    background-color: var(--primary-red);
    color: white;
    border: none;
    padding: 8px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
    display: block;
    margin: 0 auto;
}
.btn-submit-cell:hover { background-color: #b71c1c; }

.btn-sort {
    background-color: #fff;
    border: 1px solid var(--primary-red);
    color: var(--primary-red);
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: bold;
}
.btn-sort:hover, .btn-sort.active {
    background-color: var(--primary-red);
    color: white;
}

.btn-confirm {
    background-color: var(--primary-red);
    color: white;
    border: none;
    padding: 12px 40px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: background 0.3s;
}
.btn-confirm:hover:not(:disabled) { background-color: #b71c1c; }
.btn-confirm:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

.collapse-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
    color: var(--primary-red);
    padding: 0;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.collapse-btn::before {
    content: '\25BC';
    font-size: 0.7rem;
    transition: transform 0.2s;
}
.collapse-btn.collapsed::before {
    content: '\25B6';
}
tr.collapsed { display: none; }

.item-num {
    color: var(--primary-red);
    font-weight: bold;
    font-size: 0.85rem;
    margin-right: 4px;
}

/* Data Table */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
    font-size: 0.9rem;
}
.data-table th {
    background-color: var(--primary-red);
    color: white;
    padding: 10px;
    text-align: left;
}
.data-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border);
}
.data-table tr:nth-child(even) { background-color: #fafafa; }

.badge-retailer {
    background-color: #eee;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
}

.table-wrapper {
    max-height: 70vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 4px;
}

.empty-msg {
    text-align: center;
    color: #999;
    padding: 40px;
    font-size: 1rem;
}

/* ===== pro.input.html styles (merged) ===== */

.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group label {
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: #666;
    font-weight: bold;
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 1rem;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary-red);
    outline: none;
}

.radio-group {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
}

.radio-option {
    position: relative;
    width: 100%;
}

.radio-option input[type="radio"] {
    display: none;
}

.radio-option label {
    display: block;
    width: 100%;
    padding: 8px 4px;
    background-color: #eee;
    border: 1px solid #ccc;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    margin-bottom: 0;
    text-align: center;
    box-sizing: border-box;
}

.radio-option input[type="radio"]:checked + label {
    background-color: var(--primary-red);
    color: white;
    border-color: var(--primary-red);
    font-weight: bold;
}

.btn-group {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

#productSection {
    opacity: 0.5;
    pointer-events: none;
    transition: opacity 0.3s;
}
#productSection.active {
    opacity: 1;
    pointer-events: auto;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: background 0.3s;
}
.btn-primary {
    background-color: var(--primary-red);
    color: white;
}
.btn-primary:hover {
    background-color: #b71c1c;
}
.btn-secondary {
    background-color: #eee;
    color: #333;
}
.btn-secondary:hover {
    background-color: #ddd;
}

.section-title {
    color: var(--primary-red);
    border-bottom: 2px solid var(--light-red);
    padding-bottom: 10px;
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.1rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--light-red);
    margin-bottom: 15px;
}
.section-header .section-title {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 10px;
}
.section-header .clear-btn {
    background: none;
    border: 1px solid var(--primary-red);
    color: var(--primary-red);
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: bold;
    transition: all 0.2s;
}
.section-header .clear-btn:hover {
    background: var(--primary-red);
    color: white;
}

.action-btn {
    color: var(--primary-red);
    cursor: pointer;
    border: none;
    background: none;
    font-weight: bold;
}

.table-container {
    overflow-x: auto;
}

/* ===== Sliding Menu ===== */
#menuOverlay {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 998;
}
#menuOverlay.active { display: block; }

#menuPanel {
    position: fixed;
    top: 0; right: 0;
    width: 260px;
    height: 100%;
    background: #fff;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 999;
    overflow-y: auto;
}
#menuPanel.active { transform: translateX(0); }

.menu-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 2px solid var(--light-red);
    background: var(--primary-red);
    color: white;
}
.menu-header h3 { margin: 0; font-size: 1.1rem; }
.menu-close {
    background: none; border: none; color: white;
    font-size: 1.5rem; cursor: pointer;
}
.menu-user-top {
    display: flex;
    align-items: center;
    gap: 8px;
}
.menu-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}
.menu-header .menu-logout-btn {
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.4);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    text-decoration: none;
    font-size: 0.8rem;
    cursor: pointer;
}
.menu-header .menu-logout-btn:hover {
    background: rgba(255,255,255,0.3);
}
.menu-user-top .user-role {
    color: rgba(255,255,255,0.9);
    font-weight: bold;
    font-size: 0.75rem;
    text-transform: uppercase;
}

.menu-body { padding: 10px 0; }
.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    color: var(--text-dark);
    text-decoration: none;
    font-size: 1rem;
    transition: background 0.2s;
    border-bottom: 1px solid #f0f0f0;
}
.menu-item:hover {
    background: var(--light-red);
    color: var(--primary-red);
}
.menu-item .menu-icon {
    font-size: 1.2rem;
    width: 28px;
    text-align: center;
}
.menu-item.active {
    background: #fff0f0;
    color: var(--primary-red);
    font-weight: bold;
    border-left: 4px solid var(--primary-red);
    padding-left: 16px;
}

.menu-btn {
    position: fixed;
    top: 16px;
    right: 20px;
    z-index: 997;
    background: transparent;
    border: none;
    color: var(--white);
    font-size: 1.6rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}
.menu-btn:hover { background: rgba(255,255,255,0.15); }

.menu-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    padding: 15px 20px;
    background: #fafafa;
    border-top: 2px solid var(--light-red);
}
.menu-user {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-dark);
}
.menu-user .user-role {
    color: var(--primary-red);
    font-weight: bold;
    font-size: 0.75rem;
    text-transform: uppercase;
}
.menu-logout-btn {
    background: none;
    border: none;
    color: var(--primary-red);
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: underline;
}
.menu-logout-btn:hover { color: #b71c1c; }

/* --- OCR Module Styles --- */
.ocr-upload-area {
    text-align: center;
    padding: 20px;
    border: 2px dashed var(--border);
    border-radius: 8px;
    margin-bottom: 15px;
    background: #fafafa;
}
.btn-ocr-camera {
    background: var(--primary-red);
    color: white;
    border: none;
    padding: 14px 28px;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-ocr-camera:hover { background: #b71c1c; }
.btn-ocr-gallery {
    background: #fff;
    color: var(--primary-red);
    border: 2px solid var(--primary-red);
    padding: 14px 28px;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 0;
    min-width: 120px;
    width: 100%;
}
.btn-ocr-gallery:hover {
    background: var(--primary-red);
    color: white;
}
.ocr-hint {
    margin-top: 10px;
    font-size: 0.85rem;
    color: #666;
}

.ocr-preview-area {
    margin-bottom: 15px;
    text-align: center;
}
.ocr-preview-area img {
    max-width: 100%;
    max-height: 300px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.ocr-progress-area {
    margin-bottom: 15px;
}
.ocr-progress-bar-track {
    width: 100%;
    height: 20px;
    background: #eee;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 8px;
}
.ocr-progress-bar-fill {
    height: 100%;
    width: 5%;
    background: var(--primary-red);
    border-radius: 10px;
    transition: width 0.3s ease;
}
.ocr-progress-text {
    font-size: 0.9rem;
    color: #666;
    text-align: center;
}

.ocr-result-area textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 1rem;
    resize: vertical;
    min-height: 80px;
    margin-bottom: 15px;
}

.ocr-parsed-section {
    margin-bottom: 15px;
}
.ocr-parsed-title {
    font-size: 1rem;
    font-weight: bold;
    color: var(--primary-red);
    margin-bottom: 10px;
    border-left: 4px solid var(--primary-red);
    padding-left: 10px;
}
.ocr-parsed-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.ocr-parsed-item {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 12px 16px;
}
.ocr-item-header {
    margin-bottom: 8px;
    font-size: 1rem;
}
.ocr-item-fields {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}
.ocr-field-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.ocr-field-group label {
    font-size: 0.8rem;
    color: #666;
}
.ocr-field-group input[type="number"],
.ocr-field-group input[type="date"] {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem;
}

@media (max-width: 768px) {
    .form-grid {
        grid-template-columns: 1fr;
    }
    header {
        flex-direction: column;
        align-items: flex-start;
    }
    .menu-btn { top: 12px; right: 12px; font-size: 1.4rem; }
    #menuPanel { width: 220px; }
}

/* Admin Navigation Submenu Styles */
.admin-nav-parent {
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.admin-nav-parent:hover {
    background: #f5f5f5;
    color: var(--primary-red);
}

.admin-nav-arrow {
    margin-left: auto;
    transition: transform 0.3s;
    font-size: 0.8rem;
}

.admin-nav-parent.submenu-open .admin-nav-arrow {
    transform: rotate(90deg);
}

.admin-nav-submenu {
    display: none;
    background: #f9f9f9;
    padding-left: 20px;
}

.admin-nav-submenu.submenu-open {
    display: block;
}

.admin-nav-subitem {
    padding: 10px 20px;
    font-size: 0.9rem;
    border-left: none;
}

.admin-nav-subitem:hover {
    background: #f0f0f0;
    color: var(--primary-red);
}

.admin-nav-subitem.active {
    background: #fff0f0;
    color: var(--primary-red);
}
