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

:root {
    --bg-dark: #191919;
    --card-bg: #2d2d2d;
    --text-light: #ffffff;
    --text-dim: #a0a0a0;
    --border-dark: #333333;
    --bake-tag: #8c713b;
    --lauk-tag: #3b5f42;
    --soup-tag: #3f5573;
    --bake-card: #2e2a1d;
    --lauk-card: #1f2820;
    --soup-card: #202731;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: #f4f7f6;
    color: #333;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden; /* Prevent body scroll, let views handle it */
}

body.theme-dark {
    background-color: var(--bg-dark);
    color: var(--text-light);
}

/* -------------------------------------
 * Dashboard Styles (Notion-like)
 * ------------------------------------- */

.dashboard-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    padding: 20px;
    background-color: var(--bg-dark);
    overflow-y: auto;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    margin-top: 20px;
}

.dashboard-title {
    font-size: 2rem;
    font-weight: 600;
}

.primary-btn {
    background-color: #2b80ff;
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.primary-btn:hover {
    background-color: #1a6ff0;
}

.board-columns {
    display: flex;
    gap: 20px;
    overflow-x: auto;
    padding-bottom: 20px;
    /* Hide scrollbar for cleaner look */
    scrollbar-width: none;
}
.board-columns::-webkit-scrollbar {
    display: none;
}

.board-column {
    min-width: 280px;
    width: 280px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.column-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
}

.category-tag {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 500;
}

.tag-bake { background-color: var(--bake-tag); color: #ffd685; }
.tag-lauk { background-color: var(--lauk-tag); color: #a4dfa7; }
.tag-soup { background-color: var(--soup-tag); color: #9abeff; }

.recipe-count {
    color: var(--text-dim);
    font-size: 0.85rem;
    flex-grow: 1;
}

.add-to-column-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 4px;
}
.add-to-column-btn:hover {
    background-color: rgba(255,255,255,0.1);
}

.column-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 100px; /* Drop zone */
}

.recipe-card {
    border-radius: 8px;
    padding: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: transform 0.1s, background-color 0.2s;
    user-select: none;
}

.recipe-card:hover {
    background-color: rgba(255,255,255,0.05);
}
.recipe-card:active {
    transform: scale(0.98);
}

.recipe-card-icon {
    font-size: 1.2rem;
}

.recipe-card-title {
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-light);
}

/* Category Specific Card Backgrounds */
.board-column[data-category="Bake"] .recipe-card { background-color: var(--bake-card); }
.board-column[data-category="Lauk"] .recipe-card { background-color: var(--lauk-card); }
.board-column[data-category="Soup"] .recipe-card { background-color: var(--soup-card); }


/* -------------------------------------
 * App Layout - Recipe Builder
 * ------------------------------------- */
.app-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    background-color: #fff; /* Builder keeps light theme for now */
    color: #333; /* Override dark theme for builder */
    overflow: hidden;
}

.header-top {
    display: flex;
    justify-content: space-between;
    width: 100%;
    margin-bottom: 10px;
}

.back-btn {
    background: none;
    border: 1px solid #ddd;
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}
.back-btn:hover {
    background: #f0f0f0;
}

.category-select {
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.9rem;
    background: #fff;
}

/* Sidebar: Ingredient Library - Mobile First */
.sidebar {
    width: 100%;
    height: 35vh; /* Top portion of the screen on mobile */
    min-height: 250px;
    background-color: #f9f9f9;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    padding: 15px;
    border-bottom: 1px solid #eee;
    background-color: #fff;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-header h2 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: #444;
}

#search-bar {
    width: 100%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 0.9rem;
}

#search-bar:focus {
    outline: none;
    border-color: #007bff;
}

.ingredient-library {
    flex-grow: 1;
    overflow-y: auto;
    padding: 15px;
    display: grid;
    /* Smaller grid items for mobile */
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 10px;
    align-content: start;
}

/* Individual Ingredient Item (Library) */
.ingredient-item {
    background-color: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 8px;
    text-align: center;
    cursor: pointer; /* Changed from grab to pointer for tap interaction */
    transition: transform 0.2s, box-shadow 0.2s, background-color 0.2s;
    user-select: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    /* Give touch targets a minimum size */
    min-height: 80px;
}

.ingredient-item:active {
    background-color: #e0f0ff;
    transform: scale(0.95);
}

.ingredient-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

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

.ingredient-icon {
    font-size: 2rem;
    margin-bottom: 5px;
}

.ingredient-name {
    font-size: 0.8rem;
    color: #555;
    word-break: break-word;
}

/* Main Content: Recipe Canvas */
.main-content {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    height: 65vh; /* Remaining screen space */
}

.canvas-header {
    padding: 15px;
    border-bottom: 1px solid #eee;
    display: flex;
    flex-direction: column; /* Stack vertically on small screens */
    gap: 10px;
    align-items: flex-start;
    background-color: #fff;
}

.recipe-title {
    font-size: 1.2rem;
    font-weight: 600;
    border: none;
    outline: none;
    width: 100%;
    padding: 5px;
    background: transparent;
}

.view-controls {
    display: flex;
    width: 100%;
    justify-content: flex-end;
}

.recipe-title:focus {
    border-bottom: 2px dashed #007bff;
}

.view-controls button {
    padding: 8px 12px;
    margin-left: 10px;
    border: 1px solid #ddd;
    background-color: #fff;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s;
}

.view-controls button.active {
    background-color: #007bff;
    color: #fff;
    border-color: #007bff;
}

.view-controls button:hover:not(.active) {
    background-color: #f0f0f0;
}

/* Recipe Canvas Drop Zone */
.recipe-canvas {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    background-color: #fff;
    position: relative;
    /* Optional: add a dotted border to show it's a drop zone */
    border: 2px dashed transparent;
    transition: border-color 0.3s;
}

.recipe-canvas.drag-over {
    border-color: #007bff;
    background-color: rgba(0, 123, 255, 0.05);
}

.empty-state {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #aaa;
    font-size: 1.2rem;
    pointer-events: none;
}

/* Recipe Items Container */
.recipe-items {
    min-height: 100%;
}

/* Grid View */
.recipe-items.grid-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 20px;
    align-content: start;
}

/* List View */
.recipe-items.list-view {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Individual Dropped Recipe Item */
.recipe-item {
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    display: flex;
    align-items: center;
    position: relative;
}

/* Grid View Item Adjustments */
.grid-view .recipe-item {
    flex-direction: column;
    text-align: center;
    padding: 15px;
}

.grid-view .recipe-item .ingredient-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.grid-view .recipe-item .ingredient-name {
    font-size: 0.9rem;
}

/* List View Item Adjustments */
.list-view .recipe-item {
    flex-direction: row;
    padding: 10px 20px;
}

.list-view .recipe-item .ingredient-icon {
    font-size: 2rem;
    margin-right: 15px;
    margin-bottom: 0;
}

.list-view .recipe-item .ingredient-name {
    font-size: 1rem;
    flex-grow: 1;
}

/* Remove Button */
.remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: #ff4d4f;
    color: white;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 0.7rem;
    cursor: pointer;
    opacity: 1; /* Always visible on mobile touch screens */
    transition: opacity 0.2s;
}

/* Quantity Input (Optional, for later enhancement) */
.quantity-input {
    display: none; /* Hidden by default in alpha */
    margin-top: 10px;
    width: 80%;
    padding: 5px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 0.8rem;
    text-align: center;
}

.grid-view .recipe-item .quantity-input {
    display: block;
}

.list-view .recipe-item .quantity-input {
    display: block;
    width: 80px;
    margin-top: 0;
    margin-right: 20px;
}

/* Desktop Media Query */
@media (min-width: 768px) {
    .app-container {
        flex-direction: row;
        width: 95%;
        max-width: 1200px;
        height: 90vh;
        border-radius: 12px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    }

    .sidebar {
        width: 30%;
        min-width: 300px;
        height: auto;
        border-bottom: none;
        border-right: 1px solid #eee;
    }

    .sidebar-header {
        padding: 20px;
        flex-direction: column;
    }

    .ingredient-library {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        padding: 20px;
    }

    .ingredient-item {
        cursor: grab;
    }

    .ingredient-item:active {
        cursor: grabbing;
        transform: none;
    }

    .main-content {
        height: auto;
    }

    .canvas-header {
        padding: 20px;
        flex-direction: row;
        align-items: center;
    }

    .recipe-title {
        font-size: 1.5rem;
        width: 60%;
    }

    .view-controls {
        width: auto;
    }

    /* Desktop Hover States */
    .remove-btn {
        opacity: 0; /* Hide by default on desktop */
    }

    .recipe-item:hover .remove-btn {
        opacity: 1; /* Show on hover for mouse users */
    }
}