/**
 * Mobile Scanner Styles
 * Touch-friendly, large buttons, clear typography
 */

/* === MAIN CONTAINER === */
.mobile-scanner {
    height: 100dvh; /* lepsze na mobile niż 100vh */
    display: flex;
    flex-direction: column;
    background: #f5f5f5;
    position: relative;
    overflow-y: auto; /* umożliwia przewijanie całego widoku */
    -webkit-overflow-scrolling: touch;
    padding-bottom: 10px; /* ✅ Minimalna przestrzeń na system navigation bar */
}

/* === HEADER === */
.mobile-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #1565C0 0%, #0D47A1 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    min-height: 64px;
}

.header-quick-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-toggle-label {
    color: rgba(255,255,255,0.9);
    font-weight: 700;
}

.mobile-header h1 {
    font-size: 24px;
    margin: 0;
    flex: 1;
    text-align: center;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.mobile-logout-btn-header {
    background: rgba(255,255,255,0.2);
    border: 2px solid rgba(255,255,255,0.5);
    color: white;
    font-size: 16px;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 600;
    white-space: nowrap;
}

.mobile-logout-btn-header:active {
    background: rgba(255,255,255,0.3);
    transform: scale(0.95);
}

/* === STATUS BAR === */
.mobile-status {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: white;
    border-bottom: 1px solid #e0e0e0;
    gap: 12px;
}

.status-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
}

.status-label {
    color: #666;
    font-weight: 500;
}

.status-value {
    color: #1976D2;
    font-weight: 700;
    font-size: 15px;
}

.mode-badge {
    padding: 6px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.mode-badge.mode-quick {
    background: #FFF3E0;
    color: #F57C00;
}

.mode-badge.mode-manual {
    background: #E3F2FD;
    color: #1976D2;
}

.mode-badge.mode-auto {
    background: #E8F5E9;
    color: #388E3C;
}

/* === MAIN FORM === */
.mobile-scan-form {
    flex: 1;
    padding: 20px 16px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* === FIELDS === */
.mobile-field {
    margin-bottom: 20px;
}

.mobile-field label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
    letter-spacing: 0.3px;
}

.mobile-input-huge {
    width: 100%;
    height: 80px;
    font-size: 28px;
    font-weight: 600;
    padding: 20px 24px;
    border: 3px solid #1976D2;
    border-radius: 16px;
    box-sizing: border-box;
    background: white;
    text-align: center;
    transition: all 0.2s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.mobile-input-huge:focus {
    outline: none;
    border-color: #0D47A1;
    box-shadow: 0 0 0 5px rgba(33, 150, 243, 0.15), 0 4px 12px rgba(0,0,0,0.12);
    transform: scale(1.02);
}

.mobile-input-huge.mobile-quantity {
    color: #0D47A1;
    font-weight: 800;
    font-size: 40px;
    border-color: #4CAF50;
}

.mobile-input-huge.mobile-quantity:focus {
    border-color: #2E7D32;
    box-shadow: 0 0 0 5px rgba(76, 175, 80, 0.15), 0 4px 12px rgba(0,0,0,0.12);
}

.mobile-input-huge::placeholder {
    color: #999;
    font-weight: 400;
}

/* === CUSTOM NUMPAD === */
.mobile-numpad {
    margin: 1px 0 20px 0;  /* ✅ Górny margines 1px, dolny 20px */
    background: white;
    padding: 16px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.numpad-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}

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

.numpad-btn {
    height: 80px;
    font-size: 28px;
    font-weight: 700;
    border: 3px solid #e0e0e0;
    border-radius: 12px;
    background: linear-gradient(145deg, #ffffff 0%, #f5f5f5 100%);
    color: #333;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.numpad-btn:active {
    transform: scale(0.93);
    background: #e0e0e0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12) inset;
}

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

/* Special button styles */
.numpad-delete {
    background: #FFEBEE;
    color: #D32F2F;
    border-color: #FFCDD2;
}

.numpad-delete:active {
    background: #FFCDD2;
}

.numpad-action {
    background: #E3F2FD;
    color: #1976D2;
    border-color: #BBDEFB;
    font-size: 18px;
}

.numpad-action:active {
    background: #BBDEFB;
}

.numpad-clear {
    background: #FFF3E0;
    color: #F57C00;
    border-color: #FFE0B2;
}

.numpad-clear:active {
    background: #FFE0B2;
}

.numpad-zero {
    grid-column: span 1;
}

.numpad-save {
    grid-column: span 2;
    background: linear-gradient(135deg, #4CAF50 0%, #388E3C 100%);
    color: white;
    border: none;
    font-size: 18px;
    font-weight: 700;
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.numpad-save:active {
    background: linear-gradient(135deg, #388E3C 0%, #2E7D32 100%);
    box-shadow: 0 2px 6px rgba(76, 175, 80, 0.3);
}

/* === MODE TOGGLE (SIMPLIFIED) === */
.mobile-mode-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    background: white;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    margin: 20px 0 10px 0;
}

.mode-toggle-label {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toggle-icon {
    font-size: 32px;
}

.toggle-text {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .4s;
    border-radius: 34px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #4CAF50;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(26px);
}

/* Small variant for header */
.toggle-switch.small {
    width: 38px;
    height: 22px;
}
.toggle-switch.small .toggle-slider:before {
    width: 18px;
    height: 18px;
    left: 2px;
    bottom: 2px;
}
.toggle-switch.small input:checked + .toggle-slider:before {
    transform: translateX(16px);
}

/* Mode Info Text */
.mode-info {
    padding: 12px 16px;
    background: #E3F2FD;
    border-radius: 8px;
    margin-bottom: 20px;
}

.mode-info p {
    margin: 0;
    font-size: 14px;
    color: #1976D2;
    font-weight: 500;
    line-height: 1.4;
}

.mode-info.quick-active {
    background: #FFF3E0;
}

.mode-info.quick-active p {
    color: #F57C00;
}

/* === RECENT SCANS === */
.mobile-recent {
    border-top: 1px solid #e0e0e0;
    background: white;
}

.mobile-toggle-recent {
    width: 100%;
    padding: 16px;
    background: none;
    border: none;
    font-size: 15px;
    font-weight: 600;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: #333;
    -webkit-tap-highlight-color: transparent;
}

.mobile-toggle-recent .badge {
    background: #1976D2;
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 13px;
    font-weight: 700;
}

.mobile-toggle-recent .toggle-icon {
    margin-left: auto;
    font-size: 12px;
    transition: transform 0.3s;
}

.mobile-toggle-recent.expanded .toggle-icon {
    transform: rotate(180deg);
}

.mobile-recent-list {
    max-height: 500px;  /* ✅ Zwiększone z 300px aby pomieścić 20 skanów */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    transition: max-height 0.3s ease;
}

.mobile-recent-list.collapsed {
    max-height: 0;
    overflow: hidden;
}

.mobile-scan-item {
    padding: 14px 16px;
    border-top: 1px solid #f0f0f0;
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: center;
    font-size: 14px;
}

.mobile-scan-item-icon {
    font-size: 24px;
}

.mobile-scan-item-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.mobile-scan-item-barcode {
    font-weight: 600;
    color: #333;
}

.mobile-scan-item-name {
    font-size: 12px;
    color: #666;
}

.mobile-scan-item-quantity {
    font-size: 18px;
    font-weight: 700;
    color: #1976D2;
}

.mobile-recent-empty {
    padding: 40px 20px;
    text-align: center;
    color: #999;
    font-size: 14px;
}

/* === MOBILE MENU === */
.mobile-menu {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
}

.mobile-menu.active {
    display: block;
}

.mobile-menu-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
}

.mobile-menu-panel {
    position: absolute;
    top: 0;
    right: 0;
    width: 85%;
    max-width: 350px;
    height: 100%;
    background: white;
    box-shadow: -4px 0 12px rgba(0,0,0,0.2);
    display: flex;
    flex-direction: column;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
    }
    to {
        transform: translateX(0);
    }
}

.mobile-menu-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: #1976D2;
    color: white;
}

.mobile-menu-header h2 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
}

.close-btn {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    font-size: 28px;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.close-btn:active {
    background: rgba(255,255,255,0.3);
}

.mobile-menu-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-user-info {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px;
    background: #f5f5f5;
    border-radius: 12px;
    margin-bottom: 24px;
}

.user-avatar {
    font-size: 48px;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border-radius: 50%;
}

.user-details {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.user-details strong {
    font-size: 18px;
    color: #333;
}

.user-role {
    font-size: 13px;
    color: #666;
    background: white;
    padding: 4px 10px;
    border-radius: 8px;
    display: inline-block;
}

.mobile-inventory-info {
    padding: 16px;
    background: #E3F2FD;
    border-radius: 12px;
    margin-bottom: 24px;
}

.info-label {
    font-size: 12px;
    color: #666;
    margin-bottom: 6px;
    font-weight: 600;
}

.info-value {
    font-size: 16px;
    color: #1976D2;
    font-weight: 700;
}

.mobile-menu-btn {
    width: 100%;
    height: 56px;
    font-size: 16px;
    font-weight: 600;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}

.mobile-menu-btn {
    background: #2196F3;
    color: white;
}

.mobile-menu-btn:active {
    transform: scale(0.98);
    opacity: 0.9;
}

.mobile-menu-btn.logout {
    background: #f44336;
    color: white;
    margin-top: 20px;
}

/* === HIDE DESKTOP NAV ON MOBILE === */
@media (max-width: 768px) {
    /* Hide desktop navigation completely */
    #app-nav,
    .app-nav,
    #nav-toggle,
    #mobile-nav-toggle {
        display: none !important;
    }
    
    /* Mobile scanner takes full screen */
    .mobile-scanner {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 1000;
    }
}

/* === RESPONSIVE === */
@media (min-width: 769px) {
    /* Hide mobile scanner on desktop */
    .mobile-scanner {
        display: none;
    }
}

/* === LOADING SPINNER === */
.mobile-loading {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9998;
}

.mobile-loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid #e0e0e0;
    border-top-color: #2196F3;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* === v29: SCAN DISPLAY (BEZ INPUT FIELDS!) === */
.mobile-scan-display {
    background: white;
    margin: 12px 12px 8px 12px;
    padding: 16px;
    border-radius: 14px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    text-align: center;
}

.scan-display-label {
    font-size: 14px;
    color: #666;
    margin-bottom: 16px;
    font-weight: 600;
}

.scan-display-barcode {
    font-size: 26px;
    font-weight: 700;
    color: #1976D2;
    font-family: 'Courier New', monospace;
    margin-bottom: 6px;
    letter-spacing: 1px;
}

.scan-display-name {
    font-size: 16px;
    color: #333;
    font-weight: 500;
    min-height: 24px;
    padding: 8px;
}

.scan-display-price {
    font-size: 18px;
    color: #1976D2;
    font-weight: 700;
    padding: 8px;
    background: #E3F2FD;
    border-radius: 8px;
    margin: 4px 8px;
    text-align: center;
}

.scan-display-price #mobile-price-value {
    font-size: 22px;
    color: #0D47A1;
}

/* === RECENT INLINE (20 items with scroll) === */
.mobile-recent-inline {
    margin: 4px 12px 20px 12px;
    display: flex;  /* ✅ CHANGED from grid to flex for better height handling */
    flex-direction: column;
    gap: 8px;
    max-height: 500px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 50px;
    background: transparent;
}

.recent-inline-item {
    background: white;
    border-radius: 12px;
    padding: 10px 12px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 10px;
    transition: background 0.2s;
    min-height: 60px;  /* ✅ CRITICAL FIX: Force minimum height! */
    height: auto;
}

.recent-inline-item.pending {
    background: #FFF9C4; /* Jasny żółty */
    border-left: 4px solid #FBC02D; /* Ciemniejszy żółty */
}

.recent-inline-item.synced {
    background: white;
}

.recent-inline-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.recent-inline-barcode {
    font-family: 'Courier New', monospace;
    font-weight: 700;
    color: #1976D2;
    font-size: 16px;
}

.recent-inline-name {
    font-size: 12px;
    color: #444;
    line-height: 1.2;
}

.recent-inline-qty {
    background: #E3F2FD;
    color: #1976D2;
    font-weight: 800;
    border-radius: 10px;
    padding: 6px 10px;
    min-width: 44px;
    text-align: center;
}

/* === QUANTITY SECTION === */
.mobile-quantity-section {
    background: white;
    padding: 0;  /* Changed: padding moved to children */
    border-radius: 16px 16px 0 0;
    box-shadow: 0 -6px 20px rgba(0,0,0,0.2);
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    max-height: 85vh;
    overflow-y: auto;
}

/* ✅ STICKY PRODUCT HEADER (inside quantity section) */
.mobile-product-sticky-header {
    position: sticky;
    top: 0;
    background: linear-gradient(135deg, #1976D2 0%, #1565C0 100%);
    color: white;
    padding: 12px 16px;
    z-index: 2001;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border-radius: 16px 16px 0 0;
}

.sticky-product-code {
    font-family: 'Courier New', monospace;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 4px;
}

.sticky-product-name {
    font-size: 15px;
    font-weight: 500;
    margin-bottom: 4px;
    opacity: 0.95;
}

.sticky-product-price {
    font-size: 16px;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 10px;
    border-radius: 6px;
    display: inline-block;
    margin-top: 4px;
}

.quantity-display-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 1px;  /* ✅ Zmniejszone do minimum */
    padding: 8px;
}

.quantity-display-label {
    font-size: 16px;  /* ✅ Zmniejszone z 20px */
    font-weight: 600;
    color: #666;
}

.quantity-display-value {
    font-size: 28px;  /* ✅ Zmniejszone z 32px */
    font-weight: 700;
    color: #1976D2;
    font-family: 'Courier New', monospace;
    min-width: 70px;  /* ✅ Zmniejszone z 80px */
    text-align: center;
    background: #E3F2FD;
    border-radius: 6px;  /* ✅ Zmniejszone z 8px */
    padding: 4px 12px;  /* ✅ Zmniejszone z 8px 16px */
}

/* === RECENT SCANS LIST === */
.mobile-recent-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-bottom: 1px solid #e0e0e0;
    background: white;
    transition: background 0.2s;
}

.mobile-recent-item.pending {
    background: #FFF9C4; /* Jasny żółty */
    border-left: 4px solid #FBC02D; /* Ciemniejszy żółty */
}

.mobile-recent-item.synced {
    background: white;
}

.recent-barcode {
    flex: 1;
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.recent-quantity {
    font-weight: 700;
    color: #1976D2;
    font-size: 14px;
}

.recent-time {
    font-size: 12px;
    color: #666;
}

.recent-status {
    font-size: 16px;
    min-width: 24px;
    text-align: center;
}

.mobile-recent-empty {
    padding: 20px;
    text-align: center;
    color: #999;
    font-style: italic;
}

/* === SHOW MORE BUTTON === */
.mobile-show-more-btn {
    width: 100%;
    padding: 14px;
    background: #1976D2;
    color: white;
    border: none;
    border-radius: 0 0 12px 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

.mobile-show-more-btn:active {
    background: #1565C0;
}

/* === MODAL === */
.mobile-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.mobile-modal-content {
    background: white;
    border-radius: 16px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.mobile-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px;
    border-bottom: 2px solid #e0e0e0;
}

.mobile-modal-header h3 {
    margin: 0;
    font-size: 18px;
    color: #333;
}

.mobile-modal-close {
    background: none;
    border: none;
    font-size: 32px;
    color: #999;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-modal-close:active {
    color: #333;
}

.mobile-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.mobile-modal-body .mobile-recent-item {
    border-radius: 0;
}

.mobile-modal-body .mobile-recent-item:last-child {
    border-bottom: none;
}

