* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f8f9fa;
    min-height: 100vh;
}

/* Mobile Container */
.mobile-container {
    max-width: 100vw;
    min-height: 100vh;
    height: 100vh;
    background: white;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Scanner Section - flexible to fill remaining space */
.scanner-section {
    padding: 15px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Results Section - simple scrolling */
.results-section {
    padding: 15px;
}

/* Simple body styles */
body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f8f9fa;
    min-height: 100vh;
}

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

.mobile-header h1 {
    margin: 0;
    font-size: 1.3rem; /* Smaller font */
    font-weight: 600;
}

/* Scanner Section */
.scanner-section {
    padding: 15px; /* Reduced padding */
}

/* Input Toggle */
.input-toggle {
    display: flex;
    background: #f1f3f4;
    border-radius: 20px;
    padding: 3px;
    margin-bottom: 15px; /* Reduced margin */
}

.toggle-btn {
    flex: 1;
    padding: 8px 15px; /* Reduced padding */
    border: none;
    background: transparent;
    border-radius: 17px;
    font-weight: 500;
    font-size: 0.9rem; /* Smaller font */
    transition: all 0.3s ease;
    color: #666;
}

.toggle-btn.active {
    background: white;
    color: #667eea;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Scan Button */
.scan-button {
    width: 100%;
    height: 80px; /* Reduced from 120px */
    border: 2px dashed #667eea;
    border-radius: 10px;
    background: linear-gradient(135deg, #f8f9ff 0%, #e8f0ff 100%);
    color: #667eea;
    font-size: 1rem; /* Smaller font */
    font-weight: 600;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px; /* Reduced gap */
    transition: all 0.3s ease;
    cursor: pointer;
}

.scan-button:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-color: #667eea;
}

.scan-button.active {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    border-color: #dc3545;
}

.scan-button i {
    font-size: 1.5rem; /* Smaller icon */
}

/* Camera Container */
.scanner-container {
    position: relative;
    border-radius: 10px;
    overflow: hidden;
    background: #000;
    margin-top: 10px;
}

.camera-viewport {
    position: relative;
    width: 100%;
    height: 200px; /* Reduced from 300px */
    overflow: hidden;
}

#preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.drawingBuffer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

/* Scanner Overlay */
.scanner-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.scan-frame {
    width: 250px;
    height: 100px;
    border: 2px solid #00ff00;
    border-radius: 8px;
    position: relative;
    animation: pulse 2s infinite;
}

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

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

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

.scan-instruction {
    color: white;
    background: rgba(0,0,0,0.7);
    padding: 8px 16px;
    border-radius: 20px;
    margin-top: 20px;
    font-size: 0.9rem;
}

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

/* Manual Input */
.manual-input {
    display: flex;
    gap: 10px;
}

.manual-input input {
    flex: 1;
    padding: 15px;
    border: 2px solid #e9ecef;
    border-radius: 10px;
    font-size: 1rem;
}

.manual-input button {
    padding: 15px 20px;
    border-radius: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
}

/* Toast Notification */
.toast-notification {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 12px 20px;
    border-radius: 25px;
    z-index: 1000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    font-size: 0.9rem;
    max-width: 90vw;
    text-align: center;
}

.toast-notification.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-notification.success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
}

.toast-notification.error {
    background: linear-gradient(135deg, #dc3545 0%, #e74c3c 100%);
}

.toast-notification.warning {
    background: linear-gradient(135deg, #ffc107 0%, #fd7e14 100%);
    color: #333;
}

.toast-notification.info {
    background: linear-gradient(135deg, #17a2b8 0%, #6f42c1 100%);
}

/* Results Section */
.results-section {
    padding: 0 20px 20px;
}

.product-card {
    background: white;
    border-radius: 15px;
    padding: 15px;
    margin-bottom: 15px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    border: 1px solid #e9ecef;
}

.product-card h3 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: #333;
}

.product-card h4 {
    font-size: 1.1rem;
    margin-bottom: 12px;
    color: #667eea;
    display: flex;
    align-items: center;
    gap: 8px;
}

.product-image {
    max-width: 200px;
    max-height: 200px;
    object-fit: contain;
    border-radius: 10px;
}

.ingredient-item {
    background: #e9ecef;
    padding: 5px 10px;
    margin: 2px;
    border-radius: 15px;
    display: inline-block;
    font-size: 0.9em;
}

.nutrition-table {
    background: white;
    border-radius: 10px;
    overflow: hidden;
}

.loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.badge-custom {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
}

/* AI Analysis Styles */
.alert {
    border-radius: 10px;
    border: none;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.alert-warning {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    color: #856404;
    border-left: 4px solid #ffc107;
}

.alert-danger {
    background: linear-gradient(135deg, #f8d7da 0%, #fab1a0 100%);
    color: #721c24;
    border-left: 4px solid #dc3545;
}

.alert-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #74b9ff 100%);
    color: #0c5460;
    border-left: 4px solid #17a2b8;
}

.alert-success {
    background: linear-gradient(135deg, #d4edda 0%, #00b894 100%);
    color: #155724;
    border-left: 4px solid #28a745;
}

.ai-analysis-header {
    background: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
    color: white;
    padding: 10px 15px;
    border-radius: 8px 8px 0 0;
    margin: -20px -20px 15px -20px;
}

.starch-warning {
    background: linear-gradient(135deg, #fdcb6e 0%, #e17055 100%);
    color: white;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 15px;
}

.health-score {
    display: inline-block;
    padding: 5px 15px;
    border-radius: 20px;
    font-weight: bold;
    margin: 2px;
}

.score-excellent {
    background: #00b894;
    color: white;
}

.score-good {
    background: #00cec9;
    color: white;
}

.score-fair {
    background: #fdcb6e;
    color: #2d3436;
}

.score-poor {
    background: #e17055;
    color: white;
}

.score-very-poor {
    background: #d63031;
    color: white;
}