

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background-color: #faf8f5;
    color: #4a4a4a;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 60px 20px 20px 20px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Header Styles */
.header {
    text-align: center;
    margin-bottom: 30px;
    padding: 20px 0;
}

.header h1 {
    font-size: 2.5rem;
    font-weight: 600;
    color: #8b7355;
    margin-bottom: 10px;
}

.header h1 i {
    margin-right: 10px;
    color: #6b8e23;
}

.header p {
    font-size: 1.1rem;
    color: #666;
    font-weight: 300;
}



/* Main Content Layout */
.main-content {
    display: flex;
    flex-direction: column;
    gap: 0;
    flex: 1;
    margin: 60px 0 30px 450px; /* top right bottom left - reduced top margin */
    align-items: center;
}

/* Food Elements Panel - Sticky Left Sidebar */
.food-elements-panel {
    position: fixed;
    left: 0;
    top: 0;
    width: 450px;
    height: 100vh;
    background: #fff;
    padding: 30px;
    border-right: 1px solid #e8e4e0;
    overflow-y: auto;
    z-index: 50;
}

.food-elements-panel h2 {
    font-size: 1.5rem;
    font-family: 'DM Serif Display', serif;
    font-weight: 400;
    color: #8b7355;
    margin-bottom: 20px;
}

/* Food Categories */
.food-categories {
    display: flex;
    gap: 10px;
    margin-bottom: 25px;
}

.category-tab {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e8e4e0;
    background: white;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 500;
    color: #666;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.category-tab:hover {
    border-color: #d4c4a8;
    background: #faf8f5;
}

.category-tab.active {
    background: #d4c4a8;
    border-color: #d4c4a8;
    color: #5a4a3a;
}

.category-tab i {
    font-size: 1.1rem;
}

/* Food Grid */
.food-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 15px;
}

.food-item {
    background: white;
    border: 2px solid #e8e4e0;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    cursor: grab;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.food-item:hover {
    border-color: #d4c4a8;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
}

.food-item:active {
    cursor: grabbing;
}

.food-item.dragging {
    opacity: 0.5;
    transform: rotate(5deg);
}

.food-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin: 0 auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: white;
}

.food-name {
    font-weight: 500;
    color: #4a4a4a;
    margin-bottom: 5px;
    font-size: 0.95rem;
}

.food-weight {
    font-size: 0.85rem;
    color: #888;
    font-weight: 400;
}

/* Meal Plate Panel */
.meal-plate-panel {
    display: flex;
    flex-direction: column;
    gap: 40px;
    align-items: center;
    width: 100%;
    max-width: 1000px;
}

/* Plate Styles - Freeform Canvas */
.plate {
    width: 400px;
    height: 400px;
    background-image: url('plate.png');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    margin: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    overflow: visible;
    cursor: crosshair;
}



.plate.drag-over {
    filter: brightness(1.1) saturate(1.2);
}

.plate-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    position: relative;
    z-index: 1;
}

.plate-placeholder {
    color: #999;
    font-style: italic;
    text-align: center;
    font-size: 0.9rem;
}

/* Nutrition Panel */
.nutrition-panel {
    background: #e8e4e0;
    border-radius: 16px;
    padding: 30px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    border: 1px solid #e8e4e0;
    width: 100%;
    max-width: 1000px;
    margin-right: 0;
}

.nutrition-panel h2 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #8b7355;
    margin-bottom: 20px;
}

.nutrition-content {
    min-height: 200px;
    background: #faf8f5;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid #e8e4e0;
}

.nutrition-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    min-height: 200px;
    color: #999;
    text-align: center;
}

.nutrition-placeholder i {
    font-size: 2rem;
    margin-bottom: 15px;
    color: #ccc;
}

.nutrition-placeholder p {
    font-style: italic;
}

/* Nutrition Facts Display */
.nutrition-facts {
    display: none;
}

.nutrition-facts.show {
    display: block;
}

.nutrition-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e8e4e0;
}

.nutrition-item:last-child {
    border-bottom: none;
}

.nutrition-label {
    font-weight: 500;
    color: #4a4a4a;
}

.nutrition-value {
    color: #666;
}

/* Action Buttons - Top Right */
.footer {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 12px;
    z-index: 100;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
}

.btn-primary {
    background: #6b8e23;
    color: white;
}

.btn-primary:hover {
    background: #556b2f;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #e8e4e0;
    color: #4a4a4a;
}

.btn-secondary:hover {
    background: #d4c4a8;
    transform: translateY(-2px);
}

/* Food Items on Plate - Freeform Canvas */
.plate-food-item {
    position: absolute;
    width: 80px;
    height: 80px;
    cursor: move;
    transition: none;
    z-index: 10;
    user-select: none;
    background: transparent;
    border: none;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    /* Hit area padding to prevent flicker */
    padding: 12px;
    margin: -12px;
}

.plate-food-item:hover {
    z-index: 20;
}

.plate-food-item.dragging {
    z-index: 30;
    opacity: 0.8;
}

/* Bounding Box Styles */
.bounding-box {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.bounding-box-border {
    position: absolute;
    top: -5px;
    left: -5px;
    right: -5px;
    bottom: -5px;
    border: 2px solid #4CAF50;
    border-radius: 6px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.bounding-box.visible .bounding-box-border {
    opacity: 1;
}

/* Action Buttons */
.action-buttons {
    position: absolute;
    top: -18px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 6px;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 25;
    pointer-events: auto;
}

.bounding-box.visible .action-buttons {
    opacity: 1;
}

.action-btn {
    width: 16px;
    height: 16px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    transition: all 0.2s ease;
    padding: 0;
}

.rotate-btn {
    color: #4CAF50;
    font-size: 10px;
}

.rotate-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

.delete-btn {
    background: white;
    color: #ff6b6b;
    font-size: 8px;
}

.delete-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 6px rgba(0,0,0,0.3);
}

/* Corner Handles */
.corner-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #4CAF50;
    border: 2px solid white;
    border-radius: 50%;
    cursor: nw-resize;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 25;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    pointer-events: auto;
}

.bounding-box.visible .corner-handle {
    opacity: 1;
}

.corner-handle.top-left {
    top: -5px;
    left: -5px;
    cursor: nw-resize;
}

.corner-handle.top-right {
    top: -5px;
    right: -5px;
    cursor: ne-resize;
}

.corner-handle.bottom-left {
    bottom: -5px;
    left: -5px;
    cursor: sw-resize;
}

.corner-handle.bottom-right {
    bottom: -5px;
    right: -5px;
    cursor: se-resize;
}

/* Food Content */
.food-content {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Plate icon adjustments for freeform */
.plate-icon {
    width: 100%;
    height: 100%;
    position: relative;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    display: flex;
    align-items: center;
    justify-content: center;
}

.emoji-icon {
    background: transparent !important;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
}

/* Custom Food Icons */
.custom-icon {
    background: transparent !important;
    position: relative;
    overflow: visible;
}

/* Broccoli Icon */
.custom-icon-broccoli {
    background-image: url('Broccoli.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    width: 100%;
    height: 100%;
    position: relative;
}

/* Onion Icon */
.custom-icon-onion {
    background-image: url('Onion.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    width: 100%;
    height: 100%;
    position: relative;
}

/* Spinach Icon */
.custom-icon-spinach {
    background-image: url('Spinach.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    width: 100%;
    height: 100%;
    position: relative;
}

/* Mushroom Icon */
.custom-icon-mushroom {
    background-image: url('Mushroom.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    width: 100%;
    height: 100%;
    position: relative;
}

/* Protein Icons */
.custom-icon-shrimp {
    background-image: url('shrimp.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    width: 100%;
    height: 100%;
    position: relative;
}

.custom-icon-salmon {
    background-image: url('salmon.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    width: 100%;
    height: 100%;
    position: relative;
}

.custom-icon-steak {
    background-image: url('steak.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    width: 100%;
    height: 100%;
    position: relative;
}

.custom-icon-chicken {
    background-image: url('chicken.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    width: 100%;
    height: 100%;
    position: relative;
}

.custom-icon-eggs {
    background-image: url('eggs.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    width: 100%;
    height: 100%;
    position: relative;
}

/* Carb Icons */
.custom-icon-potato {
    background-image: url('potato.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    width: 100%;
    height: 100%;
    position: relative;
}

.custom-icon-rice {
    background-image: url('rice.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    width: 100%;
    height: 100%;
    position: relative;
}

.custom-icon-pasta {
    background-image: url('pasta.png');
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    width: 100%;
    height: 100%;
    position: relative;
}

/* Plate icon adjustments */
.plate-icon {
    width: 50px;
    height: 50px;
    position: relative;
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
}

/* Protein icons on plate - tighter cropping */
.plate-food-item .custom-icon-shrimp {
    background-size: 150%;
}

.plate-food-item .custom-icon-salmon {
    background-size: 150%;
}

.plate-food-item .custom-icon-steak {
    background-size: 120%;
}

.plate-food-item .custom-icon-chicken {
    background-size: 150%;
}

.plate-food-item .custom-icon-eggs {
    background-size: 150%;
}

/* Drag passthrough for plate items */
.is-dragging .plate-food-item,
.is-dragging .plate-food-item * {
  pointer-events: none !important;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .food-elements-panel {
        position: relative;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid #e8e4e0;
        margin-bottom: 30px;
    }
    
    .main-content {
        margin-left: 0;
        flex-direction: column;
        gap: 30px;
        align-items: center;
    }
    
    .meal-plate-panel {
        max-width: 100%;
        padding: 0 20px;
    }
    
    .nutrition-panel {
        max-width: 100%;
        margin-right: 20px;
    }
    
    .plate {
        width: 350px;
        height: 350px;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .header h1 {
        font-size: 2rem;
    }
    
    .food-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .plate {
        width: 300px;
        height: 300px;
    }
    
    .food-categories {
        flex-direction: column;
    }
    
    .food-elements-panel {
        padding: 20px;
    }
    
    .meal-plate-panel {
        padding: 0 15px;
    }
    
    .nutrition-panel {
        margin-right: 15px;
    }
}

@media (max-width: 480px) {
    .food-grid {
        grid-template-columns: 1fr;
    }
    
    .plate {
        width: 250px;
        height: 250px;
    }
    
    .footer {
        flex-direction: column;
        align-items: center;
    }
}
