* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    min-height: 100vh;
}

.container {
    max-width: 600px;
    margin: 0 auto;
    background-color: white;
    min-height: 100vh;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}

header {
    background-color: #01411C;
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.header-content h1 {
    font-size: 1.8rem;
    font-weight: 600;
    margin: 0;
    line-height: 1;
}

.header-content .subtitle {
    font-size: 0.9rem;
    font-weight: 300;
    margin: 0.2rem 0 0 0;
    opacity: 0.9;
}

.settings-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: background-color 0.3s;
}

.settings-btn:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

main {
    padding: 2rem 1rem;
}

.instructions {
    background-color: #e8f5e9;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    border: 1px solid #81c784;
}

.instructions h2 {
    color: #01411C;
    margin-bottom: 1rem;
    font-size: 1.3rem;
}

.instructions ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
}

.instructions li {
    margin-bottom: 0.5rem;
    line-height: 1.6;
}

.instructions .tip {
    margin: 0;
    padding: 0.75rem;
    background-color: #fff3cd;
    border-radius: 4px;
    border: 1px solid #ffeaa7;
    color: #856404;
}

.upload-section {
    text-align: center;
    margin-bottom: 2rem;
}

.upload-btn {
    background-color: #01411C;
    color: white;
    border: none;
    padding: 1.5rem 2rem;
    border-radius: 12px;
    cursor: pointer;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    transition: all 0.3s;
    box-shadow: 0 4px 6px rgba(1, 65, 28, 0.3);
}

.upload-btn:hover {
    background-color: #026b2e;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(1, 65, 28, 0.4);
}

.upload-btn:active {
    transform: translateY(0);
}

.image-preview {
    margin-bottom: 2rem;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.image-container {
    position: relative;
    display: block;
    width: 100%;
    background-color: #f0f0f0;
    min-height: 200px;
}

.image-preview img {
    width: 100%;
    height: auto;
    display: block;
    cursor: pointer;
}

.crop-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    display: none;
    pointer-events: none;
}

.crop-canvas.active {
    display: block;
    pointer-events: auto;
}

.image-controls {
    position: absolute;
    bottom: 10px;
    left: 10px;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.75rem;
    border-radius: 4px;
    font-size: 0.9rem;
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.image-controls button {
    background-color: #01411C;
    color: white;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.3s;
}

.image-controls button:hover {
    background-color: #026b2e;
}

.crop-btn {
    background-color: #01411C !important;
}

.scan-btn {
    background-color: #4CAF50 !important;
}

.scan-btn:hover {
    background-color: #45a049 !important;
}

.reset-btn {
    background-color: #ff5722 !important;
}

.reset-btn:hover {
    background-color: #e64a19 !important;
}

.image-controls label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    margin-left: 0.5rem;
}

.image-controls input[type="checkbox"] {
    cursor: pointer;
}

.close-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background-color: rgba(0, 0, 0, 0.7);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.3s;
}

.close-btn:hover {
    background-color: rgba(0, 0, 0, 0.9);
}

.scan-results {
    background-color: #f9f9f9;
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 2rem;
}

.scan-results h2 {
    margin-bottom: 1rem;
    color: #01411C;
}

.extracted-text {
    background-color: white;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
    font-size: 0.9rem;
    line-height: 1.6;
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
}

.detected-ingredients {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.rescan-btn {
    background-color: #ff9800;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    margin-top: 1rem;
    transition: background-color 0.3s;
}

.rescan-btn:hover {
    background-color: #f57c00;
}

.processing-info {
    margin-top: 0.5rem;
    text-align: center;
    color: #666;
    font-size: 0.85rem;
}

.processing-help {
    margin-top: 1.5rem;
    padding: 1rem;
    background-color: #f5f5f5;
    border-radius: 4px;
    border: 1px solid #e0e0e0;
    font-size: 0.85rem;
}

.processing-help p {
    margin: 0 0 0.5rem 0;
    color: #555;
}

.processing-help ul {
    margin: 0;
    padding-left: 1.5rem;
}

.processing-help li {
    margin-bottom: 0.3rem;
    color: #666;
}

.processing-help strong {
    color: #01411C;
}

.ingredient-alert {
    padding: 1rem;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ingredient-alert.suspicious {
    background-color: #fff3cd;
    border: 1px solid #ffeaa7;
    color: #856404;
}

.ingredient-alert.prohibited {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.ingredient-alert strong {
    font-weight: 600;
}

.loading {
    text-align: center;
    padding: 3rem;
}

.spinner {
    border: 3px solid #f3f3f3;
    border-top: 3px solid #01411C;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background-color: white;
    border-radius: 12px;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

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

.modal-header h2 {
    color: #01411C;
    font-size: 1.3rem;
}

.modal-body {
    padding: 1.5rem;
}

.list-section {
    margin-bottom: 2rem;
}

.list-section h3 {
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.ingredient-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1rem;
    min-height: 40px;
}

.ingredient-item {
    background-color: #e8f5e9;
    color: #01411C;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.ingredient-item.prohibited {
    background-color: #ffebee;
    color: #c62828;
}

.ingredient-item button {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    font-weight: bold;
    padding: 0 0.2rem;
}

.add-ingredient {
    display: flex;
    gap: 0.5rem;
}

.add-ingredient input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.add-ingredient button {
    background-color: #01411C;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

.add-ingredient button:hover {
    background-color: #026b2e;
}

.default-info {
    background-color: #f1f8f4;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
    border: 1px solid #a5d6a7;
    font-size: 0.9rem;
    line-height: 1.5;
}

.reset-section {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e0e0e0;
    text-align: center;
}

.reset-defaults-btn {
    background-color: #ff5722;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    transition: background-color 0.3s;
}

.reset-defaults-btn:hover {
    background-color: #e64a19;
}

.hidden {
    display: none !important;
}

@media (max-width: 600px) {
    .container {
        box-shadow: none;
    }
    
    .header-content h1 {
        font-size: 1.5rem;
    }
    
    main {
        padding: 1rem;
    }
}