/* ============================================================
   SYND SYNC — Sidebar Styles
   UX-Optimized: Mobile-first, touch-friendly, clear hierarchy
   ============================================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #0c0c14;
    color: #8888a8;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    max-width: 460px;
    margin: 0 auto;
    background: #0c0c14;
    box-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
}

/* ─── GATE (Login Screen) ─── */
.gate {
    position: absolute;
    inset: 0;
    z-index: 100;
    background: #0c0c14;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gate-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    padding: 32px;
    width: 100%;
}

.gate-logo {
    width: 72px;
    height: 72px;
    object-fit: contain;
    border-radius: 16px;
    opacity: 0.9;
}

.gate-title {
    font-size: 18px;
    font-weight: 800;
    color: #e8e8f0;
    letter-spacing: 3px;
}

.gate-subtitle {
    font-size: 12px;
    color: #5a5a78;
    margin-bottom: 4px;
}

.gate-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    max-width: 280px;
}

.gate-item {
    background: #10101a;
    border: 1px solid #1e1e30;
    border-radius: 10px;
    padding: 14px 20px;
    color: #e8e8f0;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    letter-spacing: 0.5px;
}

.gate-item:hover {
    background: #1a1a2e;
    border-color: #f0b90b;
    color: #e8e8f0;
}

.gate-item:active {
    transform: scale(0.97);
}

/* ─── MAIN APP ─── */
.main-app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ─── SALE BAR ─── */
.sale-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #10101a;
    border-bottom: 1px solid #1e1e30;
    flex-shrink: 0;
}

.sale-bar-name {
    font-size: 13px;
    font-weight: 700;
    color: #f0b90b;
    letter-spacing: 0.5px;
}

.sale-bar-change {
    background: none;
    border: 1px solid #1e1e30;
    color: #5a5a78;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.sale-bar-change:hover {
    border-color: #f0b90b;
    color: #e8e8f0;
}

/* ─── TABS ─── */
.tabs {
    display: flex;
    background: #10101a;
    border-bottom: 1px solid #1e1e30;
    flex-shrink: 0;
}

.tab {
    flex: 1;
    padding: 12px 0;
    background: none;
    border: none;
    color: #5a5a78;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    border-bottom: 2px solid transparent;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.tab:hover {
    color: #8888a8;
}

.tab.active {
    color: #f0b90b;
    border-bottom-color: #f0b90b;
    background: #0c0c14;
}

/* ─── TAB CONTENT ─── */
.tab-content {
    display: none;
    flex: 1;
    overflow: hidden;
}

.tab-content.active {
    display: flex;
    flex-direction: column;
}

/* ─── MAIN PANEL (LOG) ─── */
.main-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.watermark {
    position: absolute;
    inset: 0;
    z-index: 0;
    opacity: 0.1;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.watermark-img {
    width: 50%;
    max-width: 200px;
    filter: grayscale(1);
}

.terminal {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 11px;
    line-height: 1.6;
}

.terminal::-webkit-scrollbar {
    width: 4px;
}

.terminal::-webkit-scrollbar-track {
    background: transparent;
}

.terminal::-webkit-scrollbar-thumb {
    background: #1e1e30;
    border-radius: 2px;
}

.log-entry {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    word-break: break-all;
    color: #e8e8f0;
}

.log-entry .timestamp {
    opacity: 0.3;
    flex-shrink: 0;
    user-select: none;
}

.log-entry.system {
    color: #3b82f6;
    font-weight: 700;
    border-bottom: 1px solid rgba(30, 58, 138, 0.2);
    padding-bottom: 4px;
    margin-bottom: 4px;
    margin-top: 8px;
}

.log-entry.system:first-child {
    margin-top: 0;
}

.log-entry.success {
    color: #34d399;
}

.log-entry.error {
    color: #f87171;
}

.log-entry.warn {
    color: #fbbf24;
}

.log-entry.info {
    color: #cbd5e1;
}

/* ─── FORM PANEL ─── */
.form-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #0c0c14;
}

.form-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 24px 20px 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    /* Giảm gap chung từ 24px xuống 16px */
}

.form-scroll::-webkit-scrollbar {
    width: 4px;
}

.form-scroll::-webkit-scrollbar-track {
    background: transparent;
}

.form-scroll::-webkit-scrollbar-thumb {
    background: #1e1e30;
    border-radius: 2px;
}

/* Section wrappers */
#sectionCustomer,
#sectionShipping,
#sectionAddress {
    display: flex;
    flex-direction: column;
    gap: 16px;
    /* Giảm gap giữa các field trong section xuống 16px */
}

/* ─── FORM GROUPS ─── */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
    /* Ô chữ so với ô text field gần lại một chút */
}

.form-group label {
    font-size: 11px;
    font-weight: 700;
    color: #8888a8;
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.form-section-label {
    font-size: 10px;
    font-weight: 800;
    color: #5a5a78;
    letter-spacing: 1px;
    padding-bottom: 6px;
    border-bottom: 1px dashed #1e1e30;
    /* Đổi nét đứt nhẹ nhàng hơn */
    margin-top: 12px;
    /* Dãn thẻ title sub-group xa thẻ block cũ ra một chút */
    margin-bottom: -4px;
    /* Thu hẹp lại khoảng hở đẩy xuống Input field bên dưới */
}

/* ─── SHIP RESULT INDICATOR ─── */
.ship-result {
    font-size: 12px;
    color: #f0b90b;
    padding: 4px 0;
    min-height: 20px;
    letter-spacing: 0.3px;
    font-weight: 600;
}

.ship-result.loading {
    color: #f0b90b;
}

.ship-result.error {
    color: #ef4444;
}

/* ─── LOADING STATE FOR INPUTS ─── */
.input-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.6;
}

.input-loading::after {
    content: '';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid #1e1e30;
    border-top-color: #f0b90b;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to {
        transform: translateY(-50%) rotate(360deg);
    }
}

/* ─── INPUTS & SELECTS ─── */
.form-group input,
.form-group select {
    background: #10101a;
    border: 1px solid #1e1e30;
    border-radius: 10px;
    padding: 12px 16px;
    color: #e8e8f0;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
}

.form-group input::placeholder {
    color: #5a5a78;
    font-size: 13px;
}

.form-group input:focus,
.form-group select:focus {
    border-color: #f0b90b;
    box-shadow: 0 0 0 3px rgba(240, 185, 11, 0.12);
}

.form-group input[readonly] {
    opacity: 0.6;
    cursor: default;
}

.form-group label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
}

.btn-smart-paste {
    background: rgba(240, 185, 11, 0.15);
    color: var(--accent-gold);
    border: 1px solid rgba(240, 185, 11, 0.3);
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    padding: 3px 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-smart-paste:hover {
    background: rgba(240, 185, 11, 0.25);
    border-color: rgba(240, 185, 11, 0.5);
    transform: translateY(-1px);
}

.btn-smart-paste:active {
    transform: translateY(0);
}

.form-row {
    display: flex;
    gap: 12px;
    /* Tên khách và SDT sát lại 1 tý, 12px thay vì 14px */
}

.flex-1 {
    flex: 1;
    min-width: 0;
}

/* ─── SEARCHABLE SELECT ─── */
.search-select {
    position: relative;
}

.search-input {
    background: #10101a;
    border: 1px solid #1e1e30;
    border-radius: 10px;
    padding: 12px 16px;
    color: #e8e8f0;
    font-size: 14px;
    font-family: inherit;
    outline: none;
    width: 100%;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.search-input::placeholder {
    color: #5a5a78;
    font-size: 13px;
}

.search-input:focus {
    border-color: #f0b90b;
    box-shadow: 0 0 0 3px rgba(240, 185, 11, 0.12);
}

.search-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #10101a;
    border: 1px solid #1e1e30;
    border-top: none;
    border-radius: 0 0 10px 10px;
    max-height: 180px;
    overflow-y: auto;
    z-index: 50;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.search-dropdown.open {
    display: block;
}

.search-dropdown::-webkit-scrollbar {
    width: 4px;
}

.search-dropdown::-webkit-scrollbar-thumb {
    background: #475569;
    border-radius: 2px;
}

.search-option {
    padding: 10px 14px;
    font-size: 13px;
    color: #e8e8f0;
    cursor: pointer;
    transition: background 0.15s ease;
    border-bottom: 1px solid #1e1e30;
}

.search-option:hover,
.search-option.highlighted {
    background: #1e1e30;
    color: #e8e8f0;
}

.search-option .price-tag {
    color: #f0b90b;
    font-size: 11px;
    margin-left: 6px;
}

/* ─── PRODUCT LINES ─── */
.product-line {
    display: flex;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}

.product-line select {
    flex: 3;
}

.product-line input[type="number"] {
    flex: 1;
    min-width: 50px;
}

.product-line .btn-remove {
    background: #7f1d1d;
    border: none;
    color: #fca5a5;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s ease;
}

.product-line .btn-remove:hover {
    background: #991b1b;
}

.btn-add-product {
    background: none;
    border: 1px dashed #1e1e30;
    color: #f0b90b;
    padding: 10px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s ease;
    width: 100%;
    margin-top: 4px;
}

.btn-add-product:hover {
    border-color: #f0b90b;
    background: rgba(240, 185, 11, 0.06);
}

/* ─── SUBMIT BUTTON ─── */
.btn-submit {
    background: #f0b90b;
    border: none;
    color: #06060b;
    padding: 16px;
    border-radius: 12px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    margin-top: 8px;
    letter-spacing: 1.5px;
    box-shadow: 0 4px 16px rgba(240, 185, 11, 0.2);
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(240, 185, 11, 0.35);
}

.btn-submit:active {
    transform: translateY(0);
}

.btn-submit:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.form-status {
    font-size: 12px;
    text-align: center;
    min-height: 20px;
    margin-top: 8px;
    padding-bottom: 12px;
}

.form-status.success {
    color: #34d399;
}

.form-status.error {
    color: #f87171;
}

.form-status.loading {
    color: #f0b90b;
}

/* ─── FOOTER ─── */
.footer {
    height: 40px;
    background: #10101a;
    border-top: 1px solid #1e1e30;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    user-select: none;
    z-index: 20;
    flex-shrink: 0;
}

.footer-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.footer-right {
    display: flex;
    align-items: center;
}

.status-group {
    display: flex;
    align-items: center;
    gap: 6px;
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #5a5a78;
    transition: all 0.2s ease;
}

.dot-green {
    background: #22c55e;
}

.dot-red {
    background: #ef4444;
}

.dot-label {
    font-size: 10px;
    font-weight: 700;
    color: #5a5a78;
    transition: color 0.2s ease;
}

.dot-label.active {
    color: #10b981;
}

.dot-label.inactive {
    color: #ef4444;
}

.divider {
    width: 1px;
    height: 14px;
    background: #1e1e30;
}

.toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.toggle-btn:hover {
    opacity: 0.8;
}

.toggle-btn:active {
    transform: scale(0.95);
}

.import-count {
    font-size: 10px;
    font-weight: 700;
    color: #5a5a78;
    text-transform: uppercase;
}

.import-count.has-data {
    color: #10b981;
}

/* ─── RESPONSIVE: Standalone Tab ─── */
@media (min-width: 500px) {
    body {
        background: #0c0c14;
    }

    .app {
        border-radius: 16px;
        margin-top: 20px;
        height: calc(100vh - 40px);
        border: 1px solid #1e1e30;
    }
}

@media (max-width: 380px) {
    .form-row {
        flex-direction: column;
        gap: 16px;
    }

    .form-scroll {
        padding: 20px 16px 28px;
    }
}

/* ============ SALE TAB ============ */
.sale-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 8px 12px;
    gap: 8px;
    background: #0c0c14;
    scrollbar-width: thin;
    scrollbar-color: rgba(71, 85, 105, 0.3) transparent;
}

.sale-panel::-webkit-scrollbar {
    width: 4px;
}

.sale-panel::-webkit-scrollbar-track {
    background: transparent;
}

.sale-panel::-webkit-scrollbar-thumb {
    background: rgba(71, 85, 105, 0.3);
    border-radius: 4px;
}

.sale-panel::-webkit-scrollbar-thumb:hover {
    background: rgba(71, 85, 105, 0.5);
}

.sale-header {
    text-align: center;
    padding: 2px 0;
}

.sale-title {
    font-size: 11px;
    font-weight: 800;
    color: #f0b90b;
    letter-spacing: 2px;
}

.sale-subtitle {
    font-size: 10px;
    color: #475569;
    margin-top: 4px;
}

.sale-summary {
    display: flex;
    gap: 6px;
    justify-content: center;
}

.sale-stat {
    flex: 1;
    background: #10101a;
    border: 1px solid #1e1e30;
    border-radius: 8px;
    padding: 6px 6px;
    text-align: center;
}

.sale-stat-value {
    display: block;
    font-size: 16px;
    font-weight: 800;
    color: #e8e8f0;
    font-variant-numeric: tabular-nums;
}

.sale-stat-label {
    display: block;
    font-size: 8px;
    font-weight: 700;
    color: #5a5a78;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 2px;
}

.sale-alerts {
    flex: 1;
    overflow-y: auto;
}

.sale-section-title {
    font-size: 9px;
    font-weight: 800;
    color: #f0b90b;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.sale-branch-issues {
    overflow-y: auto;
    flex: 1;
    scrollbar-width: thin;
    scrollbar-color: rgba(71, 85, 105, 0.3) transparent;
}

.sale-branch-issues::-webkit-scrollbar {
    width: 3px;
}

.sale-branch-issues::-webkit-scrollbar-thumb {
    background: rgba(71, 85, 105, 0.3);
    border-radius: 3px;
}

.sale-branch-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.sale-branch-card {
    background: rgba(240, 185, 11, 0.04);
    border: 1px solid rgba(240, 185, 11, 0.1);
    border-radius: 6px;
    padding: 5px 8px;
}

.sale-branch-name {
    font-size: 10px;
    font-weight: 700;
    color: #e8e8f0;
    margin-bottom: 2px;
}

.sale-branch-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 3px;
}

.sale-tag {
    display: inline-block;
    font-size: 8px;
    font-weight: 700;
    padding: 1px 5px;
    border-radius: 3px;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sale-tag-holiday {
    background: rgba(240, 185, 11, 0.12);
    color: #f0b90b;
    border: 1px solid rgba(240, 185, 11, 0.2);
}

.sale-tag-stock {
    background: rgba(239, 68, 68, 0.08);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.15);
}

.sale-alerts-title {
    font-size: 9px;
    font-weight: 800;
    color: #ef4444;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.sale-alerts-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sale-alert-card {
    background: rgba(239, 68, 68, 0.04);
    border: 1px solid rgba(239, 68, 68, 0.12);
    border-radius: 6px;
    padding: 6px 8px;
}

.sale-alert-card .alert-name {
    font-size: 11px;
    font-weight: 700;
    color: #e8e8f0;
}

.sale-alert-card .alert-type {
    font-size: 9px;
    font-weight: 700;
    color: #f87171;
    margin-top: 2px;
}

.sale-alert-card .alert-msg {
    font-size: 10px;
    color: #8888a8;
    margin-top: 4px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sale-alert-card .alert-time {
    font-size: 8px;
    color: #5a5a78;
    font-family: monospace;
    margin-top: 4px;
}

.sale-empty {
    text-align: center;
    font-size: 10px;
    color: #5a5a78;
    padding: 8px 0;
}

.sale-open-dashboard {
    display: block;
    width: 100%;
    text-align: center;
    padding: 5px;
    font-size: 9px;
    font-weight: 700;
    color: #5a5a78;
    background: transparent;
    border: 1px solid #1e1e30;
    border-radius: 6px;
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: all 0.15s;
    flex-shrink: 0;
}

.sale-open-dashboard:hover {
    color: #f0b90b;
    border-color: rgba(240, 185, 11, 0.2);
    background: rgba(240, 185, 11, 0.04);
}