/*
 * Application-wide styles for the Recipe Book application.
 * With Propshaft, all CSS files in app/assets/stylesheets are automatically included.
 */

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background-color: #fafbfc;
    background-image: 
        radial-gradient(circle at 25% 25%, rgba(40, 167, 69, 0.02) 0%, transparent 50%),
        radial-gradient(circle at 75% 75%, rgba(40, 167, 69, 0.01) 0%, transparent 50%);
    color: #333;
    line-height: 1.6;
}

.header {
    background: white;
    border-bottom: 1px solid #e5e5e5;
    padding: 1.5rem 0;
    margin-bottom: 2rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 2rem;
}

.logo {
    font-size: 1.5rem;
    font-weight: 600;
    color: #333;
    text-decoration: none;
}

.search-container {
    position: relative;
    flex: 1;
    max-width: 400px;
    margin: 0 2rem;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.9rem;
    background: #f8f9fa;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-input:focus {
    outline: none;
    border-color: #28a745;
    background: white;
    transform: translateY(-1px);
    box-shadow: 
        0 0 0 3px rgba(40, 167, 69, 0.1),
        0 4px 12px rgba(40, 167, 69, 0.1);
}

.btn-primary {
    background: #28a745;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-block;
    position: relative;
    overflow: hidden;
}

.btn-primary:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.btn-primary::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.btn-primary:hover::before {
    left: 100%;
}

.recipe-card.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    border-radius: 12px;
    z-index: 10;
}

.search-input.searching {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16zM2 12C2 6.477 6.477 2 12 2s10 4.477 10 10-4.477 10-10 10S2 17.523 2 12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
}

.nav-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.logout-btn {
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}


.recipes-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1.5rem;
    margin-bottom: 4rem;
}

.recipe-card {
    background: white;
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid rgba(0, 0, 0, 0.06);
    cursor: pointer;
}

.recipe-card a,
.recipe-card button {
    position: relative;
    z-index: 10;
}

.recipe-card:hover {
    transform: translateY(-4px);
    border-color: rgba(40, 167, 69, 0.1);
    box-shadow: 
        0 8px 25px rgba(0, 0, 0, 0.08),
        0 0 0 1px rgba(40, 167, 69, 0.05);
}

.recipe-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.recipe-title {
    font-size: 1.375rem;
    font-weight: 650;
    color: #333;
    margin-bottom: 0.25rem;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.3;
    letter-spacing: -0.01em;
}

.recipe-title:hover {
    color: #28a745;
}

.recipe-meta {
    font-size: 0.875rem;
    color: #64748b;
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.recipe-source {
    font-size: 0.8rem;
    color: #999;
    text-decoration: none;
}

.recipe-actions {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.btn-secondary {
    background: #f8f9fa;
    color: #6c757d;
    border: 1px solid #dee2e6;
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    text-align: center;
}

.btn-secondary:hover {
    background: #e9ecef;
    color: #495057;
}

.btn-danger {
    background: #f8f9fa;
    color: #6c757d;
    border: 1px solid #dee2e6;
}

.btn-danger:hover {
    background: #dc3545;
    color: white;
    border-color: #dc3545;
}

.recipe-preview {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #f0f0f0;
    position: relative;
}

.ingredients-preview {
    font-size: 0.75rem;
}

.ingredients-preview h4 {
    font-size: 0.85rem;
    font-weight: 600;
    color: #666;
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.ingredients-list {
    list-style: none;
    padding-left: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.2rem;
    max-height: 120px;
    overflow: hidden;
    position: relative;
}

.ingredients-list::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 20px;
    background: linear-gradient(transparent, white);
    pointer-events: none;
}

.ingredients-list li {
    padding: 0.1rem 0;
    color: #555;
    position: relative;
    padding-left: 1rem;
}

.ingredients-list li:before {
    content: "•";
    color: #28a745;
    font-weight: bold;
    position: absolute;
    left: 0;
}


.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: #666;
}

.empty-state h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 300;
}

/* Recipe Detail styles moved to recipes.css to avoid duplication */

/* Recipe Edit/New Page */
.recipe-form {
    max-width: 800px;
    margin: 0 auto;
}

.recipe-form-header {
    margin-bottom: 2rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e5e5e5;
}

.recipe-form-title {
    font-size: 2.5rem;
    font-weight: 600;
    color: #333;
    margin-bottom: 0.5rem;
    line-height: 1.2;
}

/* Import Section */
.import-section {
    background: #f8f9fa;
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 2rem;
}

.import-heading {
    font-size: 1.1rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.import-form {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.import-form .form-input {
    flex: 1;
    margin-bottom: 0;
}

.btn-import {
    background: #28a745;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    min-width: 150px;
}

.btn-import:hover:not(:disabled) {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.btn-import:disabled {
    background: #6c757d;
    cursor: not-allowed;
    opacity: 0.6;
}

.import-error {
    background-color: #2c3e50;
    color: white;
    border-left: 4px solid #dc3545;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.import-error::before {
    content: "⚠";
    margin-right: 0.5rem;
    font-weight: bold;
}

.form-group {
    display: block;
    margin-bottom: 2rem;
    width: 100%;
    position: relative;
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
    margin-bottom: 0.5rem;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.form-input {
    display: block;
    width: 100%;
    max-width: 100%;
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    box-sizing: border-box;
    background-color: #fafbfc;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-input:focus {
    outline: none;
    border-color: #28a745;
    background-color: white;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1);
}

.form-textarea {
    display: block;
    width: 100%;
    max-width: 100%;
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    font-size: 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    box-sizing: border-box;
    resize: vertical;
    min-height: 120px;
    background-color: #fafbfc;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.form-textarea:focus {
    outline: none;
    border-color: #28a745;
    background-color: white;
    box-shadow: 0 0 0 3px rgba(40, 167, 69, 0.1);
}

.form-actions {
    padding-top: 2rem;
    border-top: 1px solid #e5e5e5;
    display: flex;
    gap: 1rem;
    align-items: center;
}

.btn-submit {
    background: #28a745;
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-submit:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.error-explanation {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.5rem;
}

.error-explanation h2 {
    color: #721c24;
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
}

.error-explanation ul {
    margin: 0;
    padding-left: 1.5rem;
}

.error-explanation li {
    color: #721c24;
    margin-bottom: 0.25rem;
}

/* Flash Messages */
.notice, .alert {
    max-width: 800px;
    margin: 0 auto 2rem auto;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.notice {
    background-color: #2c3e50;
    color: white;
    border-left: 4px solid #28a745;
}

.alert {
    background-color: #2c3e50;
    color: white;
    border-left: 4px solid #dc3545;
}

.notice::before {
    content: "✓";
    margin-right: 0.5rem;
    font-weight: bold;
}

.alert::before {
    content: "⚠";
    margin-right: 0.5rem;
    font-weight: bold;
}

/* Category Badge Styles */
.category-section {
    margin-bottom: 2.5rem;
}

.category-badge {
    display: inline-flex;
    align-items: center;
    color: white;
    padding: 0.6rem 1.5rem;
    border-radius: 25px;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
    background: linear-gradient(135deg, var(--category-color) 0%, var(--category-color-dark) 100%);
    border: 2px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

.category-badge:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.2);
}

.category-badge::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s ease;
}

.category-badge:hover::before {
    left: 100%;
}

.recipe-count {
    background-color: rgba(255, 255, 255, 0.25);
    padding: 0.25rem 0.75rem;
    border-radius: 15px;
    font-size: 0.9rem;
    margin-left: 0.75rem;
    font-weight: 500;
}

@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 1.5rem;
        padding: 0 1rem;
    }

    .search-container {
        margin: 0;
        max-width: 100%;
        order: 3;
        width: 100%;
    }

    .nav-actions {
        width: 100%;
        justify-content: space-between;
    }

    .form-input, .form-textarea {
        font-size: 16px;
        padding: 16px;
        min-height: 48px;
    }

    .btn-primary, .btn-secondary {
        min-height: 48px;
        padding: 12px 24px;
        font-size: 16px;
    }

    .import-form {
        flex-direction: column;
    }

    .btn-import {
        width: 100%;
        min-height: 48px;
        font-size: 16px;
    }
    
    /* Recipe detail mobile styles moved to recipes.css */

    .recipes-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .ingredients-list {
        grid-template-columns: 1fr;
    }

    /* Recipe detail mobile responsive styles moved to recipes.css */

    .notice, .alert {
        margin: 0 1rem 2rem 1rem;
    }

    .category-badge {
        font-size: 1rem;
        padding: 0.5rem 1.25rem;
    }

    .recipe-count {
        font-size: 0.8rem;
        padding: 0.2rem 0.6rem;
        margin-left: 0.5rem;
    }
}

@media (min-width: 1400px) {
    .recipes-grid {
        grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
        gap: 2rem;
    }
}

/* Enhanced Accessibility */
*:focus {
    outline: 2px solid #28a745;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .recipe-card {
        border: 2px solid #333;
    }
    
    .btn-primary {
        border: 2px solid #fff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
