/* ====================================================
   POS Touch Input System
   For Aures Yuno 1500i (15.6" PCAP touchscreen)
   Replaces on-screen keyboard with POS-style modals
   ==================================================== */

/* ===== OVERLAY ===== */
.pos-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    touch-action: none;
}

.pos-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ===== MODAL CONTAINER ===== */
.pos-modal {
    background: #ffffff;
    border-radius: 1rem;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    transform: scale(0.95) translateY(10px);
    transition: transform 0.2s ease;
    max-height: 96vh;
    display: flex;
    flex-direction: column;
}

.pos-overlay.active .pos-modal {
    transform: scale(1) translateY(0);
}

/* ===== NUMPAD MODAL ===== */
.pos-modal.numpad {
    width: 420px;
}

/* ===== KEYBOARD MODAL ===== */
.pos-modal.keyboard {
    width: 720px;
}

/* ===== HEADER ===== */
.pos-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #1e293b, #334155);
    color: white;
}

.pos-header-label {
    font-size: 1rem;
    font-weight: 600;
    opacity: 0.9;
}

.pos-header-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    touch-action: manipulation;
}

.pos-header-close:hover,
.pos-header-close:active {
    background: rgba(255, 255, 255, 0.3);
}

/* ===== DISPLAY ===== */
.pos-display {
    padding: 1rem 1.25rem;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
}

.pos-display-value {
    font-size: 2.5rem;
    font-weight: 700;
    font-family: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
    color: #0f172a;
    text-align: right;
    min-height: 3.5rem;
    line-height: 3.5rem;
    padding: 0 0.5rem;
    background: white;
    border: 2px solid #e2e8f0;
    border-radius: 0.5rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    user-select: none;
}

.pos-display-value.empty {
    color: #94a3b8;
}

.pos-display-value.has-cursor::after {
    content: '';
    display: inline-block;
    width: 2px;
    height: 2rem;
    background: #3b82f6;
    margin-left: 2px;
    vertical-align: middle;
    animation: pos-blink 1s step-end infinite;
}

@keyframes pos-blink {
    50% { opacity: 0; }
}

.pos-display-unit {
    font-size: 0.85rem;
    color: #64748b;
    margin-top: 0.25rem;
    text-align: right;
}

/* ===== NUMPAD GRID ===== */
.pos-numpad {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
    padding: 0.75rem;
}

.pos-numpad-btn {
    height: 68px;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    background: white;
    font-size: 1.5rem;
    font-weight: 600;
    color: #1e293b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s, transform 0.1s;
    touch-action: manipulation;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.pos-numpad-btn:active {
    background: #e2e8f0;
    transform: scale(0.96);
}

.pos-numpad-btn.decimal {
    font-size: 2rem;
    font-weight: 700;
}

.pos-numpad-btn.backspace {
    background: #fef2f2;
    color: #dc2626;
    font-size: 1.3rem;
}

.pos-numpad-btn.backspace:active {
    background: #fecaca;
}

.pos-numpad-btn.clear {
    background: #fefce8;
    color: #ca8a04;
    font-size: 1rem;
    font-weight: 600;
}

.pos-numpad-btn.clear:active {
    background: #fef08a;
}

/* ===== QUICK VALUES ===== */
.pos-quick-values {
    display: flex;
    gap: 6px;
    padding: 0 0.75rem;
}

.pos-quick-btn {
    flex: 1;
    height: 44px;
    border: 1px solid #bfdbfe;
    border-radius: 0.375rem;
    background: #eff6ff;
    font-size: 0.85rem;
    font-weight: 600;
    color: #1e40af;
    cursor: pointer;
    transition: background 0.1s;
    touch-action: manipulation;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.pos-quick-btn:active {
    background: #bfdbfe;
}

/* ===== ACTION BUTTONS ===== */
.pos-actions {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 6px;
    padding: 0.75rem;
    padding-top: 0.5rem;
}

.pos-action-btn {
    height: 60px;
    border: none;
    border-radius: 0.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.1s, transform 0.1s;
    touch-action: manipulation;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.pos-action-btn:active {
    transform: scale(0.97);
}

.pos-action-btn.cancel {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.pos-action-btn.cancel:active {
    background: #e2e8f0;
}

.pos-action-btn.confirm {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    color: white;
}

.pos-action-btn.confirm:active {
    background: linear-gradient(135deg, #16a34a, #15803d);
}

.pos-action-btn.confirm:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== KEYBOARD LAYOUT ===== */
.pos-keyboard {
    padding: 0.5rem 0.75rem 0.75rem;
}

.pos-kb-row {
    display: flex;
    gap: 4px;
    margin-bottom: 4px;
    justify-content: center;
}

.pos-kb-btn {
    height: 56px;
    min-width: 56px;
    flex: 0 0 auto;
    border: 1px solid #e2e8f0;
    border-radius: 0.375rem;
    background: white;
    font-size: 1.15rem;
    font-weight: 500;
    color: #1e293b;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.1s, transform 0.1s;
    touch-action: manipulation;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.pos-kb-btn:active {
    background: #e2e8f0;
    transform: scale(0.95);
}

.pos-kb-btn.wide {
    flex: 0 0 auto;
    min-width: 80px;
    font-size: 0.9rem;
    font-weight: 600;
}

.pos-kb-btn.space {
    flex: 1;
    min-width: 240px;
    font-size: 0.85rem;
    color: #64748b;
}

.pos-kb-btn.backspace {
    min-width: 80px;
    background: #fef2f2;
    color: #dc2626;
    font-size: 1.1rem;
}

.pos-kb-btn.backspace:active {
    background: #fecaca;
}

.pos-kb-btn.shift {
    min-width: 72px;
    background: #f1f5f9;
    font-size: 1.1rem;
}

.pos-kb-btn.shift.active {
    background: #dbeafe;
    border-color: #3b82f6;
    color: #1e40af;
}

.pos-kb-btn.symbols-toggle {
    background: #eef2ff;
    border-color: #818cf8;
    color: #4338ca;
    font-weight: 700;
    font-size: 1rem;
    letter-spacing: 1px;
}

/* Number row */
.pos-kb-btn.num {
    background: #f8fafc;
}

/* ===== KEYBOARD ACTIONS ===== */
.pos-kb-actions {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 6px;
    padding: 0 0.75rem 0.75rem;
}

/* ===== POS MODE TOGGLE ===== */
.pos-mode-toggle {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.75rem;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 0.5rem;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
    font-size: 0.8rem;
    font-weight: 500;
    color: #64748b;
}

.pos-mode-toggle:hover {
    background: #e2e8f0;
}

.pos-mode-toggle.active {
    background: #dbeafe;
    border-color: #3b82f6;
    color: #1e40af;
}

.pos-mode-indicator {
    width: 32px;
    height: 18px;
    border-radius: 9px;
    background: #cbd5e1;
    position: relative;
    transition: background 0.2s;
}

.pos-mode-toggle.active .pos-mode-indicator {
    background: #3b82f6;
}

.pos-mode-indicator::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: white;
    transition: transform 0.2s;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.pos-mode-toggle.active .pos-mode-indicator::after {
    transform: translateX(14px);
}

/* ===== INPUT HIGHLIGHT (when POS mode is active) ===== */
input[data-pos].pos-enabled,
input[data-pos-type].pos-enabled {
    cursor: pointer !important;
    caret-color: transparent;
}

input[data-pos].pos-enabled:focus,
input[data-pos-type].pos-enabled:focus {
    outline: 2px solid #3b82f6 !important;
    outline-offset: 1px;
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15) !important;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 480px) {
    .pos-modal.numpad {
        width: 100vw;
        max-width: 100vw;
        border-radius: 1rem 1rem 0 0;
        max-height: 85vh;
    }
    
    .pos-modal.keyboard {
        width: 100vw;
        max-width: 100vw;
        border-radius: 1rem 1rem 0 0;
        max-height: 90vh;
    }
    
    .pos-overlay {
        align-items: flex-end;
    }
    
    .pos-numpad-btn {
        height: 58px;
        font-size: 1.3rem;
    }
    
    .pos-kb-btn {
        height: 48px;
        min-width: 30px;
        font-size: 1rem;
    }
}

/* Ensure SweetAlert inputs also get POS treatment */
.swal2-popup input.pos-enabled {
    cursor: pointer !important;
    caret-color: transparent;
}
