/* Google Fonts Import */
@import url('https://fonts.googleapis.com/css2?family=EB+Garamond:ital,wght@0,400;0,500;0,600;1,400&display=swap');

/* ============================================
   CUSTOMIZATION SECTION - Edit fonts & colors here
   ============================================ */
:root {
    /* Colors */
    --primary-color: #a85419;
    --secondary-color: #e99378;
    --background-color: #ffffff;
    --card-background: #ffffff;
    --text-color: #1a1a1a;
    --text-secondary: #6b6b6b;
    --heading-color: #0a0a0a;
    --measurement-color: #d4572a;
    --measurement-background: #ffe8d6;
    --border-color: #e0e0e0;
    
    /* Fonts - Google Fonts */
    --font-serif: 'EB Garamond', Georgia, serif;
    --font-text: 'Inter', sans-serif;
    --font-size-base: 18px;
    --font-size-heading: 2.2rem;
    --font-size-subheading: 1.5rem;
}

/* ============================================
   LAYOUT & STRUCTURE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-text);
    font-size: var(--font-size-base);
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    padding: 0;
    margin: 0;
}

/* Site Header */
.site-header {
    background: var(--card-background);
    padding: 20px 40px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.site-header h1 {
    font-family: var(--font-serif);
    color: var(--heading-color);
    font-size: 1.5rem;
    margin: 0;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.header-buttons {
    display: flex;
    gap: 10px;
    margin-left: auto;
}

.container {
    max-width: 1366px;
    margin: 0 auto;
    width: 100%;
    padding: 20px;
}

.upload-section {
    background: var(--card-background);
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 30px;
    text-align: center;
}

.upload-section h1 {
    font-family: var(--font-serif);
    color: var(--heading-color);
    margin-bottom: 20px;
}

#fileInput {
    display: none;
}

/* ============================================
   TIMER CONTAINER (Material Design)
   ============================================ */
.timer-container {
    background: transparent;
    position: sticky;
    top: 70px;
    z-index: 99;
    max-width: 1366px;
    margin: 0 auto;
    animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.timer-list {
    padding: 15px 20px;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    max-height: 300px;
    overflow-y: auto;
}

/* Limit to max 5 timers - if more than 5, force smaller size */
.timer-list:has(.timer-item:nth-child(6)) {
    grid-template-columns: repeat(5, 1fr);
}

.timer-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 0;
    height: 64px;
    background: var(--card-background);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

/* Touch devices - taller buttons */
@media (pointer: coarse) {
    .timer-item {
        height: 54px;
    }
    
    .timer-btn {
        min-height: 44px;
        min-width: 44px;
    }
}

.timer-item:hover {
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
}

/* Progress bar background */
.timer-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    background: var(--primary-color);
    transition: width 1s linear;
    z-index: 0;
}

.timer-item.finished .timer-progress {
    background: #4caf50;
}

.timer-item.finished {
    border-color: #4caf50;
    animation: pulse 1s infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.01);
    }
}

.timer-content {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    flex: 1;
    z-index: 1;
}

.timer-display {
    font-size: 1.25rem;
    font-weight: 600;
    font-family: 'Courier New', monospace;
    color: var(--primary-color);
    min-width: 65px;
}

.timer-item.finished .timer-display {
    color: #4caf50;
}

.timer-label {
    font-size: 0.9rem;
    color: var(--text-color);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.timer-item.finished .timer-label::before {
    content: '✓ ';
    color: #4caf50;
}

.timer-controls {
    display: flex;
    gap: 0;
    z-index: 1;
}

.timer-btn {
    background: transparent;
    border: none;
    border-left: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 0;
    width: 48px;
    height: 64px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

@media (pointer: coarse) {
    .timer-btn {
        height: 54px;
        min-height: 44px;
        min-width: 44px;
    }
}

.timer-btn:hover {
    background: var(--background-color);
    color: var(--primary-color);
}

.timer-btn .material-symbols-outlined {
    font-size: 20px;
}

/* Time button in instructions */
.time-button {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--measurement-background);
    color: var(--measurement-color);
    border: 1px solid var(--measurement-color);
    padding: 2px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: all 0.2s;
    vertical-align: baseline;
}

.time-button:hover {
    background: var(--measurement-color);
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.time-button .material-symbols-outlined {
    font-size: 16px;
}


.upload-btn, .download-btn, .edit-btn {
    background-color: var(--primary-color);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.95rem;
    font-family: var(--font-text);
    display: flex;
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.download-btn {
    background-color: var(--secondary-color);
}

.edit-btn {
    display: none !important; /* Temporarily disabled */
    background-color: transparent;
    border: 2px solid var(--border-color);
    color: var(--text-color);
    padding: 8px;
    width: 40px;
    height: 40px;
    justify-content: center;
}

.upload-btn:hover, .download-btn:hover, .edit-btn:hover {
    opacity: 0.9;
}

.upload-btn .material-symbols-outlined,
.download-btn .material-symbols-outlined,
.edit-btn .material-symbols-outlined {
    font-size: 20px;
}

.upload-btn .separator,
.download-btn .separator {
    opacity: 0.5;
    font-weight: 300;
}

#recipeDisplay {
    display: none;
}

.recipe-header {
    background: transparent;
    padding: 30px 0;
    border-radius: 0;
    box-shadow: none;
}

.recipe-title-row {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 15px;
}

.recipe-title {
    font-family: var(--font-serif);
    font-size: var(--font-size-heading);
    color: var(--heading-color);
    margin: 0;
    flex: 1;
}

/* Recipe Icons (Favorite & Want to Cook) */
.recipe-icons {
    display: flex;
    gap: 10px;
    align-items: center;
}

.recipe-icon {
    font-size: 28px;
    cursor: default;
}

.favorite-icon {
    color: var(--text-color);
}

.favorite-icon.filled {
    color: #e74c3c;
    font-variation-settings: 'FILL' 1;
}

.cook-icon {
    color: var(--text-color);
    font-variation-settings: 'FILL' 1;
}

/* Recipe Image */
.recipe-image-container {
    margin: 20px 0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.recipe-image {
    width: 100%;
    height: auto;
    display: block;
    max-height: 500px;
    object-fit: cover;
}

/* Recipe Meta Info */
.recipe-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    padding: 20px;
    background-color: var(--card-background);
    border: 2px solid var(--border-color);
    border-radius: 4px;
    margin: 20px 0;
}

.meta-item {
    display: flex;
    gap: 8px;
    align-items: center;
}

.meta-label {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.meta-value {
    color: var(--text-color);
    font-size: 0.95rem;
}

.recipe-categories {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.category-tag {
    background-color: #b8502e;
    color: white;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
}

.recipe-link {
    margin-top: 10px;
    font-size: 0.9rem;
}

.recipe-link a {
    color: var(--primary-color);
    text-decoration: none;
}

.recipe-content {
    display: grid;
    grid-template-columns: 3fr 1fr;
    gap: 30px;
    margin-top: 30px;
    margin-bottom: 0;
}

/* Mobile Tabs - hidden by default on desktop */
.mobile-tabs {
    display: none;
}

.ingredients-section, .instructions-section {
    background: transparent;
    padding: 24px 24px;
    border-radius: 4px;
    box-shadow: none;
}

.ingredients-section {
    background: #3a3a3a;
    color: #f5f5f5;
    border-left: none;
    box-shadow: none;
    min-height: 100vh;
    min-width: 280px;
    align-self: stretch;
}

/* Ingredients header with scale controls */
.ingredients-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid rgba(245, 245, 245, 0.2);
}

.ingredients-header h2 {
    margin: 0;
    padding: 0;
    border: none;
}

.scale-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

.scale-btn {
    width: 32px;
    height: 32px;
    border: 2px solid #f5f5f5;
    background: transparent;
    color: #f5f5f5;
    font-size: 20px;
    font-weight: bold;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
    padding: 0;
}

.scale-btn:hover:not(:disabled) {
    background: #f5f5f5;
    color: #3a3a3a;
}

.scale-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: #888;
    color: #888;
}

.scale-factor {
    font-size: 18px;
    font-weight: 600;
    color: #f5f5f5;
    min-width: 24px;
    text-align: center;
}

/* Override colors for ingredients section on dark background */
.ingredients-section h2 {
    color: #f5f5f5;
    border-bottom-color: rgba(245, 245, 245, 0.2);
}

.ingredients-section h3 {
    color: var(--secondary-color);
}

.ingredients-section .ingredient-item {
    border-bottom-color: rgba(245, 245, 245, 0.1);
    color: #f5f5f5;
}

/* Adjust measurement colors for dark background */
.ingredients-section .measurement .number {
    color: #f5a582;
}

.ingredients-section .measurement .unit {
    color: #d0d0d0;
    font-weight: bold;
}

/* Desktop: Always show both sections */
.instructions-section,
.ingredients-section {
    display: block;
}

h2 {
    font-family: var(--font-text);
    font-size: var(--font-size-subheading);
    color: var(--heading-color);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border-color);
}

h3 {
    font-family: var(--font-text);
    font-size: 1.2rem;
    color: var(--primary-color);
    margin-top: 20px;
    margin-bottom: 15px;
}

.ingredient-group {
    margin-bottom: 25px;
}

.ingredient-group h3 {
    font-family: var(--font-text);
    font-size: 1.1rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.ingredient-item {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
    list-style: none;
}

.ingredient-item:last-child {
    border-bottom: none;
}

.measurement {
    display: inline-block;
}

.measurement .number {
    color: var(--primary-color);
    font-weight: normal;
}

.measurement .unit {
    color: var(--text-color);
    font-weight: bold;
}

.instruction-step {
    margin-bottom: 20px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.step-number {
    color: var(--text-secondary);
    font-size: 1rem;
    flex-shrink: 0;
    font-weight: normal;
}

.notes-section {
    background: transparent;
    padding: 15px 0 0 0;
    border-radius: 0;
    box-shadow: none;
    border-top: 2px solid var(--border-color);
    margin-top: 15px;
    color: var(--text-secondary);
}

.notes-section h2 {
    font-size: 1.5rem;
    margin-bottom: 10px;
}

/* Editable content styles */
[contenteditable="true"] {
    outline: 2px dashed var(--primary-color);
    outline-offset: 4px;
    padding: 4px;
    border-radius: 4px;
    background-color: rgba(196, 102, 31, 0.05);
}

[contenteditable="true"]:focus {
    outline: 2px solid var(--primary-color);
    background-color: rgba(196, 102, 31, 0.1);
}

/* Edit mode buttons */
.edit-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding: 20px 0;
    border-top: 2px solid var(--border-color);
    margin-top: 20px;
}

.save-btn, .cancel-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.95rem;
    font-family: var(--font-text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.save-btn {
    background-color: var(--primary-color);
    color: white;
}

.cancel-btn {
    background-color: var(--border-color);
    color: var(--text-color);
}

.save-btn:hover, .cancel-btn:hover {
    opacity: 0.9;
}

/* Responsive Design */

/* Remove the tablet breakpoint - iPad Pro 13" defines max width */

/* Mobile (bis 768px) */
@media (max-width: 768px) {
    .site-header {
        padding: 15px 20px;
    }
    
    .site-header h1 {
        font-size: 1.2rem;
    }
    
    .upload-btn span:not(.material-symbols-outlined),
    .edit-btn span:not(.material-symbols-outlined) {
        display: none;
    }
    
    .upload-btn, .edit-btn {
        padding: 10px;
        min-width: 44px;
        justify-content: center;
        gap: 0;
    }
    
    .upload-btn .material-symbols-outlined,
    .edit-btn .material-symbols-outlined {
        font-size: 24px;
        margin: 0;
    }
    
    .header-buttons {
        gap: 8px;
    }
    
    .container {
        padding: 10px;
    }
    
    /* Show tabs on mobile */
    .mobile-tabs {
        display: flex;
        gap: 0;
        margin-bottom: 20px;
        background: var(--card-background);
        border-radius: 8px;
        padding: 5px;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        grid-column: 1 / -1;
    }
    
    .tab-btn {
        flex: 1;
        padding: 12px 20px;
        border: none;
        background: transparent;
        color: var(--text-color);
        font-family: var(--font-serif);
        font-size: 1rem;
        cursor: pointer;
        border-radius: 5px;
        transition: all 0.3s ease;
    }
    
    .tab-btn.active {
        background: var(--primary-color);
        color: white;
    }
    
    .recipe-content {
        grid-template-columns: 1fr;
        display: grid;
    }
    
    .ingredients-section {
        border-left: none;
        padding-left: 0;
    }
    
    /* Hide inactive tab content on mobile */
    .instructions-section,
    .ingredients-section {
        display: none;
    }
    
    .instructions-section.active,
    .ingredients-section.active {
        display: block;
    }
    
    .upload-section,
    .recipe-header,
    .ingredients-section,
    .instructions-section,
    .notes-section {
        padding: 20px;
    }
    
    .upload-section h1 {
        font-size: 1.5rem;
    }
    
    .recipe-title {
        font-size: 1.6rem;
    }
    
    h2 {
        font-size: 1.2rem;
    }
    
    .instruction-step {
        flex-direction: row;
        gap: 10px;
        align-items: flex-start;
    }
    
    .step-number {
        flex-shrink: 0;
        min-width: 30px;
    }
}

/* Kleine Smartphones (bis 480px) */
@media (max-width: 480px) {
    .site-header {
        padding: 12px 15px;
    }
    
    .site-header h1 {
        font-size: 1rem;
    }
    
    .upload-btn span:not(.material-symbols-outlined):not(.separator) {
        display: none;
    }
    
    .upload-btn .separator {
        display: none;
    }
    
    .upload-btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }
    
    .upload-section,
    .recipe-header,
    .ingredients-section,
    .instructions-section,
    .notes-section {
        padding: 15px;
    }
    
    .recipe-title {
        font-size: 1.4rem;
    }
    
    h2 {
        font-size: 1.1rem;
    }
    
    h3 {
        font-size: 1rem;
    }
    
    .category-tag {
        font-size: 0.85rem;
        padding: 4px 12px;
    }
    
    .upload-btn {
        padding: 10px 20px;
        font-size: 0.9rem;
    }


}

/* Inline Edit Styles */
.edit-buttons {
    display: flex;
    gap: 10px;
    align-items: center;
}

.cancel-edit-btn,
.save-edit-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    background-color: var(--card-background);
    color: var(--text-color);
    cursor: pointer;
    font-size: 0.95rem;
    font-family: var(--font-text);
    font-weight: 600;
    transition: all 0.2s ease;
}

.save-edit-btn {
    background-color: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

.cancel-edit-btn:hover {
    background-color: var(--border-color);
}

.save-edit-btn:hover {
    opacity: 0.9;
}

.cancel-edit-btn .material-symbols-outlined,
.save-edit-btn .material-symbols-outlined {
    font-size: 18px;
}

.inline-edit-fields {
    background-color: var(--card-background);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.edit-field {
    margin-bottom: 15px;
}

.edit-field:last-child {
    margin-bottom: 0;
}

.edit-field label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    color: var(--text-color);
    font-family: var(--font-text);
    font-size: 0.95rem;
}

.edit-field input[type="text"],
.edit-field input[type="url"],
.edit-field input[type="number"],
.edit-field textarea {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: 5px;
    font-family: var(--font-text);
    font-size: 1rem;
    color: var(--text-color);
    background: var(--background-color);
    box-sizing: border-box;
}

.edit-field textarea {
    resize: vertical;
    min-height: 80px;
    font-family: 'Courier New', monospace;
}

.edit-field-checkbox {
    display: flex;
    align-items: center;
}

.edit-field-checkbox label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 600;
}

.edit-field-checkbox input[type="checkbox"] {
    width: auto;
    margin: 0;
    cursor: pointer;
    transform: scale(1.2);
}

.edit-field input:focus,
.edit-field textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* New Inline Edit Styles - Edit fields appear at content position */
.edit-input,
.edit-textarea {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--primary-color);
    border-radius: 5px;
    font-family: var(--font-text);
    font-size: 1rem;
    color: var(--text-color);
    background: var(--card-background);
    box-sizing: border-box;
    margin: 8px 0;
}

.title-edit {
    font-family: var(--font-serif);
    font-size: 2rem;
    font-weight: bold;
    padding: 15px;
}

.categories-edit,
.link-edit {
    margin-top: 10px;
    margin-bottom: 10px;
}

.meta-edit {
    width: 100%;
    margin-top: 5px;
}

.edit-textarea {
    min-height: 200px;
    font-family: 'Courier New', monospace;
    resize: vertical;
}

.ingredients-edit,
.instructions-edit {
    margin-top: 15px;
    min-height: 300px;
}

.notes-edit {
    min-height: 100px;
}

.edit-input:focus,
.edit-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(196, 102, 31, 0.1);
}

/* Edit Field Descriptions */
.edit-field-description {
    margin-top: 8px;
    margin-bottom: 5px;
    color: var(--text-secondary);
    font-size: 0.875rem;
    line-height: 1.4;
}

.edit-field-description small {
    display: block;
}

.edit-field-description code {
    background-color: rgba(196, 102, 31, 0.1);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.85em;
}

.edit-field-description a {
    color: var(--primary-color);
    text-decoration: none;
}

.edit-field-description a:hover {
    text-decoration: underline;
}

.edit-checkboxes {
    display: flex;
    gap: 20px;
    align-items: center;
    padding: 10px 0;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 600;
}

.checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Image Upload Styles */
.image-upload-container {
    margin-top: 15px;
    text-align: center;
}

.upload-image-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: 2px dashed var(--primary-color);
    border-radius: 8px;
    background-color: rgba(196, 102, 31, 0.05);
    color: var(--primary-color);
    cursor: pointer;
    font-size: 1rem;
    font-family: var(--font-text);
    font-weight: 600;
    transition: all 0.2s ease;
}

.upload-image-btn:hover {
    background-color: rgba(196, 102, 31, 0.1);
    border-color: var(--primary-color);
}

.upload-image-btn .material-symbols-outlined {
    font-size: 24px;
}
