:root {
    --primary-color: #2196F3;
    --secondary-color: #4CAF50;
    --background-color: #f5f5f5;
    --text-color: #333;
}

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

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    min-height: 100vh;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    background-attachment: fixed;
    position: relative;
    background-color: var(--background-color);
}

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.85);
    z-index: -1;
}

header {
    background-color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    padding: 1rem;
    position: sticky;
    top: 0;
    z-index: 1000;
}

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

.logo a {
    font-size: 1.5rem;
    text-decoration: none;
    color: var(--text-color);
    font-weight: bold;
}

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

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

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

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #43A047;
    transform: translateY(-1px);
}

.search-bar {
    flex: 1;
    display: flex;
    gap: 1rem;
    align-items: center;
    max-width: 600px;
}

.search-input {
    position: relative;
    flex: 1;
}

.search-input i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
}

.search-input input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.95rem;
    background-color: #f8f9fa;
    transition: all 0.2s ease;
}

.search-input input::placeholder {
    color: #666;
    transition: color 0.2s ease;
}

.search-input input:focus::placeholder {
    color: transparent;
}

.category-filter select {
    padding: 0.75rem 2rem 0.75rem 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 0.95rem;
    background-color: #f8f9fa;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23666' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    min-width: 160px;
}

.category-filter select:focus {
    background-color: #fff;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
    outline: none;
}

.recipe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 2rem;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
}

.recipe-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
    border: 3px solid transparent;
}

.recipe-card[data-categories*="BTCOG"] {
    outline: 3px solid #f60707 !important;
}

.recipe-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.recipe-card a {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.recipe-card img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    border-radius: 8px 8px 0 0;
}

.placeholder-image {
    width: 100%;
    height: 200px;
    background-color: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #adb5bd;
    font-size: 3rem;
    border-radius: 8px 8px 0 0;
}

.recipe-details .placeholder-image {
    height: 400px;
    border-radius: 8px;
}

.step-image .placeholder-image {
    height: 300px;
    border-radius: 8px;
    background-color: #f8f9fa;
}

.recipe-info {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
}

.recipe-info h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-color);
}

.recipe-meta {
    font-size: 0.9rem;
    color: #666;
}

.categories {
    display: block;
    font-style: italic;
}

.auth-container {
    max-width: 400px;
    margin: 2rem auto;
    padding: 2rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.form-group input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 1rem;
}

.error-message {
    background-color: #ffebee;
    color: #c62828;
    padding: 0.5rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.auth-container form {
    margin-bottom: 1rem;
}

.auth-container p {
    text-align: center;
    margin-top: 1rem;
}

.auth-container a {
    color: var(--primary-color);
    text-decoration: none;
}

.auth-container a:hover {
    text-decoration: underline;
}

.success-message {
    background-color: #e8f5e9;
    color: #2e7d32;
    padding: 0.5rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.no-recipes {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    color: #666;
}

.recipe-grid .error-message {
    grid-column: 1 / -1;
    text-align: center;
    padding: 2rem;
    background-color: #ffebee;
    color: #c62828;
    border-radius: 4px;
}

.recipe-details {
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 1rem;
}

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

.back-link {
    color: var(--primary-color);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
}

.back-link:hover {
    text-decoration: underline;
}

.recipe-meta {
    color: #666;
    margin-bottom: 2rem;
}

.recipe-meta span {
    margin-right: 1rem;
}

.recipe-details .recipe-image {
    margin: 2rem 0;
    border-radius: 8px;
    overflow: hidden;
}

.recipe-details .recipe-image img {
    width: 100%;
    max-height: 400px;
    object-fit: cover;
}

.ingredients-section {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.ingredients-list {
    list-style: none;
    padding: 0;
}

.ingredients-list li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #eee;
}

.ingredients-list li:last-child {
    border-bottom: none;
}

.amount {
    font-weight: bold;
    margin-right: 0.5rem;
}

.unit {
    color: #666;
    margin-right: 0.5rem;
}

.recipe-form {
    max-width: 800px;
    margin: 2rem auto;
    padding: 2rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.recipe-current-image {
    max-width: 300px;
    border-radius: 4px;
    margin: 1rem 0;
}

.ingredient-row {
    display: grid;
    grid-template-columns: 15% 15% minmax(0, 1fr) auto;
    gap: 1rem;
    margin-bottom: 1rem;
}

.ingredient-row input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

#add-ingredient {
    margin: 1rem 0;
}

.form-actions {
    margin: 2rem 0;
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

.form-actions-top {
    margin-bottom: 2rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 1rem;
}

.form-actions-bottom {
    margin-top: 2rem;
    border-top: 1px solid #eee;
    padding-top: 1rem;
}

.ingredients-section {
    margin: 2rem 0;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 4px;
}

.instructions-section,
.notes-section,
.stories-section {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-top: 2rem;
}

.instructions-section h2 {
    margin: 0 0 1rem 0;
    padding: 0;
}

.instructions {
    white-space: pre-wrap;
    line-height: 1.8;
    margin: 0;
    padding: 0;
    text-align: left;
    text-indent: 0;
}

.instructions p {
    margin: 0;
    padding: 0;
}

.note,
.story {
    border-bottom: 1px solid #eee;
    padding: 1rem 0;
}

.note:last-child,
.story:last-child {
    border-bottom: none;
}

.note-meta,
.story-meta {
    color: #666;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.note-text,
.story-text {
    line-height: 1.6;
}

textarea {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: inherit;
    font-size: 1rem;
    resize: vertical;
}

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

.modal-content {
    background-color: white;
    margin: 10% auto;
    padding: 2rem;
    width: 80%;
    max-width: 600px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: relative;
}

.modal-content textarea {
    width: 100%;
    margin: 1rem 0;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: monospace;
}

.modal-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 1rem;
}

.modal-content p {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.modal-actions {
    margin-top: 1rem;
    text-align: right;
}

.modal-actions button {
    margin-left: 0.5rem;
}

.btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

/* Introduction page styles */
.introduction-content {
    max-width: 800px;
    margin: 2rem auto;
    padding: 0 1rem;
}

.intro-text {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    margin-bottom: 2rem;
    line-height: 1.8;
    white-space: pre-wrap;
    text-indent: 0;
}

.intro-text p {
    margin: 0;
    padding: 0;
}

.intro-text br + br {
    display: block;
    margin: 1em 0;
}

.timeline {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.timeline-entry {
    display: flex;
    gap: 2rem;
    padding: 1rem 0;
    border-bottom: 1px solid #eee;
}

.timeline-entry:last-child {
    border-bottom: none;
}

.timeline-year {
    font-weight: bold;
    min-width: 60px;
    color: var(--primary-color);
}

.timeline-event {
    flex: 1;
    line-height: 1.6;
}

/* Edit introduction page styles */
.edit-introduction {
    max-width: 800px;
    margin: 2rem auto;
    padding: 2rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.timeline-entry-edit {
    display: grid;
    grid-template-columns: 100px 1fr auto;
    gap: 1rem;
    margin-bottom: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 4px;
    align-items: start;
}

.timeline-entry-edit input[type="number"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.timeline-entry-edit textarea {
    width: 100%;
    min-height: 100px;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: vertical;
}

#add-timeline-entry {
    margin: 1rem 0 2rem;
}

.form-actions {
    margin-top: 2rem;
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* Success and error messages */
.success-message {
    background-color: #e8f5e9;
    color: #2e7d32;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.error-message {
    background-color: #ffebee;
    color: #c62828;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

/* Add these styles */
.category-selection {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

#new-category-input {
    display: none;
    gap: 1rem;
    align-items: start;
}

#new-category-input input {
    flex: 1;
    min-width: 200px;
}

/* Add these styles for the login page */
.auth-container {
    max-width: 400px;
    margin: 2rem auto;
    padding: 2rem;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.auth-container h2 {
    margin-bottom: 1.5rem;
    text-align: center;
}

.auth-container .form-group {
    margin-bottom: 1rem;
}

.auth-container label {
    display: block;
    margin-bottom: 0.5rem;
}

.auth-container input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.auth-container button {
    width: 100%;
    margin-top: 1rem;
}

.auth-container p {
    margin-top: 1rem;
    text-align: center;
}

.error-message {
    background-color: #ffebee;
    color: #c62828;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1rem;
}

.ingredient-buttons {
    margin-top: 1rem;
    display: flex;
    gap: 1rem;
}

.ingredient-buttons button {
    flex: 0 0 auto;
}

.ingredient-section {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.section-header {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: center;
}

.section-title {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-weight: bold;
}

.ingredients-container {
    margin-bottom: 1rem;
}

#ingredient-sections {
    margin-bottom: 1rem;
}

.category-selection select[multiple] {
    min-height: 120px;
    padding: 0.5rem;
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.category-selection select[multiple] option {
    padding: 0.5rem;
    border-bottom: 1px solid #eee;
}

.category-selection select[multiple] option:last-child {
    border-bottom: none;
}

.category-selection small {
    display: block;
    color: #666;
    margin-bottom: 0.5rem;
}

/* iOS-specific styles */
@supports (-webkit-touch-callout: none) {
    /* CSS specific to iOS devices */
    .recipe-form {
        /* Adjust form padding for better touch targets */
        padding: 20px 16px;
    }

    .ingredient-row {
        /* More space between ingredient inputs */
        margin-bottom: 15px;
        /* Stack inputs vertically on iOS */
        flex-direction: column;
        gap: 10px;
    }

    .ingredient-row input {
        /* Larger touch targets */
        height: 44px;
        font-size: 16px; /* Prevents iOS zoom on focus */
        width: 100%;
    }

    /* Larger buttons for better touch targets */
    .btn {
        min-height: 44px;
        padding: 12px 20px;
        font-size: 16px;
    }

    /* Adjust select boxes */
    select {
        height: 44px;
        font-size: 16px;
    }

    /* Adjust text inputs */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    textarea {
        font-size: 16px; /* Prevents iOS zoom on focus */
        padding: 12px;
    }

    /* Modal adjustments */
    .modal-content {
        padding: 20px;
        width: 90%;
        max-width: none;
        margin: 20px auto;
    }

    /* Navigation adjustments */
    .nav-links {
        gap: 15px;
    }

    /* Recipe card adjustments */
    .recipe-card {
        margin: 15px 0;
    }
}

/* Additional iPhone-specific adjustments using User Agent */
@media screen and (max-width: 428px) {
    /* iPhone-specific landscape mode */
    @media (orientation: landscape) {
        .recipe-form {
            max-width: 100%;
            margin: 10px;
        }
    }

    /* iPhone-specific portrait mode */
    @media (orientation: portrait) {
        .recipe-form {
            margin: 10px;
        }

        .form-group {
            margin-bottom: 20px;
        }
    }
}

@media only screen and (max-width: 430px) {
    .desktop-only {
        display: none !important;
    }

    header {
        padding: 8px !important;
    }

    nav {
        flex-direction: column !important;
        gap: 8px !important;
        padding: 0 !important;
    }

    .search-bar {
        display: flex !important;
        width: 100% !important;
        gap: 8px !important;
    }

    .search-input {
        width: 60% !important;
    }

    .category-filter {
        width: 40% !important;
    }

    .recipe-grid {
        grid-template-columns: 1fr !important;
        padding: 1rem !important;
        gap: 1rem !important;
    }

    .nav-links {
        justify-content: flex-end !important;
        gap: 8px !important;
    }

    /* Recipe action buttons */
    .recipe-actions .btn {
        padding: 6px 12px;
        font-size: 0.8rem;
        min-width: auto;
    }

    /* Hide full text and show mobile text on small screens */
    .recipe-actions .btn {
        font-size: 0.85rem;
        padding: 8px 16px;
    }

    .recipe-actions .btn::before {
        content: attr(data-mobile-text);
    }

    .recipe-actions .btn {
        font-size: 0;
    }

    .recipe-actions .btn::before {
        font-size: 0.85rem;
    }

    /* Search input modifications */
    .search-input i {
        display: none;
    }

    .search-input input {
        padding: 0.75rem 1rem;
    }

    .search-input input::placeholder {
        color: #666;
    }
}