/* ===================================================================
   CORE BAKING APP STYLESHEET (v1.0 - Monolithic)
   - Combines all functionality from previous CSS files into one stable file.
   - Designed to override Bootstrap 5.
=================================================================== */

/* ===================================
   1. THEME & GLOBAL VARIABLES
=================================== */
:root {
    /* Colors */
    --primary-color: #667eea;
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;

    /* Typography */
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;

    /* Spacing & Radius */
    --border-radius: 12px;
    --border-radius-lg: 20px;

    /* Shadows */
    --shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 15px 35px rgba(0, 0, 0, 0.2);

    /* Z-Index Layers */
    --z-content: 1;
    --z-floating-btn: 9998;
    --z-navbar: 1050;
    --z-dropdown: 1060;
    --z-modal-backdrop: 1065;
    --z-offcanvas: 1070;
    --z-modal: 1075;
}

/* ===================================
   2. GLOBAL STYLES & RESETS
=================================== */
body {
    font-family: var(--font-family);
    background-attachment: fixed;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    background-color: #f8f9fa;
}

@media (orientation: landscape) { body { background-image: url("../img/00.jpg"); } }
@media (orientation: portrait) { body { background-image: url("../img/0.jpg"); } }

body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    z-index: -1;
    pointer-events: none;
}

h1, h2, h3, h4, h5, h6 { font-weight: 700; color: #2d3748; }

/* ===================================
   3. GLOBAL ANIMATIONS
=================================== */
@keyframes fadeInUp { from { opacity: 0; transform: translateY(30px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInDown { from { opacity: 0; transform: translateY(-20px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scrollText {
    0%, 15% { transform: translateY(0); }
    85%, 100% { transform: translateY(-25%); }
}

/* ===================================
   4. LAYOUT & CONTAINERS
=================================== */
.welcome-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    min-height: 70vh;
    text-align: center;
    color: white;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.7);
}
.welcome-title { font-size: 3.5rem; animation: fadeInUp 0.8s ease; }
.welcome-subtitle { font-size: 1.4rem; animation: fadeInUp 0.8s ease 0.2s both; }
.welcome-instruction { font-size: 1.1rem; background: rgba(255, 255, 255, 0.2); padding: 1rem 2rem; border-radius: var(--border-radius-lg); backdrop-filter: blur(10px); animation: fadeInUp 0.8s ease 0.4s both; }

.recipe-container {
    background: rgba(255, 255, 255, 0.95);
    border-radius: var(--border-radius-lg);
    padding: 2rem;
    margin: 2rem auto;
    max-width: 1200px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(15px);
    animation: fadeInUp 0.5s ease;
    position: relative;
    z-index: var(--z-content);
}

.recipe-title {
    color: #2d3748;
    cursor: pointer;
    transition: all 0.3s ease;
}
.recipe-title:hover {
    color: var(--primary-color);
    transform: scale(1.02);
}

/* ===================================
   5. NAVIGATION
=================================== */
.navbar {
    backdrop-filter: blur(10px);
    background: rgba(33, 37, 41, 0.95) !important;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.3);
    position: sticky !important;
    top: 0;
    z-index: var(--z-navbar);
}

.dropdown-menu {
    border: none;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    backdrop-filter: blur(15px);
    background: rgba(255, 255, 255, 0.98);
    animation: fadeInDown 0.3s ease;
    z-index: var(--z-dropdown);
    max-height: calc(100vh - 200px);
    overflow-y: auto;
    padding: 8px;
}

.dropdown-menu::-webkit-scrollbar { width: 8px; }
.dropdown-menu::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.05); }
.dropdown-menu::-webkit-scrollbar-thumb { background: rgba(102, 126, 234, 0.3); border-radius: 4px; }
.dropdown-menu::-webkit-scrollbar-thumb:hover { background: rgba(102, 126, 234, 0.5); }

.dropdown-item {
    font-weight: 500;
    color: #FDF6E3 !important;
    border-radius: var(--border-radius);
    margin: 2px 8px;
    transition: all 0.2s ease;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.dropdown-item:hover, .dropdown-item:focus {
    color: white !important;
    background: var(--primary-gradient);
    transform: translateX(5px);
}
.dropdown-item span, .dropdown-item:hover span { color: inherit !important; }
.recipe-name { flex-grow: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.recipe-count { flex-shrink: 0; font-size: 0.75rem; background: rgba(0,0,0,0.1); padding: 2px 6px; border-radius: 50px; }
#userMenuDropdown { max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ===================================
   6. TABLES & FORMS
=================================== */
.ingredients-table {
    background: white;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
    margin: 2rem 0;
}
.table th {
    background: var(--primary-gradient);
    color: white;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.85rem;
    padding: 1rem 0.75rem;
    text-align: center;
    border: none;
}
.table td { padding: 1rem 0.75rem; vertical-align: middle; border-color: #e9ecef; }
.table td:first-child { text-align: left; }
.table-hover tbody tr:hover { background: rgba(102, 126, 234, 0.08); }
.table tbody tr:last-child { background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%); font-weight: 600; border-top: 2px solid var(--primary-color); }
.form-control:focus, .form-select:focus { border-color: var(--primary-color); box-shadow: 0 0 0 0.2rem rgba(102, 126, 234, 0.15); }

/* ===================================
   7. AVAILABILITY INDICATORS
=================================== */
/* Dropdown Indicators */
.recipe-available { border-left: 4px solid var(--success-color) !important; }
.recipe-partial { border-left: 4px solid var(--warning-color) !important; }
.recipe-unavailable { border-left: 4px solid var(--danger-color) !important; opacity: 0.7; }
/* Visual Card Indicators */
.card-available { border-top: 5px solid var(--success-color); }
.card-partial { border-top: 5px solid var(--warning-color); }
.card-unavailable { border-top: 5px solid var(--danger-color); opacity: 0.85; }
/* Table Row Indicators */
.ingredient-available { background-color: rgba(40, 167, 69, 0.1) !important; border-left: 4px solid var(--success-color); }
.ingredient-insufficient { background-color: rgba(255, 193, 7, 0.1) !important; border-left: 4px solid var(--warning-color); }
.ingredient-unavailable { background-color: rgba(220, 53, 69, 0.1) !important; border-left: 4px solid var(--danger-color); }

/* ===================================
   8. VISUAL RECIPE CHOOSER
=================================== */
.visual-chooser-container { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; gap: 20px; padding: 20px; }
.visual-recipe-card { flex: 0 0 80%; scroll-snap-align: center; position: relative; border-radius: var(--border-radius-lg); box-shadow: var(--shadow); overflow: hidden; transition: transform 0.15s ease-out, border-color 0.3s ease; }
.visual-recipe-card a { display: block; height: 100%; text-decoration: none; color: white; }
.visual-recipe-card a:active, .visual-recipe-card a:focus, .visual-recipe-card a:hover { transform: scale(0.98); }
.visual-recipe-card .card-img-top { width: 100%; height: 100%; object-fit: cover; transition: transform 0.4s ease; }
.visual-recipe-card a:hover .card-img-top { transform: scale(1.05); }
.visual-recipe-card .card-overlay { position: absolute; bottom: 0; left: 0; right: 0; padding: 2rem 1.5rem; background: linear-gradient(to top, rgba(0,0,0,0.9), rgba(0,0,0,0)); height: 220px; overflow: hidden; }
.visual-recipe-card .card-text-scroller { animation: scrollText 15s linear infinite; animation-play-state: paused; }
.visual-recipe-card.in-viewport .card-text-scroller { animation-play-state: running; }
.visual-recipe-card:hover .card-text-scroller { animation-play-state: paused; }

/* ===================================
   9. MODALS & OFFCANVAS
=================================== */
.offcanvas { backdrop-filter: blur(15px); background: rgba(255, 255, 255, 0.95); z-index: var(--z-offcanvas); }
.offcanvas-header { background: var(--primary-gradient); color: white; }
.btn-close-white { filter: invert(1) grayscale(100%) brightness(200%); }

.offcanvasInfo .offcanvas-header {
    height: 280px;
    overflow: hidden;
    position: relative;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-bottom: 5px solid var(--primary-color);
}
.offcanvasInfo .recipe-image {
    width: 180px; height: 180px;
    object-fit: cover;
    border-radius: 50%;
    border: 4px solid rgba(255,255,255,0.8);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    margin-bottom: 1rem;
}
.offcanvasInfo .offcanvas-body { overflow-y: auto !important; max-height: calc(100vh - 280px) !important; padding: 1.5rem; }
.recipe-info-content p { color: #6c757d !important; font-size: 0.95rem; line-height: 1.6; }

.modal-fullscreen .modal-content { background-color: rgba(0, 43, 54, 0.95); backdrop-filter: blur(10px); }

/* ===================================
   10. OTHER COMPONENTS
=================================== */
.preparation-content {
    line-height: 1.8;
    font-size: 0.95rem;
    color: #000000;
    background: #fffef7;
    padding: 1.5rem;
    border-radius: var(--border-radius);
    border-left: 4px solid var(--primary-color);
    white-space: pre-wrap;
    word-wrap: break-word;
    max-height: 400px;
    overflow-y: auto;
    text-align: justify;
}
.preparation-content::-webkit-scrollbar { width: 8px; }
.preparation-content::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.05); }
.preparation-content::-webkit-scrollbar-thumb { background: rgba(102, 126, 234, 0.3); border-radius: 4px; }

/* Floating Action Buttons Z-Index Hierarchy */
.position-fixed[ng-if="loggedIn"] { z-index: var(--z-floating-btn) !important; display: block !important; visibility: visible !important; opacity: 1 !important; }
.position-fixed[style*="bottom: 140px"] { z-index: calc(var(--z-floating-btn) - 2) !important; }
.position-fixed[style*="bottom: 80px"] { z-index: calc(var(--z-floating-btn) - 1) !important; }
.position-fixed[style*="bottom: 20px"] { z-index: var(--z-floating-btn) !important; }

/* ===================================
   11. MOBILE & RESPONSIVE STYLES
=================================== */

/* Tablet and Mobile Breakpoint */
@media (max-width: 991px) {
    .recipe-container { margin: 1rem 0.5rem; padding: 1.5rem 1rem; }
    .visual-recipe-card { flex-basis: 90%; }
}

/* General Mobile Breakpoint */
@media (max-width: 767px) {
    .navbar { z-index: 1050 !important;position: sticky !important; }
    .navbar-collapse { background: rgba(33, 37, 41, 0.98); border-radius: 0 0 15px 15px; margin-top: 10px; padding: 1rem; z-index: 1055 !important; }
    .dropdown-menu { position: static !important; width: 100%; box-shadow: none; margin: 0.5rem 0; }
    .offcanvas-start, .offcanvas-end { width: 100vw !important; max-width: 100vw !important; }
    .offcanvasInfo .offcanvas-header { height: 220px; }
    .offcanvasInfo .recipe-image { width: 140px; height: 140px; }
    .offcanvasInfo .offcanvas-body { max-height: calc(100vh - 220px); }
    .ingredient-item .row { flex-direction: column; gap: 0.5rem; }
    .ingredient-item .col-7, .ingredient-item .col-5 { width: 100%; max-width: 100%; flex: 0 0 100%; }
}

/* Portrait Mobile Table Layout */
@media (max-width: 767px) and (orientation: portrait) {
    .table th:nth-child(4), .table td:nth-child(4), /* Fat */
    .table th:nth-child(5), .table td:nth-child(5), /* Carbs */
    .table th:nth-child(6), .table td:nth-child(6), /* Fibers */
    .table th:nth-child(7), .table td:nth-child(7), /* Protein */
    .table th:nth-child(8), .table td:nth-child(8) { /* Water */
        display: none !important;
    }
    .table th:nth-child(1), .table td:nth-child(1) { width: 45%; }
    .table th:nth-child(2), .table td:nth-child(2) { width: 30%; }
    .table th:nth-child(3), .table td:nth-child(3) { width: 25%; }
}

/* Landscape Mobile Table Layout */
@media (max-width: 991px) and (orientation: landscape) {
    .table th, .table td { padding: 0.4rem 0.2rem; font-size: 0.75rem; word-break: break-word; }
    .table th { font-size: 0.65rem; line-height: 1.2; }
    .table th .bi { display: none; }
}

/* Very Small Screens */
@media (max-width: 575px) {
    .recipe-title { font-size: 1.6rem; }
    .preparation-content { padding: 1rem; font-size: 0.9rem; max-height: 300px; }
}
