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

:root {
    --primary-color: #2c3e50;
    --secondary-color: #3498db;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --light-bg: #ecf0f1;
    --dark-text: #2c3e50;
    --light-text: #7f8c8d;
    --border-color: #bdc3c7;
    --card-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --hover-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--dark-text);
    background-color: var(--light-bg);
}

html, body {
    max-width: 100%;
    overflow-x: hidden;
    width: 100%;
    position: relative;
    -webkit-text-size-adjust: 100%;
}

pre {
    font-family: inherit;
    white-space: pre-wrap;
    word-wrap: break-word;
    margin: 0;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: var(--card-shadow);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.header h1 {
    color: var(--primary-color);
    font-size: 2rem;
}

.header-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

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

.btn-primary:hover {
    background-color: #2980b9;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

/* Mobile width safeguards */
.toolbar input[type="search"] { min-width: 0; }
.toolbar { overflow-x: hidden; }
/* Avoid 100vw overflow on iOS */
#recipeModal .modal-content { max-width: 100%; overflow-x: hidden; }

@media (max-width: 768px) {
  /* Allow toolbar to shrink properly on small screens */
  .toolbar .btn { min-width: 0; }
  .search-box { min-width: 0; }
}

@media (max-width: 480px) {
  .container { padding-left: 12px; padding-right: 12px; }
  .recipe-grid { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}
@media (max-width: 360px) {
  .recipe-grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}

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

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

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

.btn-success:hover {
    background-color: #229954;
}

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

.btn-danger:hover {
    background-color: #c0392b;
}

.btn-icon {
    background: none;
    border: 2px solid var(--border-color);
    padding: 8px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-icon:hover,
.btn-icon.active {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
    color: white;
}

/* Toolbar */
.toolbar {
    background: white;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: var(--card-shadow);
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    align-items: center;
}

.search-box {
    flex: 1;
    min-width: 200px;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 10px 12px 10px 15px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.3s ease;
}

.search-box input:focus {
    outline: none;
    border-color: var(--secondary-color);
}



.filter-box select {
    padding: 10px 15px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    min-width: 150px;
}

.sort-box {
    min-width: 180px;
}

.sort-select {
    width: 100%;
    padding: 10px 15px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    background: white;
    cursor: pointer;
    transition: border-color 0.3s ease;
}

.sort-select:hover {
    border-color: var(--secondary-color);
}

.sort-select:focus {
    outline: none;
    border-color: var(--secondary-color);
}

.view-toggle {
    display: flex;
    gap: 5px;
}

/* Recipe Grid */
.recipe-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

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

.recipe-card {
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    position: relative;
    /* Prevent layout shift */
    contain: layout;
}

.recipe-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--hover-shadow);
    will-change: transform;
}

.recipe-card-image {
    width: 100%;
    height: 200px;
    object-fit: cover;
    background-color: var(--light-bg);
    display: block;
    /* Prevent layout shift while loading */
    min-height: 200px;
    /* Smooth image loading */
    opacity: 1;
    transition: opacity 0.3s ease;
}

.recipe-card-image[src*="placeholder"] {
    opacity: 0.7;
}

.recipe-card-no-image {
    width: 100%;
    height: 200px;
    background: linear-gradient(135deg, var(--light-bg) 0%, #e8e8e8 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #999;
}

.recipe-card-no-image svg {
    opacity: 0.4;
}

.recipe-card-content {
    padding: 15px;
}

.recipe-card-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--primary-color);
}

.recipe-card-description {
    color: var(--light-text);
    font-size: 0.9rem;
    margin-bottom: 10px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.recipe-card-categories {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.category-tag {
    display: inline-block;
    padding: 3px 10px;
    background-color: var(--primary-color);
    color: white;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.recipe-card-meta {
    display: flex;
    gap: 15px;
    font-size: 0.85rem;
    color: var(--light-text);
    flex-wrap: wrap;
}

.recipe-card-categories {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.category-tag {
    background-color: var(--secondary-color);
    color: white;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.recipe-card-checkbox {
    position: absolute;
    bottom: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    cursor: pointer;
    z-index: 2;
    background: rgba(255, 255, 255, 0.95);
    border: 1px solid #ccc;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.08);
}

/* List View */
.list-view .recipe-card {
    display: flex;
    flex-direction: row;
}

.list-view .recipe-card-image,
.list-view .recipe-card-no-image {
    width: 200px;
    height: 150px;
    flex-shrink: 0;
}

.list-view .recipe-card-content {
    flex: 1;
}

/* Loading */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--light-text);
    font-size: 1.1rem;
}

/* Modal overlay container (used by all modals) */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.5);
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 30px;
    border-radius: 8px;
    width: 90%;
    max-width: 900px;
    max-height: 85vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    position: relative;
    animation: slideIn 0.3s ease;
}

/* Lock background scroll when any modal is open */
body.modal-open {
    overflow: hidden !important;
    height: 100vh;
    position: fixed;
    width: 100%;
}

/* Recipe detail modal: full-screen on small screens; centered width on wide screens uses default .modal-content */
@media (max-width: 1024px) {
  #recipeModal {
      overflow: hidden;
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
  }
  #recipeModal .modal-content {
      margin: 0;
      width: 100%;
      max-width: 100%;
      height: 100vh;
      max-height: 100%;
      border-radius: 0;
      overflow: hidden; /* inner detail scrolls */
      padding: 0; /* provide padding on inner container instead */
      position: relative;
  }
  #recipeModal .close {
      position: absolute;
      top: 10px;
      right: 12px;
      z-index: 10;
      width: 44px;
      height: 44px;
      line-height: 44px;
      display: inline-flex;
      align-items: center;
      justify-content: center;
      -webkit-tap-highlight-color: transparent;
      touch-action: manipulation;
  }
  #recipeModal #recipeDetail {
      height: 100%;
      overflow-y: auto;
      overflow-x: hidden;
      -webkit-overflow-scrolling: touch;
      padding: 24px;
      width: 100%;
      box-sizing: border-box;
  }
}
/* On wider screens, fall back to default .modal-content sizing (max-width: 900px). */

@media (min-width: 1025px) {
  /* Keep close button visible while scrolling without altering layout */
  #recipeModal .close {
    position: sticky;
    top: 10px;
    z-index: 10;
    /* float right keeps it aligned inside padded content, away from scrollbar */
  }
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.close {
    color: var(--light-text);
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
}

.close:hover {
    color: var(--dark-text);
}

.modal-large {
    max-width: 1000px;
}

/* Import Tabs */
.import-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    border-bottom: 2px solid var(--border-color);
}

.import-tab {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    font-size: 1rem;
    color: var(--light-text);
    transition: all 0.3s ease;
}

.import-tab:hover {
    color: var(--dark-text);
}

.import-tab.active {
    color: var(--secondary-color);
    border-bottom-color: var(--secondary-color);
}

.import-tab-content {
    display: none;
    padding: 20px 0;
}

.import-tab-content.active {
    display: block;
}

/* Import Textarea */
.import-textarea {
    width: 100%;
    min-height: 300px;
    padding: 15px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    margin-bottom: 15px;
}

.import-textarea:focus {
    outline: none;
    border-color: var(--secondary-color);
}

/* Paste Textarea Header */
.paste-textarea-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

.paste-textarea-header .btn-sm {
    font-size: 0.85rem;
    padding: 4px 10px;
}

/* URL Input Group */
.url-input-group {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.url-input-group input {
    flex: 1;
}

/* URL Recipe Selection */
#urlRecipeSelection {
    margin-top: 20px;
    padding: 20px;
    background-color: var(--light-bg);
    border-radius: 8px;
}

#urlRecipeSelection h3 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

#urlRecipeList {
    max-height: 400px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 15px;
}

.url-recipe-card {
    background: white;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    display: flex;
    align-items: flex-start;
    gap: 10px;
    transition: all 0.3s ease;
}

.url-recipe-card:hover {
    border-color: var(--secondary-color);
    box-shadow: var(--card-shadow);
}

.url-recipe-card input[type="checkbox"] {
    margin-top: 3px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.url-recipe-card label {
    flex: 1;
    cursor: pointer;
}

.url-recipe-card label strong {
    display: block;
    color: var(--primary-color);
    margin-bottom: 5px;
    font-size: 1.1rem;
}

.url-recipe-card label p {
    color: var(--light-text);
    margin-bottom: 5px;
    font-size: 0.9rem;
}

.url-recipe-card label small {
    color: var(--light-text);
    font-size: 0.85rem;
}

/* Recipe Detail */
.recipe-detail-header {
    margin-bottom: 20px;
}

.recipe-detail-title {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.recipe-detail-image {
    display: block;
    max-width: 100%;
    height: auto;
    /* Combine viewport and pixel cap for large screens */
    max-height: min(60vh, 620px);
    object-fit: contain;
    background-color: var(--light-bg);
    border-radius: 8px;
    margin: 0 auto 20px auto;
}
@media (max-width: 768px) {
  /* Slightly smaller cap on mobile */
  .recipe-detail-image { max-height: min(50vh, 420px); }
}

.recipe-detail-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
    padding: 12px 15px;
    background-color: var(--light-bg);
    border-radius: 8px;
    font-size: 0.95rem;
}

.meta-item {
    white-space: nowrap;
}

@media (max-width: 480px) {
    .meta-item {
        white-space: normal;
    }
}

.meta-item strong {
    color: var(--light-text);
    font-weight: 600;
}

.meta-label {
    font-size: 0.85rem;
    color: var(--light-text);
    margin-bottom: 5px;
}

.meta-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--primary-color);
}

.recipe-section {
    margin-bottom: 25px;
}

.recipe-section h3 {
    font-size: 1.3rem;
    color: var(--primary-color);
    margin-bottom: 10px;
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 5px;
}

.recipe-section p,
.recipe-section pre {
    white-space: pre-wrap;
    line-height: 1.8;
    color: var(--dark-text);
}

.recipe-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

/* Servings Scaler */
.servings-scaler {
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
    background-color: var(--light-bg);
    border-radius: 8px;
    overflow: hidden;
}

.scaler-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 12px;
    cursor: pointer;
    user-select: none;
    background-color: var(--light-bg);
    transition: background-color 0.2s ease;
}

.scaler-header:hover {
    background-color: #e8e8e8;
}

.scaler-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--primary-color);
}

.scaler-toggle {
    font-size: 0.8rem;
    color: var(--light-text);
    transition: transform 0.3s ease;
}

.servings-scaler.collapsed .scaler-toggle {
    transform: rotate(0deg);
}

/* Show up-arrow when expanded */
.servings-scaler:not(.collapsed) .scaler-toggle {
    transform: rotate(180deg);
}


.scaler-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 0 12px 12px 12px;
    max-height: 500px;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.servings-scaler.collapsed .scaler-content {
    max-height: 0;
    padding: 0 12px;
}

.scaler-row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.scaler-row label {
    font-size: 0.9rem;
    color: var(--light-text);
    font-weight: 600;
    margin-right: 5px;
}

.servings-scaler button {
    min-width: 45px;
    height: 32px;
    padding: 0 12px;
    border-radius: 6px;
    border: 2px solid var(--secondary-color);
    background: white;
    color: var(--secondary-color);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.servings-scaler button:hover {
    background: var(--secondary-color);
    color: white;
    transform: translateY(-1px);
}

.servings-scaler button:active {
    transform: translateY(0);
}

.servings-scaler .serving-btn {
    min-width: 40px;
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.servings-scaler .serving-btn:hover {
    background: var(--primary-color);
    color: white;
}

.servings-scaler input {
    text-align: center;
    padding: 5px 8px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
}

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

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--primary-color);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
}

.form-group textarea {
    min-height: 100px;
    resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--secondary-color);
}

/* Import Form */
.import-form {
    padding: 20px 0;
}

.import-form input[type="file"] {
    margin: 15px 0;
    padding: 10px;
    border: 2px dashed var(--border-color);
    border-radius: 6px;
    width: 100%;
}

.progress-bar {
    width: 100%;
    height: 20px;
    background-color: var(--light-bg);
    border-radius: 10px;
    overflow: hidden;
    margin: 15px 0;
}

.progress-fill {
    height: 100%;
    background-color: var(--success-color);
    width: 0%;
    transition: width 0.3s ease;
    animation: progress 1.5s ease-in-out infinite;
}

@keyframes progress {
    0% { width: 0%; }
    50% { width: 100%; }
    100% { width: 0%; }
}

.progress-text {
    text-align: center;
    color: var(--light-text);
}

#importResult {
    margin-top: 15px;
    padding: 15px;
    border-radius: 6px;
}

#importResult.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

#importResult.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Mobile visibility helpers */
.mobile-only { display: none; }
.desktop-only { display: initial; }

/* Responsive Design */
@media (max-width: 1024px) {
    .header {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 10px;
    }
    #mobileMenuBtn {
        margin-left: auto;
        width: auto;
        align-self: center;
    }

    .header h1 {
        font-size: 1.5rem;
        text-align: center;
    }

    /* Show/hide helpers on small screens */
    .mobile-only { display: inline-block; }
    .desktop-only { display: none !important; }

    /* Header as simple bar with burger */
    .header-actions { display: none; }

    .toolbar {
        display: grid;
        grid-template-columns: 1fr auto;
        align-items: center;
        gap: 8px;

    /* Make mobile menu dropdown export button full-width */
    #mobileMenuModal .dropdown-container { width: 100%; }
    #mobileMenuModal .dropdown-container > .btn { width: 100%; display: block; }

    }

    /* Ensure full-width items inside mobile menu grid */
    #mobileMenuModal .mobile-menu-list > * { width: 100%; }
    #mobileSelectionActions .btn { width: 100%; display: block; }


    /* Only show search and a Filters button in toolbar; move filters/sort into modal */
    .search-box { width: 100%; }
    .filter-box, .sort-box { display: none; }

    .view-toggle { display: none; }

    /* Keep category UI out of toolbar on mobile; use Filters modal instead */
    .category-filter-container { display: none; }

    /* If any dropdown leaks into flow, force it hidden */
    .category-filter-dropdown { display: none !important; }


    .list-view .recipe-card { flex-direction: column; }
    .list-view .recipe-card-image { width: 100%; height: 200px; }

    .modal-content { width: 95%; margin: 10% auto; padding: 20px; }
    .recipe-detail-title { font-size: 1.5rem; }
}

/* Ensure filter and sort show properly inside filters modal on mobile */
.filters-modal .filter-box,
.filters-modal .sort-box { display: block !important; width: 100%; }
.filters-modal .category-filter-container { display: block !important; }
.filters-modal .category-filter-btn { display: none; }
.filters-modal .category-filter-dropdown { display: block !important; position: static; width: 100%; max-height: 60vh; }
/* Edit modal: two-column layout with photo panel on the right for wide screens */
@media (min-width: 992px) {
  #editRecipeForm {
    display: grid;
    grid-template-columns: 1fr 360px;
    column-gap: 24px;
  }
  #editRecipeForm > .form-group,
  #editRecipeForm > .form-row,
  #editRecipeForm > .form-actions {
    grid-column: 1;
  }
  #editRecipeForm > .photo-group {
    grid-column: 2;
    grid-row: 1 / span 10;
    align-self: start;
    position: sticky;
    top: 12px;
  }
}


/* Print Styles */
@media print {
    .header,
    .toolbar,
    .recipe-actions,
    .modal .close {
        display: none !important;
    }

    .modal-content {
        box-shadow: none;
        margin: 0;
        padding: 0;
    }

    .recipe-section {
        page-break-inside: avoid;
    }
}

/* Form Styles */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--dark-text);
}

.form-group input[type="text"],
.form-group input[type="url"],
.form-group input[type="file"],
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.3s;
}

.form-group input[type="text"]:focus,
.form-group input[type="url"]:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--secondary-color);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-group small {
    display: block;
    margin-top: 5px;
    color: var(--light-text);
    font-size: 12px;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

#photoPreview img {
    max-width: 200px;
    max-height: 200px;
    border-radius: 4px;
    border: 1px solid var(--border-color);
}

/* Mobile camera input styling */
input[type="file"][capture] {
    cursor: pointer;
}

/* Photo drop zone */
.photo-drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    background-color: var(--light-bg);
    transition: all 0.3s ease;
    cursor: pointer;
}

.photo-drop-zone:hover,
.photo-drop-zone.drag-over {
    border-color: var(--primary-color);
    background-color: #e8f4f8;
}

.drop-zone-content p {
    margin: 5px 0;
    color: var(--light-text);
}

.file-input-label {
    display: inline-block;
    padding: 10px 24px;
    background-color: var(--secondary-color);
    color: white !important;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: background-color 0.3s ease;
    text-decoration: none;
}

.file-input-label:hover {
    background-color: #2980b9;
}

/* Tagify customizations for category input */
.tagify {
    --tag-bg: var(--secondary-color);
    --tag-hover: #2980b9;
    --tag-text-color: white;
    --tags-border-color: #ddd;
    --tags-focus-border-color: var(--primary-color);
    --tag-remove-bg: rgba(211, 148, 148, 0.3);
    --tag-remove-btn-bg--hover: #c77777;
    --tag-pad: 0.3em 0.5em;
    border-radius: 6px;
    /* Style new categories (not in whitelist) the same as existing ones */
    --tag-invalid-color: var(--tag-text-color);
    --tag-invalid-bg: var(--tag-bg);
}

/* Ensure tags not in whitelist look the same as normal tags */
.tagify .tagify__tag:not(.tagify__tag--editable).tagify--notAllowed:not(.tagify__tag--noAnim),
.tagify .tagify__tag.tagify--notAllowed {
    background: var(--tag-bg);
    color: var(--tag-text-color);
    animation: none;
}

.tagify .tagify__tag.tagify--notAllowed > div::before {
    background: transparent;
}

/* Custom dropdown styling to match the "tags-look" example */
.tags-look .tagify__dropdown__item {
    display: inline-block;
    vertical-align: middle;
    border-radius: 3px;
    padding: 0.3em 0.5em;
    border: 1px solid #CCC;
    background: #F3F3F3;
    margin: 0.2em;
    font-size: 0.85em;
    color: black;
    transition: 0s;
}

.tags-look .tagify__dropdown__item--active {
    border-color: black;
}

.tags-look .tagify__dropdown__item:hover {
    background: lightyellow;
    border-color: gold;
}

.tags-look .tagify__dropdown__item--hidden {
    max-width: 0;
    max-height: initial;
    padding: 0.3em 0;
    margin: 0.2em 0;
    white-space: nowrap;
    text-indent: -20px;
    border: 0;
}

@media (max-width: 768px) {
    .form-row {
        grid-template-columns: 1fr;
    }

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

    .form-actions button {
        width: 100%;
    }
}


/* Ingredients list styling */
.ingredients-list {
    list-style: disc;
    padding-left: 20px;
    font-family: inherit;
    line-height: 1.8;
    color: var(--dark-text);
}
.ingredients-list li {
    margin-bottom: 0.5em;
}
.ingredients-list .qty {
    font-weight: 700;
    color: var(--primary-color);
}
/* Subsection headings inside ingredients (e.g., "Base", "Topping") */
.ingredients-list li.ingredient-section {
    list-style: none;
    padding-left: 0;
    margin-left: -20px; /* Counteract the ul's padding-left to align with container edge */
    margin-top: 0.8em;
    margin-bottom: 0.3em;
}


/* Multi-select category filter */
.category-filter-container {
    position: relative;
}

.category-filter-btn {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 12px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    min-width: 180px;
    transition: border-color 0.2s;
}

.category-filter-btn:hover {
    border-color: var(--primary-color);
}

.dropdown-arrow {
    font-size: 0.7rem;
    color: var(--light-text);
}

.category-filter-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 5px;
    background: white;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 3000;
    min-width: 250px;
    max-height: 400px;
    overflow-y: auto;
}

/* When portaled to body on desktop, force fixed positioning above grid */
.category-filter-dropdown.category-filter-popover {
    position: fixed;
    z-index: 4000;
}


.category-filter-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--dark-text);
}

.category-filter-mode {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 15px;
    background: var(--light-bg);
}

.category-filter-mode label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--dark-text);
}

.category-filter-mode input[type="radio"] {
    cursor: pointer;
}

.clear-filter-btn {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    font-size: 0.85rem;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.clear-filter-btn:hover {
    background: var(--light-bg);
}

.category-filter-list {
    padding: 8px;
}

.category-filter-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.category-filter-item:hover {
    background: var(--light-bg);
}

.category-filter-item input[type="checkbox"] {
    cursor: pointer;
    width: 16px;
    height: 16px;
}

.category-filter-item span {
    flex: 1;
    font-size: 0.95rem;
    color: var(--dark-text);
}

/* Recipe preview */
.recipe-preview {
    background: var(--light-bg);
    padding: 20px;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.preview-field {
    margin-bottom: 15px;
}

.preview-field strong {
    display: block;
    margin-bottom: 5px;
    color: var(--dark-text);
    font-weight: 600;
}

/* URL recipe cards */
.url-recipe-card {
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 10px;
    background: white;
}

.url-recipe-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}

.url-recipe-header input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.url-recipe-header label {
    flex: 1;
    cursor: pointer;
    margin: 0;
}

.url-recipe-card .recipe-desc {
    margin: 8px 0;
    color: var(--light-text);
    font-size: 0.9rem;
}

.btn-small {
    padding: 4px 12px;
    font-size: 0.85rem;
    border: 1px solid var(--primary-color);
    background: white;
    color: var(--primary-color);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* Export Menu */
.export-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    min-width: 220px;
    max-width: 280px;
}

/* When there isn't room below, flip up */
.export-menu.drop-up {
    top: auto;
    bottom: 100%;
    margin-top: 0;
    margin-bottom: 4px;
}

.export-menu button {
    display: block;
    width: 100%;
    padding: 10px 16px;
    text-align: left;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
    white-space: nowrap;
}

.export-menu button:hover {
    background: var(--hover-color);
}

.export-menu button:not(:last-child) {
    border-bottom: 1px solid var(--border-color);
}

/* Responsive adjustments for export menu */
@media (max-width: 768px) {
    .export-menu {
        right: 0;
        left: auto;
        min-width: 200px;
        max-width: calc(100vw - 40px);
    }

    .export-menu button {
        font-size: 13px;
        padding: 8px 12px;
    }
}

/* Loading Overlay */
#loadingOverlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    justify-content: center;
    align-items: center;
}

.loading-content {
    background: white;
    padding: 40px 60px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid #f3f3f3;
    border-top: 5px solid var(--secondary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-message {
    font-size: 18px;
    color: var(--dark-text);
    font-weight: 500;
}