/* ============================================================================
   PICKING & PACKING APP - MAIN STYLESHEET
   ============================================================================ */

/* --- CSS Variables --- */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --text-primary: #1f2937;
    --text-secondary: #6b7280;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --border-radius: 8px;
    --nav-height: 64px;
    --header-height: 56px;
    --safe-area-inset-bottom: env(safe-area-inset-bottom, 0);
}

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

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--text-primary);
    background: #f3f4f6; /* Updated to match scan-style */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* --- App Container --- */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height for mobile */
    position: relative;
}

.main-content {
    flex: 1;
    overflow-y: auto;
    padding-bottom: calc(var(--nav-height) + var(--safe-area-inset-bottom) + 1.5rem);
    -webkit-overflow-scrolling: touch;
}

/* --- Page Container --- */
.page-container {
    padding: 1rem 1rem 2.25rem 1rem; /* Extra bottom padding for navigation clearance */
    max-width: 600px; /* Match scan-style */
    margin: 0 auto;
}

/* --- Scanner Input Section (matching scan-style.css) --- */
.scanner-section {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 1.5rem;
}

.scanner-wrapper {
    position: relative;
}

.scan-input {
    width: 100%;
    padding: 1rem;
    font-size: 1.25rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    box-sizing: border-box;
    transition: all 0.2s;
}

.scan-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.clear-button {
    position: absolute;
    right: 1rem;
    top: 50%;
    transform: translateY(-50%);
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
}

/* --- Product Card (matching scan-style.css) --- */
.result-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 1rem;
}

/* TWO-COLUMN LAYOUT: Image on left, info on right */
.result-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.result-image {
    width: 120px;
    height: 120px;
    object-fit: contain;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: white;
    flex-shrink: 0;
}

.result-image-placeholder {
    width: 120px;
    height: 120px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f3f4f6;
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    color: #9ca3af;
    font-size: 3rem;
    flex-shrink: 0;
}

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

.result-sku {
    margin: 0;
    font-size: 1.3rem;
    color: var(--text-primary);
}

.result-barcode {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.result-bin-wrapper {
    margin-top: 0.5rem;
}

.bin-badge {
    display: inline-block;
    padding: 0.5rem 0.75rem;
    background: var(--primary-light);
    border-radius: 6px;
    font-family: 'Courier New', 'Consolas', 'Monaco', monospace;
    font-weight: 600;
    font-size: 1.3rem;
    color: var(--primary-color);
}

.count-hint {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    color: #9ca3af;
    font-style: italic;
    text-align: left;
}

/* --- Product Field (Description) --- */
.result-field {
    margin-bottom: 1rem;
}

.result-field-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.result-field-value {
    display: block;
    font-size: 1.1rem;
    color: var(--text-primary);
    word-break: break-word;
}

/* --- Stock Quantities (matching scan-style.css) --- */
.stock-quantities {
    margin-bottom: 1rem;
}

.stock-main-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.stock-main-item {
    text-align: center;
    padding: 1rem;
    background: #f9fafb;
    border-radius: 8px;
}

.stock-main-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

.stock-main-value {
    display: block;
    font-size: 2.5rem;
    font-weight: 700;
    line-height: 1;
}

.stock-main-value.positive {
    color: var(--success-color);
}

.stock-main-value.warning {
    color: var(--warning-color);
}

.stock-main-value.negative {
    color: var(--danger-color);
}

/* Stock detail grid */
.stock-detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
    font-size: 0.9rem;
}

.stock-detail-item {
    display: flex;
    justify-content: space-between;
    padding: 0.5rem;
    background: #f9fafb;
    border-radius: 4px;
}

.stock-detail-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.stock-detail-value {
    color: var(--text-primary);
    font-weight: 600;
}

/* --- Action Buttons (matching scan-style.css) --- */
.result-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 1rem;
}

.action-btn {
    padding: 0.875rem 1rem;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    background: #f3f4f6;
    color: #1f2937;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.action-btn:hover {
    background: #f9fafb;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

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

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

/* --- States (matching scan-style.css) --- */
.state-message {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-secondary);
}

.state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state, .error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 3rem 1rem;
    text-align: center;
}

.empty-text, .error-text {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.empty-subtext {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

.error-message {
    background: #fee;
    border-left: 4px solid var(--danger-color);
    padding: 1rem;
    border-radius: 6px;
    color: #991b1b;
    margin-bottom: 1rem;
}

/* --- Loading --- */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--bg-primary);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* --- Responsive adjustments --- */
@media (max-width: 480px) {
    .page-container {
        padding: 0.5rem 0.5rem 2rem 0.5rem; /* Extra bottom padding for navigation clearance */
    }
    
    .scanner-section {
        padding: 1rem;
    }
    
    .scan-input {
        font-size: 1.1rem;
        padding: 0.875rem;
    }
    
    .result-card {
        padding: 1rem;
    }
    
    .stock-main-value {
        font-size: 2rem;
    }
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    border-radius: var(--border-radius);
    font-weight: 600;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    line-height: 1;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-primary:active {
    transform: scale(0.98);
}

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

.btn-secondary:hover {
    background: var(--border-color);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

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

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

/* --- 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;
}

/* Focus styles for keyboard navigation */
*:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}