/**
 * QR-Direct App - Mobile-First CSS Styles
 * Optimized for mobile QR scanning experience
 */
/* Hide version banners */
.qr-version-banner,
[style*="background: #007cba"],
[style*="background:#007cba"] {
    display: none !important;
}

/* Hide any element containing version text */
*:contains("v1.2.9") {
    display: none !important;
}


/* ==========================================================================
   CSS RESET & BASE STYLES
   ========================================================================== */

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

.qr-scanner-container {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f8f9fa;
    min-height: 100vh;
    overflow-x: hidden;
}

/* ==========================================================================
   MOBILE-FIRST LAYOUT
   ========================================================================== */

.qr-main-container {
    max-width: 100%;
    margin: 0 auto;
    padding: 10px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.qr-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px;
    margin: -10px -10px 20px -10px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.qr-header h1 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.qr-header .qr-subtitle {
    margin: 5px 0 0 0;
    font-size: 0.9rem;
    opacity: 0.9;
}

/* ==========================================================================
   LANGUAGE SWITCHER
   ========================================================================== */

.qr-language-switcher {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 100;
}

.qr-language-select {
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    padding: 5px 8px;
    border-radius: 15px;
    font-size: 0.8rem;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.qr-language-select option {
    background: #333;
    color: white;
}

/* ==========================================================================
   QR SCANNER SECTION
   ========================================================================== */

.qr-scanner-section {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    border: 1px solid #e9ecef;
}

.qr-scanner-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0 0 15px 0;
    color: #495057;
    text-align: center;
}

.qr-scanner-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    justify-content: center;
    flex-wrap: wrap;
}

.qr-btn {
    padding: 12px 20px;
    border: none;
    border-radius: 25px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    min-height: 44px; /* iOS touch target */
    min-width: 44px;
    justify-content: center;
    user-select: none;
    -webkit-user-select: none;
}

.qr-btn:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.qr-btn-primary {
    background: linear-gradient(135deg, #007bff, #0056b3);
    color: white;
    box-shadow: 0 2px 10px rgba(0,123,255,0.3);
}

.qr-btn-primary:hover, .qr-btn-primary:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0,123,255,0.4);
}

.qr-btn-success {
    background: linear-gradient(135deg, #28a745, #1e7e34);
    color: white;
    box-shadow: 0 2px 10px rgba(40,167,69,0.3);
}

.qr-btn-success:hover, .qr-btn-success:active {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(40,167,69,0.4);
}

.qr-btn-secondary {
    background: #6c757d;
    color: white;
}

.qr-btn-danger {
    background: linear-gradient(135deg, #dc3545, #c82333);
    color: white;
}

.qr-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
}

.qr-btn-icon {
    font-size: 1.1em;
}

/* QR Reader Container */
.qr-reader-container {
    position: relative;
    background: #000;
    border-radius: 15px;
    overflow: hidden;
    margin: 15px 0;
    min-height: 250px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#qr-reader {
    width: 100% !important;
    border-radius: 15px;
}

#qr-reader video {
    border-radius: 15px;
    object-fit: cover;
}

.qr-reader-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 10;
}

.qr-reader-frame {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    height: 200px;
    border: 2px solid #fff;
    border-radius: 15px;
    box-shadow: 0 0 0 9999px rgba(0,0,0,0.5);
}

.qr-reader-frame::before,
.qr-reader-frame::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 3px solid #00ff00;
}

.qr-reader-frame::before {
    top: -3px;
    left: -3px;
    border-right: none;
    border-bottom: none;
}

.qr-reader-frame::after {
    bottom: -3px;
    right: -3px;
    border-left: none;
    border-top: none;
}

.qr-scanner-status {
    text-align: center;
    padding: 10px;
    margin: 10px 0;
    border-radius: 10px;
    font-size: 0.9rem;
}

.qr-status-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.qr-status-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.qr-status-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* ==========================================================================
   PRODUCTS LIST
   ========================================================================== */

.qr-products-section {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    border: 1px solid #e9ecef;
}

.qr-products-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0 0 15px 0;
    color: #495057;
    display: flex;
    align-items: center;
    gap: 10px;
}

.qr-products-count {
    background: #007bff;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.qr-products-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.qr-product-item {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 10px;
    position: relative;
    transition: all 0.3s ease;
}

.qr-product-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.qr-product-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.qr-product-code {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    font-weight: 600;
    color: #007bff;
    background: white;
    padding: 4px 8px;
    border-radius: 6px;
    border: 1px solid #dee2e6;
}

.qr-product-remove {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.qr-product-remove:hover {
    background: #c82333;
    transform: scale(1.1);
}

.qr-product-details {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    font-size: 0.9rem;
}

.qr-product-detail {
    display: flex;
    flex-direction: column;
}

.qr-product-label {
    font-weight: 500;
    color: #6c757d;
    font-size: 0.8rem;
    margin-bottom: 2px;
}

.qr-product-value {
    color: #495057;
}

.qr-product-quantity {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
}

.qr-quantity-label {
    font-weight: 500;
    color: #6c757d;
    font-size: 0.9rem;
}

.qr-quantity-input {
    width: 60px;
    padding: 5px 8px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    text-align: center;
    font-size: 0.9rem;
}

.qr-products-empty {
    text-align: center;
    padding: 40px 20px;
    color: #6c757d;
}

.qr-products-empty-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

/* ==========================================================================
   CONTACT FORM
   ========================================================================== */

.qr-contact-section {
    background: white;
    border-radius: 15px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    border: 1px solid #e9ecef;
}

.qr-contact-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0 0 20px 0;
    color: #495057;
}

.qr-form-group {
    margin-bottom: 20px;
    position: relative;
}

.qr-form-label {
    display: block;
    font-weight: 500;
    color: #495057;
    margin-bottom: 8px;
    font-size: 0.95rem;
    line-height: 1.4;
}

.qr-form-label.required::after {
    content: ' *';
    color: #dc3545;
    font-weight: bold;
}

.qr-form-input,
.qr-form-textarea,
.qr-form-select {
    width: 100%;
    padding: 14px 16px;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s ease;
    background: white;
    min-height: 48px; /* Better touch target */
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    -webkit-appearance: none;
    appearance: none;
}

.qr-form-input:focus,
.qr-form-textarea:focus,
.qr-form-select:focus {
    outline: none;
    border-color: #007bff;
    box-shadow: 0 2px 8px rgba(0,123,255,0.15), 0 0 0 3px rgba(0,123,255,0.1);
    transform: translateY(-1px);
}

.qr-form-textarea {
    resize: vertical;
    min-height: 120px;
    line-height: 1.5;
}

.qr-form-error {
    color: #dc3545;
    font-size: 0.85rem;
    margin-top: 6px;
    display: none;
    font-weight: 500;
}

.qr-form-group.error .qr-form-input,
.qr-form-group.error .qr-form-textarea,
.qr-form-group.error .qr-form-select {
    border-color: #dc3545;
    box-shadow: 0 2px 8px rgba(220,53,69,0.15), 0 0 0 3px rgba(220,53,69,0.1);
}

.qr-form-group.error .qr-form-error {
    display: block;
    animation: qr-fadeIn 0.3s ease;
}

/* Better form layout */
.qr-form-section {
    background: white;
    border-radius: 16px;
    padding: 24px;
    margin: 20px 0;
    box-shadow: 0 4px 20px rgba(0,0,0,0.08);
    border: 1px solid #f1f3f4;
}

.qr-form-section h3 {
    margin: 0 0 20px 0;
    color: #2c3e50;
    font-size: 1.1rem;
    font-weight: 600;
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 10px;
}

/* Two-column layout ONLY for desktop screens */
@media (min-width: 1024px) {
    .qr-form-row {
        display: flex;
        gap: 20px;
        margin-bottom: 20px;
    }
    
    .qr-form-col {
        flex: 1;
    }
    
    .qr-form-col .qr-form-group {
        margin-bottom: 0;
    }
}

/* Keep buttons side by side on mobile */
.qr-button-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 20px;
}

.qr-button-group .qr-btn {
    flex: 1;
    min-width: 120px;
    max-width: 200px;
}

/* Mobile-first button layout */
@media (max-width: 480px) {
    .qr-button-group {
        gap: 8px;
    }
    
    .qr-button-group .qr-btn {
        font-size: 0.9rem;
        padding: 12px 16px;
    }
}

/* ==========================================================================
   COMPACT SCANNER
   ========================================================================== */

.qr-scanner-compact {
    background: white;
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    margin-bottom: 15px;
}

.qr-compact-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.qr-compact-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: #495057;
}

.qr-compact-counter {
    background: #e9ecef;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    color: #6c757d;
}

.qr-compact-scanner {
    text-align: center;
    margin-bottom: 15px;
}

.qr-compact-reader {
    margin: 10px 0;
    border-radius: 10px;
    overflow: hidden;
}

.qr-compact-products {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 15px;
}

.qr-compact-actions {
    text-align: center;
}

/* ==========================================================================
   LOADING & ANIMATIONS
   ========================================================================== */

.qr-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.qr-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: qr-spin 1s linear infinite;
}

@keyframes qr-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.qr-fade-in {
    animation: qr-fadeIn 0.3s ease-in;
}

@keyframes qr-fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.qr-slide-up {
    animation: qr-slideUp 0.3s ease-out;
}

@keyframes qr-slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ==========================================================================
   ACCESSIBILITY
   ========================================================================== */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.qr-skip-links {
    position: absolute;
    top: -40px;
    left: 6px;
    z-index: 1000;
}

.qr-skip-link {
    position: absolute;
    left: -10000px;
    top: auto;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.qr-skip-link:focus {
    position: static;
    width: auto;
    height: auto;
    background: #007bff;
    color: white;
    padding: 8px 16px;
    border-radius: 4px;
    text-decoration: none;
    font-weight: 500;
}

.qr-accessibility-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #007bff;
    color: white;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,123,255,0.3);
    z-index: 1000;
    transition: all 0.3s ease;
}

.qr-accessibility-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0,123,255,0.4);
}

.qr-font-controls {
    position: fixed;
    bottom: 80px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.qr-font-controls .qr-accessibility-btn {
    position: static;
    width: 40px;
    height: 40px;
    font-size: 0.9rem;
}

/* High contrast mode */
.qr-high-contrast {
    filter: contrast(150%) brightness(120%);
}

.qr-high-contrast .qr-btn-primary {
    background: #000 !important;
    border: 2px solid #fff !important;
}

.qr-high-contrast .qr-form-input,
.qr-high-contrast .qr-form-textarea,
.qr-high-contrast .qr-form-select {
    border: 2px solid #000 !important;
    background: #fff !important;
}

/* ==========================================================================
   ERROR PAGES
   ========================================================================== */

.qr-error-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 60vh;
    padding: 20px;
}

.qr-error-content {
    text-align: center;
    max-width: 400px;
}

.qr-error-icon {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.7;
}

.qr-error-content h2 {
    color: #495057;
    margin-bottom: 15px;
    font-size: 1.3rem;
}

.qr-error-message {
    color: #6c757d;
    margin-bottom: 10px;
    font-size: 0.9rem;
}

.qr-error-code {
    color: #adb5bd;
    font-size: 0.8rem;
    font-family: monospace;
    margin-bottom: 25px;
}

.qr-error-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

/* Small phones (up to 375px) */
@media (max-width: 375px) {
    .qr-main-container {
        padding: 5px;
    }
    
    .qr-scanner-section,
    .qr-products-section,
    .qr-contact-section {
        padding: 15px;
        margin-bottom: 15px;
    }
    
    .qr-btn {
        padding: 10px 15px;
        font-size: 0.8rem;
    }
    
    .qr-product-details {
        grid-template-columns: 1fr;
        gap: 8px;
    }
    
    .qr-scanner-controls {
        flex-direction: column;
        align-items: stretch;
    }
    
    .qr-reader-frame {
        width: 150px;
        height: 150px;
    }
}

/* Tablets and larger phones (768px and up) */
@media (min-width: 768px) {
    .qr-main-container {
        max-width: 600px;
        padding: 20px;
    }
    
    .qr-header {
        margin: -20px -20px 30px -20px;
        padding: 25px;
    }
    
    .qr-header h1 {
        font-size: 2rem;
    }
    
    .qr-scanner-section,
    .qr-products-section,
    .qr-contact-section {
        padding: 30px;
        margin-bottom: 30px;
    }
    
    .qr-scanner-controls {
        justify-content: center;
    }
    
    .qr-product-details {
        grid-template-columns: 1fr 1fr 1fr;
    }
    
    .qr-reader-frame {
        width: 250px;
        height: 250px;
    }
}

/* Desktop (1024px and up) */
@media (min-width: 1024px) {
    .qr-main-container {
        max-width: 800px;
    }
    
    .qr-scanner-section {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 30px;
        align-items: start;
    }
    
    .qr-scanner-title {
        grid-column: 1 / -1;
    }
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
    .qr-scanner-section,
    .qr-accessibility-btn,
    .qr-font-controls {
        display: none !important;
    }
    
    .qr-language-switcher {
        display: block !important;
    }

/* Hide scanner section when products are present */
.qr-products-list:not(:empty) ~ .qr-scanner-container .qr-scanner-section {
    display: none !important;
}

.qr-has-products .qr-scanner-section {
    display: none !important;
}
    
    .qr-main-container {
        max-width: none;
        padding: 0;
    }
    
    .qr-header {
        background: none !important;
        color: #000 !important;
        box-shadow: none !important;
    }
    
    .qr-products-section,
    .qr-contact-section {
        box-shadow: none !important;
        border: 1px solid #000 !important;
    }
}

/* ==========================================================================
   DARK MODE SUPPORT
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .qr-scanner-container {
        background: #1a1a1a;
        color: #e9ecef;
    }
    
    .qr-scanner-section,
    .qr-products-section,
    .qr-contact-section,
    .qr-scanner-compact {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .qr-form-input,
    .qr-form-textarea,
    .qr-form-select {
        background: #4a5568;
        border-color: #718096;
        color: #e9ecef;
    }
    
    .qr-product-item {
        background: #4a5568;
        border-color: #718096;
    }
    
    .qr-product-code {
        background: #2d3748;
        color: #63b3ed;
        border-color: #718096;
    }
}

/* ==========================================================================
   UTILITY CLASSES
   ========================================================================== */

.qr-text-center { text-align: center; }
.qr-text-left { text-align: left; }
.qr-text-right { text-align: right; }

.qr-mb-0 { margin-bottom: 0; }
.qr-mb-1 { margin-bottom: 0.5rem; }
.qr-mb-2 { margin-bottom: 1rem; }
.qr-mb-3 { margin-bottom: 1.5rem; }

.qr-mt-0 { margin-top: 0; }
.qr-mt-1 { margin-top: 0.5rem; }
.qr-mt-2 { margin-top: 1rem; }
.qr-mt-3 { margin-top: 1.5rem; }

.qr-p-0 { padding: 0; }
.qr-p-1 { padding: 0.5rem; }
.qr-p-2 { padding: 1rem; }
.qr-p-3 { padding: 1.5rem; }

.qr-d-none { display: none; }
.qr-d-block { display: block; }
.qr-d-flex { display: flex; }
.qr-d-grid { display: grid; }

.qr-w-100 { width: 100%; }
.qr-h-100 { height: 100%; }

.qr-text-muted { color: #6c757d; }
.qr-text-primary { color: #007bff; }
.qr-text-success { color: #28a745; }
.qr-text-danger { color: #dc3545; }
.qr-text-warning { color: #ffc107; }

/* ==========================================================================
   PRODUCT ADDED MESSAGE
   ========================================================================== */

.qr-product-added-message {
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    margin: 20px 0;
    box-shadow: 0 8px 25px rgba(76, 175, 80, 0.3);
    animation: slideInUp 0.5s ease-out;
}

.qr-product-added-message h3 {
    margin: 0 0 15px 0;
    font-size: 24px;
    font-weight: 600;
}

.qr-product-added-message p {
    margin: 0 0 25px 0;
    font-size: 16px;
    opacity: 0.9;
}

.qr-proceed-button {
    background: white;
    color: #4CAF50;
    border: none;
    padding: 15px 30px;
    border-radius: 25px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.qr-proceed-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.15);
    background: #f8f9fa;
}

.qr-proceed-button:active {
    transform: translateY(0);
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile responsive for product added message */
@media (max-width: 768px) {
    .qr-product-added-message {
        padding: 20px;
        margin: 15px 0;
    }
    
    .qr-product-added-message h3 {
        font-size: 20px;
    }
    
    .qr-proceed-button {
        padding: 12px 25px;
        font-size: 14px;
    }
}