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

body {
    font-family: 'Georgia', 'Times New Roman', serif;
    background-color: #e8e8e8;
    color: #333;
    padding: 0px;
    max-width: 1400px;
    margin: 0 auto;
    position: relative;
    height: 100vh; 
    overflow: hidden;  
}

/* Background image */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    background-image: url('https://images.unsplash.com/photo-1556911220-bff31c812dba?w=1920&q=80');
    background-size: cover;
    background-position: center;
    background-attachment: fixed;
    opacity: 0.4;
    filter: blur(2px);
}

/* Header Styling */
h1 {
    text-align: center;
    color: #1a1a1a;
    font-size: 3.5rem;
    margin: 10px 0 10px 0;
    font-weight: 400;
    letter-spacing: 2px;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 10px 20px 0;
    max-width: 1400px;
    margin: 0 auto;
}

/* Add tagline after h1 */
h1::after {
    content: 'STORE YOUR FAVORITE RECIPES';
    display: block;
    font-size: 0.9rem;
    letter-spacing: 4px;
    color: #4a7c59;
    margin-top: 15px;
    font-weight: 300;
    border-bottom: 1px solid #333;
    padding-bottom: 30px;
    margin-bottom: 0px;
}

/* Scrollable content area - STARTS BELOW the black line */
.scrollable-content {
    position: absolute;
    top: 140px;  
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;  
    padding: 20px;

    /* Hide scrollbar but keep scroll functionality */
    scrollbar-width: none; 
    -ms-overflow-style: none; 
}

.scrollable-content::-webkit-scrollbar {
    display: none; 
}

/* Two Column Layout Container */
.container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 60px;
    align-items: start;
}

/* Left Column - Add Recipe */
.add-recipe-section {
    grid-column: 1;
}

/* Right Column - Your Recipes */
.recipes-section {
    grid-column: 2;
}

h2 {
    color: #1a1a1a;
    font-size: 2rem;
    margin-bottom: 25px;
    font-weight: 400;
    text-align: center;
}

/* Recipe Input Section */
form {
    background-color: #fff;
    padding: 35px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    max-width: 480px;
    margin: 0 auto;
}

label {
    display: block;
    margin-bottom: 8px;
    font-weight: 400;
    color: #1a1a1a;
    font-size: 0.95rem;
}

input[type="text"],
input[type="url"],
textarea {
    width: 100%;
    padding: 12px;
    margin-bottom: 20px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    font-family: 'Arial', sans-serif;
    font-size: 0.95rem;
    background-color: #fafafa;
    transition: border-color 0.3s ease, background-color 0.3s ease;
}

input[type="text"]:focus,
input[type="url"]:focus,
textarea:focus {
    outline: none;
    border-color: #4a7c59;
    background-color: #fff;
}

textarea {
    resize: vertical;
    min-height: 80px;
}

button[type="submit"] {
    background-color: #4a7c59;
    color: white;
    padding: 14px 40px;
    border: none;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    width: 100%;
    transition: background-color 0.3s ease;
    letter-spacing: 1px;
}

button[type="submit"]:hover {
    background-color: #2c5f2d;
}

/* Recipe Display Area */
#recipeDisplay {
    display: flex;
    flex-direction: column;
    gap: 20px;
    max-width: 600px;
    margin: 0 auto;
}

/* Recipe cards styling */
.recipe-card {
    background-color: #fff;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.recipe-card h3 {
    font-size: 2rem;
    font-weight: 400;
    margin-bottom: 20px;
    text-align: center;
    color: #4a7c59;
}

.recipe-card img {
    width: 100%;
    border-radius: 8px;
    margin-bottom: 20px;
    object-fit: cover;
    max-height: 300px;
}

.recipe-card p {
    margin-bottom: 10px;
    line-height: 1.6;
}

/* Recipe card list styling */
.recipe-card ul,
.recipe-card ol {
    margin: 10px 0 15px 20px;
    padding: 0;
}

.recipe-card li {
    margin-bottom: 8px;
    line-height: 1.6;
}

.recipe-card ul li {
    list-style-type: disc;
}

.recipe-card ol li {
    list-style-type: decimal;
}

.recipe-card div {
    margin-bottom: 15px;
}

/* Recipe Tags */
.recipe-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 12px 0;
}

.recipe-tag {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 16px;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: 'Arial', sans-serif;
    text-transform: capitalize;
}

/* Tag colors based on category */
.tag-breakfast { background-color: #FFE5B4; color: #8B4513; }
.tag-lunch { background-color: #FFE4E1; color: #DC143C; }
.tag-dinner { background-color: #E6E6FA; color: #4B0082; }
.tag-dessert { background-color: #FFB6C1; color: #C71585; }
.tag-snack { background-color: #FFDAB9; color: #FF8C00; }
.tag-appetizer { background-color: #F0E68C; color: #DAA520; }

.tag-vegan { background-color: #98FB98; color: #228B22; }
.tag-vegetarian { background-color: #90EE90; color: #2E8B57; }
.tag-glutenfree { background-color: #DDA0DD; color: #8B008B; }
.tag-dairyfree { background-color: #B0E0E6; color: #4682B4; }
.tag-keto { background-color: #FFE4B5; color: #D2691E; }
.tag-paleo { background-color: #F5DEB3; color: #A0522D; }

.tag-quick { background-color: #87CEEB; color: #1E90FF; }
.tag-easy { background-color: #98D8C8; color: #2F7F73; }
.tag-healthy { background-color: #C1FFC1; color: #008B00; }
.tag-comfort { background-color: #FFDEAD; color: #CD853F; }
.tag-spicy { background-color: #FFA07A; color: #FF4500; }
.tag-sweet { background-color: #FFB6D9; color: #FF1493; }

/* Default tag color for unrecognized tags */
.tag-default { background-color: #E0E0E0; color: #555; }

/* Icon buttons for Edit, Delete, and Comments */
.action-icons {
    display: flex;
    gap: 15px;
    margin-top: 20px;
    justify-content: flex-end;
}

.icon-button {
    background-color: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    transition: transform 0.2s ease;
    width: auto;
    position: relative;
}

.icon-button:hover {
    transform: scale(1.2);
}

.edit-icon {
    color: #4a7c59;
}

.delete-icon {
    color: #dc3545;
}

.comment-icon {
    color: #4a7c59;
    position: relative;
}

.print-icon {
    color: #000;
}

.download-icon {
    color: #4a7c59;
}

.comment-count {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: #dc3545;
    color: white;
    border-radius: 50%;
    font-size: 0.7rem;
    padding: 2px 5px;
    min-width: 18px;
    text-align: center;
    font-family: 'Arial', sans-serif;
}

/* Comments dropdown/modal */
.comments-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.comments-modal-content {
    background-color: white;
    padding: 30px;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.comments-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #4a7c59;
}

.comments-modal-header h3 {
    color: #4a7c59;
    margin: 0;
    font-size: 1.5rem;
}

.close-modal {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: auto;
    line-height: 1;
}

.close-modal:hover {
    color: #333;
}

/* Comment form */
.comment-form {
    margin-bottom: 25px;
    padding: 20px;
    background-color: #f9f9f9;
    border-radius: 8px;
}

.comment-form input,
.comment-form textarea {
    width: 100%;
    padding: 12px;
    margin-bottom: 12px;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    font-family: 'Arial', sans-serif;
    font-size: 0.95rem;
}

.comment-form input {
    height: 45px;
}

.comment-form textarea {
    height: 80px;
    resize: vertical;
}

.comment-form button {
    background-color: #4a7c59;
    color: white;
    padding: 10px 25px;
    border: none;
    border-radius: 6px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background-color 0.3s ease;
    width: auto;
}

.comment-form button:hover {
    background-color: #2c5f2d;
}

/* Comments list */
.comments-list {
    margin-top: 20px;
}

.comment-item {
    background-color: #f9f9f9;
    padding: 15px;
    margin-bottom: 12px;
    border-radius: 8px;
    border-left: 4px solid #4a7c59;
}

.comment-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.comment-author {
    font-weight: 600;
    color: #4a7c59;
    font-size: 1rem;
}

.comment-delete-icon {
    background: none;
    border: none;
    color: #dc3545;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    width: auto;
}

.comment-delete-icon:hover {
    color: #c82333;
}

.comment-text {
    color: #333;
    font-size: 0.95rem;
    line-height: 1.6;
}

.no-comments {
    color: #999;
    font-style: italic;
    font-size: 0.95rem;
    text-align: center;
    padding: 20px;
}

/* Loading indicator */
.loading {
    text-align: center;
    padding: 40px;
    color: #4a7c59;
    font-size: 1.2rem;
}

.error-message {
    background-color: #f8d7da;
    color: #721c24;
    padding: 15px;
    border-radius: 6px;
    margin: 20px auto;
    max-width: 600px;
    text-align: center;
}

/* Search input */
#searchInput {
    position: fixed;
    top: 15px;
    right: 60px;
    width: 200px;
    padding: 10px 10px;
    border: 1px solid #d0d0d0;
    border-radius: 25px;
    font-family: 'Arial', sans-serif;
    font-size: 0.9rem;
    background-color: #fff;
    background-size: 18px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    z-index: 10;
}

#searchInput:focus {
    outline: none;
    border-color: #4a7c59;
    box-shadow: 0 2px 12px rgba(74, 124, 89, 0.2);
}

/* Sort icon button */
.sort-icon-button {
    position: fixed;
    top: 25px;
    right: 30px;
    background-color: transparent;
    border: none;
    padding: 0;
    cursor: pointer;
    transition: transform 0.2s ease;
    z-index: 10;
}

.sort-icon-button:hover {
    border-color: #4a7c59;
    box-shadow: 0 2px 12px rgba(74, 124, 89, 0.2);
    transform: scale(1.1);
}

/* Sort dropdown menu */
.sort-menu {
    position: fixed;
    top: 65px;
    right: 30px;
    background-color: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    min-width: 180px;
}

.sort-option {
    padding: 5px 20px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-family: 'Arial', sans-serif;
    font-size: 0.95rem;
    color: #333;
}

.sort-option:first-child {
    border-radius: 8px 8px 0 0;
}

.sort-option:last-child {
    border-radius: 0 0 8px 8px;
}

.sort-option:hover {
    background-color: #f0f0f0;
}

.sort-option.active {
    background-color: #4a7c59;
    color: white;
}

/* Recipes header with view toggle */
.recipes-header {
    position: relative;
    margin-bottom: 25px;
    text-align: center;
}

.recipes-header h2 {
    margin: 0;
    display: inline-flex;
    align-items: center;
    gap: 10px;
}

/* View toggle button */
.view-toggle-button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    transition: transform 0.2s ease;
}

.view-toggle-button:hover {
    transform: scale(1.1);
}

/* View dropdown menu */
.view-menu {
    position: absolute;
    top: 45px;
    right: 30px;
    background-color: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    min-width: 180px;
}

.view-option {
    padding: 12px 20px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-family: 'Arial', sans-serif;
    font-size: 0.95rem;
    color: #333;
}

.view-option:first-child {
    border-radius: 8px 8px 0 0;
}

.view-option:last-child {
    border-radius: 0 0 8px 8px;
}

.view-option:hover {
    background-color: #f0f0f0;
}

.view-option.active {
    background-color: #4a7c59;
    color: white;
}

/* Grid View (default - current style) */
#recipeDisplay.grid-view {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

#recipeDisplay.grid-view .recipe-card {
    background-color: #fff;
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

#recipeDisplay.grid-view .recipe-card img {
    width: 100%;
    height: 300px;
    object-fit: cover;
    border-radius: 8px;
}

/* Compact View - Side by side grid with expandable cards */
#recipeDisplay.compact-view {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

#recipeDisplay.compact-view .recipe-card {
    background-color: #fff;
    border-radius: 12px;
    padding: 0;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: all 0.3s ease;
}

#recipeDisplay.compact-view .recipe-preview {
    padding: 20px;
}

#recipeDisplay.compact-view .recipe-preview:hover {
    background-color: #f9f9f9;
}

#recipeDisplay.compact-view .recipe-card h3 {
    font-size: 1.3rem;
    margin-bottom: 0;
    margin-top: 12px;
    text-align: center;
    color: #4a7c59;
}

#recipeDisplay.compact-view .recipe-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 8px;
}

/* Placeholder in compact view matches image height */
#recipeDisplay.compact-view .recipe-image-placeholder {
    height: 180px;
}

/* Collapsible details in compact view */
#recipeDisplay.compact-view .recipe-details {
    display: none;
    padding: 20px;
    border-top: 1px solid #e0e0e0;
    background-color: #fafafa;
}

#recipeDisplay.compact-view .recipe-card.expanded .recipe-details {
    display: block;
}

/* Expanded card takes more space */
#recipeDisplay.compact-view .recipe-card.expanded {
    grid-column: span 2;
}

#recipeDisplay.compact-view .recipe-card.expanded img {
    width: 100%;
    height: 300px;
    object-fit: cover;
    border-radius: 8px;
}

/* Placeholder in expanded compact view matches image height */
#recipeDisplay.compact-view .recipe-card.expanded .recipe-image-placeholder {
    height: 300px;
}

/* On smaller screens, expanded card spans all columns */
@media (max-width: 900px) {
    #recipeDisplay.compact-view .recipe-card.expanded {
        grid-column: span 1;
    }
}

/* List View - Accordion style */
#recipeDisplay.list-view {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#recipeDisplay.list-view .recipe-card {
    background-color: #fff;
    border-radius: 8px;
    padding: 0;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

#recipeDisplay.list-view .recipe-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    cursor: pointer;
    background-color: #f9f9f9;
    transition: background-color 0.2s ease;
}

#recipeDisplay.list-view .recipe-header:hover {
    background-color: #f0f0f0;
}

#recipeDisplay.list-view .recipe-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: #4a7c59;
}

#recipeDisplay.list-view .recipe-expand-icon {
    font-size: 1.2rem;
    color: #666;
    transition: transform 0.3s ease;
}

#recipeDisplay.list-view .recipe-card.expanded .recipe-expand-icon {
    transform: rotate(180deg);
}

#recipeDisplay.list-view .recipe-card.expanded img {
    width: 100%;
    height: 300px;
    object-fit: cover;
    border-radius: 8px;
}

#recipeDisplay.list-view .recipe-content {
    display: none;
    padding: 20px;
    border-top: 1px solid #e0e0e0;
}

#recipeDisplay.list-view .recipe-card.expanded .recipe-content {
    display: block;
}

#recipeDisplay.list-view .recipe-card img {
    height: 300px;
    margin-bottom: 15px;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .container {
        grid-template-columns: 1fr;
    }

    .add-recipe-section,
    .recipes-section {
        grid-column: 1;
    }
}

@media (max-width: 768px) {
    body {
        padding: 15px;
    }

    h1 {
        font-size: 2.5rem;
        margin: 20px 0;
    }

    h1::after {
        font-size: 0.75rem;
        letter-spacing: 3px;
    }

    h2 {
        font-size: 1.5rem;
    }

    form {
        padding: 25px;
    }
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 400px;
}

.toast {
    background-color: #fff;
    border-radius: 8px;
    padding: 16px 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s ease-out;
    border-left: 4px solid #4a7c59;
    min-width: 300px;
}

.toast.success {
    border-left-color: #4a7c59;
}

.toast.error {
    border-left-color: #dc3545;
}

.toast.warning {
    border-left-color: #ffc107;
}

.toast.info {
    border-left-color: #17a2b8;
}

.toast-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.toast.success .toast-icon::before {
    content: '✓';
    color: #4a7c59;
}

.toast.error .toast-icon::before {
    content: '✕';
    color: #dc3545;
}

.toast.warning .toast-icon::before {
    content: '⚠';
    color: #ffc107;
}

.toast.info .toast-icon::before {
    content: 'ℹ';
    color: #17a2b8;
}

.toast-content {
    flex: 1;
    font-family: 'Arial', sans-serif;
    font-size: 0.95rem;
    color: #333;
}

.toast-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    transition: color 0.2s ease;
}

.toast-close:hover {
    color: #333;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.toast.hiding {
    animation: slideOut 0.3s ease-out forwards;
}

/* Recipe Image Placeholder */
.recipe-image-placeholder {
    width: 100%;
    height: 300px;
    background-color: #f0f0f0;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.recipe-image-placeholder .icon {
    font-size: 4rem;
    margin-bottom: 10px;
}

.recipe-image-placeholder .text {
    font-size: 0.9rem;
    color: #999;
    font-family: 'Arial', sans-serif;
}