/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    overflow-x: hidden;
    user-select: none;
}

/* Container with responsive height */
.container {
    width: 100%;
    height: 450px; /* Default iframe height */
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Detect if running in new tab vs iframe */
@media (min-height: 500px) {
    .container {
        height: 90vh;
    }
}

/* Header tooltip */
.tooltip {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    opacity: 0;
    pointer-events: none;
    z-index: 1000;
    transition: opacity 0.3s ease;
    max-width: 300px;
    text-align: center;
}

.container:hover .tooltip {
    opacity: 1;
}

/* Main content layout */
.main-content {
    display: flex;
    flex: 1;
    gap: 10px;
    padding: 10px;
    min-height: 0;
}

/* Pantry sidebar - Modified: Simplified layout without categorization */
.pantry-sidebar {
    width: 200px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    overflow-y: auto;
    padding: 10px;
}

.pantry-section {
    margin-bottom: 15px;
}

.pantry-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
    padding: 8px 10px;
    background: #f8f9fa;
    border-radius: 6px;
    border-left: 3px solid #4CAF50;
    text-align: center;
}

/* Modified: Food items now in a grid layout for better organization */
.food-items {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.food-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 10px 8px;
    background: #fff;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: grab;
    transition: all 0.2s ease;
    font-size: 10px;
    min-height: 60px;
    text-align: center;
}

.food-item:hover {
    border-color: #4CAF50;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(76, 175, 80, 0.2);
}

.food-item:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.food-icon {
    font-size: 20px;
    width: 24px;
    text-align: center;
}

/* Plate area */
.plate-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.plate-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    width: 100%;
    max-width: 400px;
}

/* Balance indicator */
.balance-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 16px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    font-size: 12px;
    font-weight: 500;
}

.indicator-light {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ffc107;
    transition: background-color 0.3s ease;
}

.indicator-light.green {
    background: #4CAF50;
}

.indicator-light.red {
    background: #f44336;
}

/* Healthy plate design */
.healthy-plate {
    width: 280px;
    height: 280px;
    border-radius: 50%;
    background: white;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    position: relative;
    overflow: hidden;
    border: 4px solid #e0e0e0;
}

.plate-section {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px dashed transparent;
    transition: all 0.3s ease;
}

.grains-section {
    top: 0;
    left: 50%;
    width: 50%;
    height: 50%;
    transform-origin: bottom left;
    background: rgba(255, 193, 7, 0.1);
    border-radius: 100% 0 0 0;
}

.protein-section {
    top: 50%;
    left: 50%;
    width: 50%;
    height: 50%;
    transform-origin: top left;
    background: rgba(255, 87, 34, 0.1);
    border-radius: 0 0 100% 0;
}

.vegetables-section {
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    background: rgba(76, 175, 80, 0.1);
    border-radius: 100% 0 0 100%;
}

.fruits-section {
    top: 10px;
    right: 10px;
    width: 60px;
    height: 60px;
    background: rgba(156, 39, 176, 0.1);
    border-radius: 50%;
    border: 2px solid rgba(156, 39, 176, 0.3);
}

/* Modified: Section labels without portion sizes */
.section-label {
    position: absolute;
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-align: center;
    pointer-events: none;
}

.grains-section .section-label {
    top: 20%;
    left: 50%;
    transform: translateX(-50%);
}

.protein-section .section-label {
    bottom: 20%;
    left: 50%;
    transform: translateX(-50%);
}

.vegetables-section .section-label {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.fruits-section .section-label {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 9px;
}

.drop-zone {
    width: 100%;
    height: 100%;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 5px;
}

.plate-section.drag-over {
    border-color: #4CAF50;
    background-color: rgba(76, 175, 80, 0.2);
}

/* Placed food items on plate */
.placed-food {
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 4px 6px;
    font-size: 9px;
    display: flex;
    align-items: center;
    gap: 3px;
    cursor: pointer;
    transition: all 0.2s ease;
    max-width: 60px;
    text-align: center;
}

.placed-food:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.placed-food .food-icon {
    font-size: 12px;
}

/* Controls */
.controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

.control-btn {
    padding: 8px 16px;
    border: none;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-height: 36px;
    white-space: nowrap;
}

.reset-btn {
    background: #f44336;
    color: white;
}

.reset-btn:hover {
    background: #d32f2f;
    transform: translateY(-1px);
}

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

.compare-btn:hover {
    background: #1976D2;
    transform: translateY(-1px);
}

.summary-btn {
    background: #4CAF50;
    color: white;
}

.summary-btn:hover {
    background: #388E3C;
    transform: translateY(-1px);
}

/* Feedback area */
.feedback-area {
    padding: 8px 16px;
    text-align: center;
}

.hint {
    background: rgba(255, 193, 7, 0.1);
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 11px;
    color: #f57c00;
    display: inline-block;
}

/* Food tooltip */
.food-tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 12px;
    border-radius: 8px;
    font-size: 11px;
    max-width: 200px;
    opacity: 0;
    pointer-events: none;
    z-index: 1000;
    transition: opacity 0.3s ease;
}

.food-tooltip.show {
    opacity: 1;
}

.tooltip-content h4 {
    margin-bottom: 5px;
    color: #4CAF50;
}

.tooltip-content p {
    margin-bottom: 5px;
    line-height: 1.4;
}

.tooltip-content small {
    color: #ccc;
}

/* Modal styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
}

.close {
    color: #aaa;
    float: right;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    position: absolute;
    right: 15px;
    top: 15px;
}

.close:hover {
    color: #000;
}

.modal h2 {
    margin-bottom: 20px;
    color: #333;
    font-size: 18px;
}

.comparison-container {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.example-plate {
    flex: 1;
    min-width: 200px;
    padding: 15px;
    border-radius: 8px;
    background: #f8f9fa;
}

.example-content p {
    margin: 8px 0;
    font-size: 12px;
}

.reflection-area {
    margin-top: 20px;
}

.reflection-area h3 {
    margin-bottom: 10px;
    font-size: 14px;
}

#reflectionText {
    width: 100%;
    height: 80px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 12px;
    resize: vertical;
}

/* Mobile responsiveness - Modified: Adjusted for single column layout */
@media (max-width: 768px) {
    .main-content {
        flex-direction: column;
        gap: 8px;
        padding: 8px;
    }
    
    .pantry-sidebar {
        width: 100%;
        height: 140px;
        overflow-x: auto;
        overflow-y: hidden;
    }
    
    .food-items {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        gap: 8px;
        min-width: max-content;
    }
    
    .food-item {
        min-width: 70px;
        flex-shrink: 0;
    }
    
    .healthy-plate {
        width: 240px;
        height: 240px;
    }
    
    .controls {
        flex-direction: column;
        width: 100%;
    }
    
    .control-btn {
        width: 100%;
    }
}

/* Touch-friendly targets */
@media (pointer: coarse) {
    .food-item {
        min-height: 44px;
        padding: 10px;
    }
    
    .control-btn {
        min-height: 44px;
        padding: 12px 16px;
    }
    
    .placed-food {
        min-width: 44px;
        min-height: 32px;
    }
}