/* ABC Terminal - Mobile-First CSS */
/* ================================ */

:root {
    /* Dark theme with vibrant accents */
    --bg-primary: #0f0f1a;
    --bg-secondary: #1a1a2e;
    --bg-tertiary: #252542;
    --bg-card: #16213e;
    
    --text-primary: #eaeaea;
    --text-secondary: #a0a0a0;
    --text-muted: #666;
    
    --accent-primary: #00d9ff;
    --accent-secondary: #7c3aed;
    --accent-success: #10b981;
    --accent-danger: #ef4444;
    --accent-warning: #f59e0b;
    
    --border-color: #2a2a4a;
    --shadow-color: rgba(0, 0, 0, 0.4);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    
    --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
    
    --top-bar-height: 60px;
    --bottom-bar-height: 80px;
}

/* Import Google Font */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

/* Reset & Base */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

body {
    font-family: var(--font-main);
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ================================ */
/* Config Selection Screen */
/* ================================ */

.terminal-select-body {
    background: linear-gradient(135deg, var(--bg-primary) 0%, var(--bg-secondary) 50%, #1e1e3f 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.terminal-select-container {
    max-width: 600px;
    width: 100%;
    text-align: center;
}

.terminal-title {
    font-size: 2.5rem;
    font-weight: 700;
    background: linear-gradient(90deg, var(--accent-primary), var(--accent-secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.terminal-subtitle {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 40px;
}

.pibox-settings {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    margin-bottom: 24px;
    text-align: left;
}

.pibox-settings label {
    display: block;
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin: 12px 0 8px;
}

.pibox-settings label:first-child {
    margin-top: 0;
}

.pibox-settings-row {
    display: flex;
    gap: 8px;
}

.pibox-address-input,
.pibox-address-select {
    flex: 1;
    min-width: 0;
    height: 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 0 12px;
}

.pibox-address-select {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image:
        linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%),
        linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
    background-position:
        calc(100% - 18px) 17px,
        calc(100% - 13px) 17px;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 32px;
}

.pibox-settings-links {
    margin-top: 6px;
}

.pibox-monitor-link {
    color: var(--accent-primary);
    text-decoration: none;
    font-size: 0.78rem;
}

.pibox-monitor-link:hover {
    text-decoration: underline;
}

.pibox-check-btn {
    border: none;
    border-radius: var(--radius-md);
    background: var(--accent-primary);
    color: var(--bg-primary);
    font-weight: 600;
    padding: 0 14px;
    cursor: pointer;
}

.pibox-status {
    color: var(--text-secondary);
    font-size: 0.78rem;
    margin-top: 8px;
    word-break: break-all;
}

.pibox-status:empty {
    display: none;
}

.pibox-status.ok {
    color: var(--accent-success);
}

.pibox-status.error {
    color: var(--accent-danger);
}

.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px;
    margin-bottom: 40px;
}

.config-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px 16px;
    text-decoration: none;
    color: var(--text-primary);
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
}

.config-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-4px);
    box-shadow: 0 8px 24px var(--shadow-color);
}

.config-icon {
    color: var(--accent-primary);
}

.config-name {
    font-weight: 600;
    font-size: 1rem;
}

.config-warehouse {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.config-uid,
.terminal-uid-info {
    font-family: var(--font-mono);
    font-size: 0.68rem;
    color: var(--text-secondary);
    word-break: break-all;
}

.terminal-footer {
    margin-top: 20px;
}

.back-link {
    color: var(--accent-primary);
    text-decoration: none;
    font-size: 0.9rem;
}

.back-link:hover {
    text-decoration: underline;
}

/* No Session Screen */
.no-session-message {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 40px;
    margin-bottom: 24px;
}

.no-session-message svg {
    margin-bottom: 20px;
}

.no-session-message h2 {
    margin-bottom: 16px;
    color: var(--accent-danger);
}

.no-session-message p {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.back-button {
    display: inline-block;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    padding: 12px 24px;
    border-radius: var(--radius-md);
    text-decoration: none;
    transition: background 0.2s;
}

.back-button:hover {
    background: var(--bg-card);
}

/* ================================ */
/* Main Terminal POS Screen */
/* ================================ */

.terminal-body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport for mobile browsers */
    background: var(--bg-primary);
}

/* TOP BAR */
.terminal-top-bar {
    flex-shrink: 0;
    height: var(--top-bar-height);
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 12px;
    gap: 8px;
}

.terminal-config-pill {
    flex-shrink: 0;
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border: 1px solid var(--border-color);
    border-radius: 999px;
    color: white;
    background: rgba(255, 255, 255, 0.16);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
}

.search-container {
    flex: 1;
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 12px;
    color: var(--text-muted);
    pointer-events: none;
}

.search-input {
    width: 100%;
    height: 44px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0 40px 0 44px;
    font-size: 16px; /* Prevents zoom on iOS */
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-input:focus {
    border-color: var(--accent-primary);
}

.clear-search-btn {
    position: absolute;
    right: 8px;
    width: 28px;
    height: 28px;
    background: var(--bg-primary);
    border: none;
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.action-btn {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.session-close-btn {
    color: var(--accent-warning);
}

.offline-indicator .session-close-btn {
    width: 28px;
    height: 22px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    color: white;
}

.offline-indicator .close-btn {
    width: 28px;
    height: 22px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    color: white;
}

.scan-btn {
    background: linear-gradient(135deg, var(--accent-primary), #00a8cc);
    color: var(--bg-primary);
}

.scan-btn:hover {
    transform: scale(1.05);
}

.close-btn {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.close-btn:hover {
    background: var(--accent-danger);
    color: white;
}

/* Search Results Dropdown */
.search-results {
    position: absolute;
    top: var(--top-bar-height);
    left: 0;
    right: 0;
    max-height: 50vh;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    overflow-y: auto;
    z-index: 100;
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.15s;
}

.search-result-item:hover,
.search-result-item:active {
    background: var(--bg-tertiary);
}

.search-result-img {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--bg-tertiary);
}

.search-result-info {
    flex: 1;
    min-width: 0;
}

.search-result-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.search-result-code {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.search-result-price {
    font-weight: 600;
    color: var(--accent-primary);
    font-family: var(--font-mono);
}

.search-loading,
.search-no-results {
    padding: 24px;
    text-align: center;
    color: var(--text-secondary);
}

/* ORDER CONTAINER */
.terminal-order-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.order-header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.order-title {
    flex: 1;
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-secondary);
}

.kode-harga-btn {
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-tertiary);
    color: var(--accent-primary);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 0 10px;
    cursor: pointer;
    white-space: nowrap;
}

.kode-harga-btn:hover {
    border-color: var(--accent-primary);
    background: var(--bg-card);
}

.clear-order-btn {
    width: 36px;
    height: 36px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.clear-order-btn:hover {
    background: var(--accent-danger);
    color: white;
}

.order-lines {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    -webkit-overflow-scrolling: touch;
}

.empty-order {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    gap: 16px;
}

.empty-order p {
    font-size: 0.9rem;
}

/* Order Line */
.order-line {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 8px;
    gap: 12px;
    cursor: pointer;
    transition: all 0.15s;
    border: 1px solid transparent;
}

.order-line:hover,
.order-line:active {
    border-color: var(--accent-primary);
}

.order-line-img {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
    object-fit: cover;
    background: var(--bg-tertiary);
    flex-shrink: 0;
}

.order-line-info {
    flex: 1;
    min-width: 0;
}

.order-line-name {
    font-weight: 500;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.order-line-code {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
}

.order-line-qty {
    background: var(--accent-secondary);
    color: white;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.9rem;
    min-width: 40px;
    text-align: center;
}

.order-line-price {
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--accent-primary);
    min-width: 80px;
    text-align: right;
}

/* BOTTOM BAR */
.terminal-bottom-bar {
    flex-shrink: 0;
    min-height: var(--bottom-bar-height);
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    padding: 8px 12px;
    gap: 8px;
}

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

.partner-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 10px 14px;
    color: var(--text-primary);
    cursor: pointer;
    width: 100%;
    transition: border-color 0.2s;
}

.partner-btn:hover {
    border-color: var(--accent-primary);
}

.partner-btn svg {
    flex-shrink: 0;
    color: var(--accent-secondary);
}

#partnerName {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.85rem;
}

.total-section {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    min-width: 90px;
}

.total-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.total-amount {
    font-size: 1.25rem;
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--accent-primary);
}

.pay-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--accent-success), #059669);
    border: none;
    border-radius: var(--radius-md);
    padding: 0 24px;
    height: 52px;
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.pay-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.pay-btn:not(:disabled):hover {
    transform: scale(1.02);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.3);
}

/* ================================ */
/* Modals */
/* ================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: flex-end;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease;
}

.kode-harga-modal {
    max-width: 900px;
}

.kode-harga-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    overflow: auto;
    max-height: 70vh;
    padding-bottom: 4px;
}

.kode-harga-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.78rem;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.kode-harga-table th,
.kode-harga-table td {
    padding: 8px;
    border-bottom: 1px solid var(--border-color);
    text-align: right;
    font-family: var(--font-mono);
}

.kode-harga-table th:first-child,
.kode-harga-table td:first-child {
    text-align: left;
}

.kode-harga-table th {
    color: var(--text-secondary);
    background: var(--bg-card);
    position: sticky;
    top: 0;
}

@media (max-width: 640px) {
    .kode-harga-list {
        grid-template-columns: 1fr;
    }
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-weight: 600;
    font-size: 1.1rem;
}

.modal-header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-close {
    width: 32px;
    height: 32px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 50%;
    color: var(--text-secondary);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-close:hover {
    background: var(--accent-danger);
    color: white;
}

.modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-search-input {
    width: 100%;
    height: 44px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0 16px;
    font-size: 16px;
    color: var(--text-primary);
    outline: none;
    margin-bottom: 16px;
}

.modal-search-input:focus {
    border-color: var(--accent-primary);
}

/* Partner List */
.partner-list {
    max-height: 300px;
    overflow-y: auto;
}

.partner-item {
    display: flex;
    flex-direction: column;
    padding: 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border-color);
}

.partner-item:hover {
    background: var(--bg-tertiary);
}

.partner-item-name {
    font-weight: 500;
}

.partner-item-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* Cashier Section & Modal */
.cashier-partner-row {
    display: flex;
    gap: 8px;
    width: 100%;
    margin-bottom: 8px;
}

.total-pay-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
}

.cashier-section {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cashier-btn {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px 12px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.cashier-btn:hover {
    background: var(--bg-card);
    border-color: var(--accent-secondary);
}

#cashierName {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-align: left;
}

#cashierName.has-cashier {
    color: var(--accent-success);
    font-weight: 500;
}

.clear-cashier-btn {
    background: var(--accent-danger);
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    color: white;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.clear-cashier-btn:hover {
    background: #dc2626;
}

.nfc-indicator {
    background: var(--accent-secondary);
    border-radius: var(--radius-sm);
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: nfc-pulse 2s infinite;
}

@keyframes nfc-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.nfc-indicator svg {
    color: white;
}

.cashier-modal {
    max-height: 70vh;
}

.nfc-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: rgba(124, 58, 237, 0.1);
    border: 1px solid var(--accent-secondary);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    color: var(--accent-secondary);
    font-size: 0.85rem;
}

.cashier-list {
    max-height: 300px;
    overflow-y: auto;
}

.cashier-item {
    display: flex;
    flex-direction: column;
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.2s;
}

.cashier-item:hover {
    background: var(--bg-card);
}

.cashier-item.selected {
    background: rgba(16, 185, 129, 0.1);
    border-left: 3px solid var(--accent-success);
}

.cashier-item-name {
    font-weight: 500;
    color: var(--text-primary);
}

.cashier-item-info {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.no-cashiers {
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
}

/* Cashier Notification Toast */
.cashier-notification {
    position: fixed;
    top: 50px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    animation: slideDown 0.3s ease;
}

.cashier-notification.success {
    background: var(--accent-success);
    color: white;
}

.cashier-notification.error {
    background: var(--accent-danger);
    color: white;
}

.cashier-notification.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes slideDown {
    from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
    to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Adjust partner section for new layout */
.partner-section {
    flex: 1;
}

.partner-btn {
    width: 100%;
    padding: 8px 12px;
    font-size: 0.8rem;
}

#partnerName {
    font-size: 0.8rem;
}

/* Payment Modal */
.payment-modal {
    max-height: 95vh;
}

.payment-no-price-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    white-space: nowrap;
}

.payment-no-price-toggle input {
    width: 18px;
    height: 18px;
}

.payment-summary {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 16px;
}

.payment-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.95rem;
}

.payment-row:last-child {
    margin-bottom: 0;
}

.payment-remaining {
    font-weight: 600;
    font-size: 1.1rem;
    padding-top: 8px;
    border-top: 1px solid var(--border-color);
}

.payment-total-amount {
    font-weight: 700;
    font-family: var(--font-mono);
    color: var(--accent-primary);
}

.payment-methods {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}

.payment-method-btn {
    flex: 1 1 calc(50% - 4px);
    padding: 12px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}

.payment-method-btn:hover,
.payment-method-btn.active {
    border-color: var(--accent-primary);
    background: var(--bg-tertiary);
}

.payment-lines {
    margin-bottom: 16px;
}

.payment-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    margin-bottom: 8px;
}

.payment-line-name {
    font-weight: 500;
}

.payment-line-amount {
    display: flex;
    align-items: center;
    gap: 8px;
}

.payment-line-amount input {
    width: 100px;
    height: 36px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0 10px;
    font-size: 0.95rem;
    font-family: var(--font-mono);
    color: var(--text-primary);
    text-align: right;
}

.payment-line-remove {
    width: 28px;
    height: 28px;
    background: var(--accent-danger);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Numpad */
.payment-numpad,
.qty-numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
}

.numpad-btn {
    height: 56px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1.25rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
}

.numpad-btn:hover,
.numpad-btn:active {
    background: var(--bg-tertiary);
    border-color: var(--accent-primary);
}

.numpad-backspace,
.qty-backspace {
    color: var(--accent-warning);
}

.qty-clear {
    color: var(--accent-danger);
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--accent-primary), #00a8cc);
    border: none;
    border-radius: var(--radius-md);
    padding: 14px 24px;
    color: var(--bg-primary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.btn-primary:not(:disabled):hover {
    transform: scale(1.02);
}

.btn-secondary {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px 24px;
    color: var(--text-primary);
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: var(--bg-card);
}

.btn-danger {
    background: var(--accent-danger);
    border: none;
    border-radius: var(--radius-md);
    padding: 14px 24px;
    color: white;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-danger:hover {
    opacity: 0.9;
}

.submit-payment-btn {
    width: 100%;
}

/* Quantity Modal */
.qty-modal {
    max-width: 360px;
}

.qty-display {
    font-size: 3rem;
    font-weight: 700;
    font-family: var(--font-mono);
    text-align: center;
    padding: 24px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: 16px;
    color: var(--accent-primary);
}

.qty-modal-footer {
    justify-content: space-between;
}

/* Success Modal */
.success-modal {
    border-radius: var(--radius-lg);
    text-align: center;
    padding: 40px 20px;
    max-width: 360px;
}

.success-icon {
    margin-bottom: 16px;
}

.success-modal h2 {
    margin-bottom: 8px;
    color: var(--accent-success);
}

.success-modal p {
    color: var(--text-secondary);
    margin-bottom: 24px;
    font-family: var(--font-mono);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 15, 26, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border-color);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

#loadingText {
    color: var(--text-secondary);
}

/* Scanner Overlay */
.scanner-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.scanner-container {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    width: 90%;
    max-width: 400px;
}

.scanner-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: var(--bg-tertiary);
}

.scanner-close-btn {
    width: 36px;
    height: 36px;
    background: var(--accent-danger);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.scanner-reader {
    min-height: 300px;
}

.scanner-video {
    width: 100%;
    max-height: 70vh;
    object-fit: cover;
    border-radius: var(--radius-md);
    background: #000;
}

/* Desktop Enhancements */
@media (min-width: 768px) {
    .modal-content {
        border-radius: var(--radius-lg);
        margin-bottom: 40px;
    }
    
    .terminal-top-bar {
        padding: 0 24px;
    }
    
    .terminal-bottom-bar {
        padding: 0 24px;
    }
    
    .order-lines {
        padding: 16px;
    }
    
    .order-line {
        padding: 16px;
    }
    
    .config-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    }
}

/* Dark scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ================================ */
/* Offline Mode Indicators */
/* ================================ */

.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 28px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    gap: 8px;
    font-size: 0.75rem;
    font-weight: 500;
    z-index: 500;
    transition: all 0.3s ease;
}

.terminal-status-left,
.terminal-status-center,
.terminal-status-right {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.terminal-status-left {
    flex-direction: column;
    align-items: flex-start;
    justify-content: flex-start;
    padding-left: 8px;
    gap: 0;
}

.terminal-status-center {
    flex-direction: column;
    justify-content: center;
    gap: 0;
}

.terminal-status-state {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.terminal-status-center .terminal-uid-info {
    color: rgba(255, 255, 255, 0.8);
    font-size: 0.58rem;
    line-height: 1;
    max-width: 52vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.terminal-status-right {
    justify-content: flex-end;
    padding-right: 8px;
}

.offline-indicator.online {
    background: linear-gradient(90deg, rgba(16, 185, 129, 0.9), rgba(16, 185, 129, 0.7));
    color: white;
}

.offline-indicator.offline {
    background: linear-gradient(90deg, rgba(239, 68, 68, 0.95), rgba(239, 68, 68, 0.8));
    color: white;
    animation: pulse-offline 2s infinite;
}

@keyframes pulse-offline {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.offline-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
}

.offline-indicator.offline .offline-dot {
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.pending-badge {
    background: white;
    color: var(--accent-danger);
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.7rem;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
}

/* Adjust top-bar position when offline indicator is visible */
.terminal-body {
    padding-top: 28px;
}

.terminal-top-bar {
    top: 28px;
}

/* Sync button */
.sync-btn {
    background: linear-gradient(135deg, var(--accent-warning), #d97706);
    color: white;
}

.sync-btn:hover {
    transform: scale(1.05);
}

.sync-btn.syncing svg {
    animation: spin 1s linear infinite;
}

/* Sync notification toast */
.sync-notification {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--accent-success);
    color: white;
    padding: 12px 24px;
    border-radius: var(--radius-md);
    font-weight: 500;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    z-index: 2000;
    animation: slideUp 0.3s ease;
}

.sync-notification.fade-out {
    animation: fadeOut 0.3s ease forwards;
}

@keyframes fadeOut {
    from { opacity: 1; transform: translateX(-50%) translateY(0); }
    to { opacity: 0; transform: translateX(-50%) translateY(20px); }
}

/* Success message styling */
.success-message {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
}

/* Offline success icon (different color) */
.success-modal.offline .success-icon svg {
    stroke: var(--accent-warning);
}

/* ================================ */
/* Offline Page */
/* ================================ */

.offline-page {
    text-align: center;
    padding: 40px 20px;
}

.offline-page .offline-icon {
    margin-bottom: 24px;
}

.offline-page h2 {
    color: var(--text-primary);
    margin-bottom: 16px;
}

.offline-page p {
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.offline-page .offline-hint {
    color: var(--accent-success);
    font-weight: 500;
    margin-bottom: 24px;
}

/* ===================== piBox Monitor Dashboard ===================== */
.pibox-monitor-body {
    background: var(--bg-primary);
    min-height: 100vh;
}

.pibox-monitor {
    max-width: 880px;
    margin: 0 auto;
    padding: 20px;
    color: var(--text-primary);
}

.pibox-monitor-header {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 16px;
}

.pibox-monitor-header h1 {
    font-size: 1.4rem;
    margin: 0;
}

.pibox-monitor-meta {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    flex-wrap: wrap;
}

.pibox-live-dot {
    display: inline-block;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: var(--accent-success);
    margin-right: 6px;
    box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.6);
    animation: piboxLive 1.6s ease-out infinite;
}

@keyframes piboxLive {
    0% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.6); }
    70% { box-shadow: 0 0 0 8px rgba(46, 204, 113, 0); }
    100% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0); }
}

.pibox-monitor-back {
    color: var(--accent-primary);
    text-decoration: none;
}

.pibox-monitor-back:hover {
    text-decoration: underline;
}

.pibox-monitor-summary {
    margin-bottom: 16px;
}

.pibox-monitor-summary-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.pibox-monitor-summary-table th,
.pibox-monitor-summary-table td {
    text-align: center;
    padding: 12px 6px;
    border-right: 1px solid var(--border-color);
}

.pibox-monitor-summary-table th:last-child,
.pibox-monitor-summary-table td:last-child {
    border-right: none;
}

.pibox-monitor-summary-table th {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.85rem;
}

.pibox-monitor-summary-table td {
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--text-primary);
}

.pibox-monitor-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 24px;
}

.pibox-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 16px;
}

.pibox-card-idle { border-left-color: var(--accent-success); }
.pibox-card-syncing { border-left-color: var(--accent-primary); }
.pibox-card-error { border-left-color: var(--accent-danger); }
.pibox-card-offline { border-left-color: #6b6f7a; opacity: 0.85; }

.pibox-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.pibox-card-title {
    font-weight: 600;
}

.pibox-card-status {
    font-size: 0.78rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
}

.pibox-card-status-idle { color: var(--accent-success); }
.pibox-card-status-syncing { color: var(--accent-primary); }
.pibox-card-status-error { color: var(--accent-danger); }
.pibox-card-status-offline { color: #9ba3b4; }

.pibox-card-body {
    font-size: 0.85rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.pibox-card-body strong {
    color: var(--text-primary);
}

.pibox-card-task {
    color: var(--accent-primary);
}

.pibox-card-error {
    color: var(--accent-danger);
}

.pibox-monitor-events h2 {
    font-size: 1rem;
    margin: 24px 0 8px;
    color: var(--text-secondary);
}

.pibox-monitor-events-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    font-size: 0.85rem;
}

.pibox-monitor-events-table td {
    padding: 8px 12px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
    vertical-align: top;
}

.pibox-monitor-events-table tr:last-child td {
    border-bottom: none;
}

.pibox-event-time {
    white-space: nowrap;
    color: var(--text-primary);
    font-family: var(--font-mono);
    width: 110px;
}

.pibox-event-terminal {
    color: var(--text-primary);
    width: 240px;
}

.pibox-monitor-empty {
    padding: 18px;
    text-align: center;
    color: var(--text-secondary);
    font-style: italic;
}

/* ================================ */
/* Buyback popup */
/* ================================ */

.buyback-popup {
    max-width: 560px;
    max-height: 95vh;
}

.buyback-popup-body {
    padding: 16px 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bb-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bb-field label {
    font-size: 0.78rem;
    color: var(--text-secondary);
    letter-spacing: 0.02em;
}

.bb-field input[type="text"],
.bb-field input[type="number"],
.bb-field input[type="date"] {
    height: 38px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0 10px;
    font-size: 0.95rem;
    color: var(--text-primary);
    font-family: var(--font-main);
}

.bb-field input[type="number"] {
    font-family: var(--font-mono);
    text-align: right;
}

.bb-field input:focus {
    outline: none;
    border-color: var(--accent-primary);
}

.bb-field-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 10px;
}

.bb-inline-group {
    display: flex;
    align-items: center;
    gap: 10px;
}

.bb-inline-group input[type="text"] {
    flex: 1 1 auto;
}

.bb-lm-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.bb-lm-toggle input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent-primary);
}

.bb-camera-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.bb-camera-row .btn-secondary {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    cursor: pointer;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.bb-camera-row .btn-secondary:hover {
    border-color: var(--accent-primary);
}

.bb-camera-status {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.bb-camera-status-ok {
    color: var(--accent-success);
}

.bb-image-preview {
    max-width: 96px;
    max-height: 96px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: var(--bg-card);
}

.bb-advanced {
    padding: 12px;
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.bb-advanced h4 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.bb-total-row {
    display: flex;
    align-items: stretch;
    gap: 8px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    padding: 10px;
    margin-top: 4px;
}

.bb-total-input {
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bb-total-input label {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.bb-total-input input {
    height: 42px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 0 12px;
    color: var(--accent-primary);
    font-family: var(--font-mono);
    font-size: 1.15rem;
    font-weight: 600;
    text-align: right;
}

.btn-icon {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    border-radius: var(--radius-sm);
    width: 42px;
    align-self: end;
    cursor: pointer;
    font-size: 1.05rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* Shared camera overlay */
.camera-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.camera-stage {
    width: min(96vw, 600px);
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 16px;
}

.camera-stage video {
    width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    background: black;
}

.camera-controls {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.camera-controls .btn-primary,
.camera-controls .btn-secondary {
    flex: 1 1 0;
    height: 44px;
    border-radius: var(--radius-md);
    font-size: 1rem;
    cursor: pointer;
    border: none;
}

.camera-controls .btn-primary {
    background: var(--accent-primary);
    color: var(--bg-primary);
    font-weight: 600;
}

.camera-controls .btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

