/* Import Bootstrap CSS */
@import url('https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css');

/* ── CSS Variables for theming ── */
:root {
    --bg-body: #f8f9fa;
    --bg-card: #ffffff;
    --text-body: #212529;
    --text-muted: #6c757d;
    --border-color: #dee2e6;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --success-bg: #d1fae5;
    --success-text: #065f46;
    --card-transition: 0.2s ease-in-out;
}

/* ── Dark mode (auto) ── */
@media (prefers-color-scheme: dark) {
    :root {
        --bg-body: #1a1a2e;
        --bg-card: #16213e;
        --text-body: #e4e6eb;
        --text-muted: #b0b3b8;
        --border-color: #3a3b3c;
        --shadow-color: rgba(0, 0, 0, 0.3);
        --success-bg: #064e3b;
        --success-text: #a7f3d0;
    }

    .card,
    .modal-content,
    .list-group-item,
    .form-control,
    .form-select,
    .page-link,
    .breadcrumb-item.active,
    .dropdown-menu {
        background-color: var(--bg-card) !important;
        color: var(--text-body) !important;
        border-color: var(--border-color) !important;
    }

    .form-control,
    .form-select {
        background-color: #0f1a2e !important;
    }

    .form-control:focus,
    .form-select:focus {
        background-color: #1a2a40 !important;
    }

    .breadcrumb-item + .breadcrumb-item::before {
        color: var(--text-muted);
    }

    .text-muted {
        color: var(--text-muted) !important;
    }

    .bg-light {
        background-color: #0f1a2e !important;
    }

    .badge.bg-light {
        background-color: #2a3a50 !important;
        color: #e4e6eb !important;
    }

    .alert-info {
        background-color: #1a3a4e;
        color: #a8d8ea;
        border-color: #2a5a7e;
    }

    .card-footer {
        background-color: #0f1a2e !important;
        border-top-color: var(--border-color);
    }

    img {
        opacity: 0.9;
        transition: opacity 0.2s;
    }

    img:hover {
        opacity: 1;
    }
}

/* ── General Styles ── */
body {
    font-family: 'Segoe UI', system-ui, -apple-system, 'Arial', sans-serif;
    background-color: var(--bg-body);
    color: var(--text-body);
    margin: 0;
    padding: 0;
    transition: background-color 0.3s, color 0.3s;
    line-height: 1.6;
}

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

/* ── Card Styles ── */
.card {
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow-color);
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    transition: transform var(--card-transition), box-shadow var(--card-transition);
    background-color: var(--bg-card);
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--shadow-color);
}

.card img {
    max-width: 100%;
    height: auto;
    border-top-left-radius: 12px;
    border-top-right-radius: 12px;
}

.card-body {
    padding: 20px;
}

.card-title {
    font-size: 1.25rem;
    margin-bottom: 10px;
    font-weight: 600;
}

.card-text {
    color: var(--text-muted);
}

.card-header {
    font-weight: 600;
    background-color: rgba(0,0,0,0.02);
    border-bottom: 1px solid var(--border-color);
}

.card-footer {
    background-color: rgba(0,0,0,0.02);
    border-top: 1px solid var(--border-color);
}

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

.form-label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-control,
.form-select {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    transition: border-color 0.15s, box-shadow 0.15s;
    background-color: var(--bg-card);
    color: var(--text-body);
}

.form-control:focus,
.form-select:focus {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

.btn {
    border-radius: 8px;
    transition: all 0.15s ease;
}

.btn-lg {
    border-radius: 10px;
}

/* ── Ingredient Manager Styles ── */
#ingredient-list {
    min-height: 60px;
    max-height: 350px;
    overflow-y: auto;
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 0.375rem;
    transition: border-color 0.15s ease-in-out;
}

#ingredient-list:focus-within {
    border-color: #86b7fe;
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.15);
}

.ingredient-row {
    background: white;
    transition: background-color 0.15s ease, opacity 0.15s ease;
}

.ingredient-row:hover {
    background-color: #f8f9fa;
}

.ingredient-row.optional {
    opacity: 0.65;
}

.ingredient-row .drag-handle {
    cursor: grab;
    font-size: 1.1rem;
    user-select: none;
}

.ingredient-row .drag-handle:active {
    cursor: grabbing;
}

.ingredient-row .ingredient-name {
    font-weight: 500;
    min-width: 120px;
}

.ingredient-row .quantity-input {
    width: 80px;
}

.ingredient-row .unit-select {
    width: 90px;
}

.ingredient-row .prep-note {
    width: 130px;
}

/* Suggestions dropdown */
#ingredient-suggestions.dropdown-menu {
    max-height: 280px;
    overflow-y: auto;
    border: 1px solid #dee2e6;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

#ingredient-suggestions.dropdown-menu .dropdown-item {
    cursor: pointer;
    padding: 0.4rem 0.8rem;
    font-size: 0.95rem;
}

#ingredient-suggestions.dropdown-menu .dropdown-item:hover,
#ingredient-suggestions.dropdown-menu .dropdown-item.active {
    background-color: #19875422;
    color: #155724;
}

/* ── Nutrition Panel ── */
.nutrition-value {
    font-size: 1.25rem;
    font-weight: 700;
}

.nutrition-label {
    font-size: 0.8rem;
    color: #6c757d;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ── Cooking Timer ── */
#cooking-timer-display {
    font-size: 2.2rem;
    font-weight: 700;
    font-family: 'Courier New', Courier, monospace;
    letter-spacing: 3px;
    min-width: 120px;
}

/* ── Serving Scaler ── */
#serving-input {
    -moz-appearance: textfield;
}

#serving-input::-webkit-inner-spin-button,
#serving-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ── Print Styles ── */
@media print {
    .navbar,
    .btn,
    #cooking-timer-minutes,
    #cooking-timer-start,
    #cooking-timer-reset,
    #unit-converter,
    #print-recipe,
    .breadcrumb {
        display: none !important;
    }
    .card {
        box-shadow: none !important;
        border: 1px solid #dee2e6 !important;
        break-inside: avoid;
    }
    body {
        background: white;
    }
    .container {
        max-width: 100%;
        padding: 0;
    }
}

/* ── Dietary & Badge Enhancements ── */
.badge-difficulty {
    font-size: 0.85rem;
    padding: 0.35em 0.65em;
}

.badge-dietary {
    font-size: 0.8rem;
}

/* ── Ingredient list in view mode ── */
#ingredient-list-display .list-group-item {
    border-left: none;
    border-right: none;
    padding: 0.6rem 0;
}

#ingredient-list-display .list-group-item:first-child {
    border-top: none;
}

#ingredient-list-display .ingredient-name {
    font-weight: 400;
}

/* Responsive Styles */
@media (max-width: 768px) {
    .card img {
        height: auto;
    }
    .ingredient-row {
        flex-wrap: wrap;
    }
    .ingredient-row .ingredient-name {
        min-width: 100%;
        margin-bottom: 0.3rem;
    }
}
