/* =============================================================
   MyRecipes — Warm Pantry Theme
   Loaded after Bootstrap; overrides CSS custom properties.
   ============================================================= */

/* ----- Typography ----- */
:root {
    --mr-font-heading: 'Spectral', Georgia, serif;
    --mr-font-body: 'Source Sans 3', system-ui, sans-serif;
}

body {
    font-family: var(--mr-font-body);
}

h1, h2, h3, h4, h5, h6,
.display-1, .display-2, .display-3, .display-4, .display-5, .display-6 {
    font-family: var(--mr-font-heading);
}


/* =============================================================
   Light Theme
   ============================================================= */
[data-bs-theme="light"] {
    --bs-primary:                   #B5451B;
    --bs-primary-rgb:               181, 69, 27;
    --bs-body-bg:                   #FAF7F2;
    --bs-body-bg-rgb:               250, 247, 242;
    --bs-body-color:                #2D1B0E;
    --bs-body-color-rgb:            45, 27, 14;
    --bs-emphasis-color:            #1C1008;
    --bs-secondary-color:           rgba(45, 27, 14, 0.65);
    --bs-secondary-bg:              #F0EAE0;
    --bs-tertiary-bg:               #F0EAE0;
    --bs-border-color:              #E2D5C3;
    --bs-border-color-translucent:  rgba(45, 27, 14, 0.1);
    --bs-link-color:                #B5451B;
    --bs-link-color-rgb:            181, 69, 27;
    --bs-link-hover-color:          #8e3515;
    --bs-link-hover-color-rgb:      142, 53, 21;
    --mr-nav-bg:                    #2D1B0E;
    --mr-surface:                   #F0EAE0;
    --mr-accent:                    #C47A2B;
}

[data-bs-theme="light"] .card {
    --bs-card-bg:           #FFFFFF;
    --bs-card-border-color: #E2D5C3;
}

[data-bs-theme="light"] .btn-primary {
    --bs-btn-color:                 #fff;
    --bs-btn-bg:                    #B5451B;
    --bs-btn-border-color:          #B5451B;
    --bs-btn-hover-bg:              #9a3a17;
    --bs-btn-hover-border-color:    #8e3515;
    --bs-btn-active-bg:             #8e3515;
    --bs-btn-active-border-color:   #833112;
    --bs-btn-focus-shadow-rgb:      181, 69, 27;
    --bs-btn-disabled-bg:           #B5451B;
    --bs-btn-disabled-border-color: #B5451B;
}

[data-bs-theme="light"] .btn-outline-primary {
    --bs-btn-color:             #B5451B;
    --bs-btn-border-color:      #B5451B;
    --bs-btn-hover-color:       #fff;
    --bs-btn-hover-bg:          #B5451B;
    --bs-btn-hover-border-color: #B5451B;
    --bs-btn-active-color:      #fff;
    --bs-btn-active-bg:         #B5451B;
    --bs-btn-active-border-color: #B5451B;
    --bs-btn-focus-shadow-rgb:  181, 69, 27;
}

[data-bs-theme="light"] .form-control:focus,
[data-bs-theme="light"] .form-select:focus {
    border-color: #B5451B;
    box-shadow: 0 0 0 0.25rem rgba(181, 69, 27, 0.18);
}


/* =============================================================
   Dark Theme
   Two-tone accent system:
     - Copper-terracotta (#D47040) for interactive actions (buttons, focus)
     - Whiskey-amber gold (#E8B84C) for links, active states, and
       decorative accents — reads like candlelight against espresso
   ============================================================= */
[data-bs-theme="dark"] {
    --bs-primary:                   #D47040;
    --bs-primary-rgb:               212, 112, 64;
    --bs-body-bg:                   #1A1007;
    --bs-body-bg-rgb:               26, 16, 7;
    --bs-body-color:                #F0E8D8;
    --bs-body-color-rgb:            240, 232, 216;
    --bs-emphasis-color:            #FAF7F2;
    --bs-secondary-color:           rgba(240, 232, 216, 0.6);
    --bs-secondary-bg:              #2D1E0F;
    --bs-tertiary-bg:               #241507;
    --bs-border-color:              #3D2A15;
    --bs-border-color-translucent:  rgba(240, 232, 216, 0.08);
    --bs-link-color:                #E8B84C;
    --bs-link-color-rgb:            232, 184, 76;
    --bs-link-hover-color:          #F5CC6E;
    --bs-link-hover-color-rgb:      245, 204, 110;
    --mr-nav-bg:                    #0F0805;
    --mr-surface:                   #2D1E0F;
    --mr-accent:                    #E8B84C;
}

[data-bs-theme="dark"] .card {
    --bs-card-bg:           #201408;
    --bs-card-border-color: #3A2712;
}

[data-bs-theme="dark"] .btn-primary {
    --bs-btn-color:                 #fff;
    --bs-btn-bg:                    #D47040;
    --bs-btn-border-color:          #D47040;
    --bs-btn-hover-bg:              #E07E4E;
    --bs-btn-hover-border-color:    #E07E4E;
    --bs-btn-active-bg:             #BC6236;
    --bs-btn-active-border-color:   #B05C32;
    --bs-btn-focus-shadow-rgb:      212, 112, 64;
    --bs-btn-disabled-bg:           #D47040;
    --bs-btn-disabled-border-color: #D47040;
}

[data-bs-theme="dark"] .btn-outline-primary {
    --bs-btn-color:              #D47040;
    --bs-btn-border-color:       #D47040;
    --bs-btn-hover-color:        #fff;
    --bs-btn-hover-bg:           #D47040;
    --bs-btn-hover-border-color: #D47040;
    --bs-btn-active-color:       #fff;
    --bs-btn-active-bg:          #D47040;
    --bs-btn-active-border-color: #D47040;
    --bs-btn-focus-shadow-rgb:   212, 112, 64;
}

[data-bs-theme="dark"] .btn-outline-secondary {
    --bs-btn-color:              rgba(240, 232, 216, 0.7);
    --bs-btn-border-color:       #4A3520;
    --bs-btn-hover-color:        #F0E8D8;
    --bs-btn-hover-bg:           #2D1E0F;
    --bs-btn-hover-border-color: #5A4228;
    --bs-btn-active-color:       #F0E8D8;
    --bs-btn-active-bg:          #2D1E0F;
    --bs-btn-active-border-color: #5A4228;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: #1E1309;
    border-color: #4A3520;
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: #1E1309;
    border-color: #D47040;
    box-shadow: 0 0 0 0.25rem rgba(212, 112, 64, 0.2);
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .form-control::placeholder,
[data-bs-theme="dark"] .form-select::placeholder {
    color: rgba(240, 232, 216, 0.3);
}


/* =============================================================
   Navbar — always espresso, regardless of page theme
   ============================================================= */
.site-navbar {
    background-color: var(--mr-nav-bg) !important;
    border-bottom: 1px solid rgba(240, 232, 216, 0.07);
    min-height: 58px;
    padding-top: 0;
    padding-bottom: 0;
}

.site-brand {
    font-family: var(--mr-font-heading) !important;
    font-size: 1.3rem !important;
    font-weight: 700 !important;
    letter-spacing: -0.02em;
    color: #F0E8D8 !important;
}

.site-navbar .nav-link {
    font-size: 0.9rem;
    font-family: var(--mr-font-body);
}

.site-navbar .nav-link.active {
    color: var(--mr-accent) !important;
    font-weight: 600;
}

.theme-toggle {
    color: rgba(240, 232, 216, 0.7) !important;
    font-size: 1rem;
    text-decoration: none;
}

.theme-toggle:hover {
    color: #F0E8D8 !important;
}


/* =============================================================
   Desktop layout — sidebar + main content
   ============================================================= */
@media (min-width: 992px) {
    .layout-wrapper {
        display: flex;
        min-height: 100vh;
    }

    .layout-main {
        flex: 1;
        min-width: 0;
    }

    /* No top navbar on desktop — full viewport height */
    .auth-page {
        min-height: 100vh;
    }

    /* Sticky content no longer needs to clear a top navbar */
    .sticky-below-nav {
        top: 1rem;
    }
}

/* Sidebar shell */
.site-sidebar {
    width: 220px;
    flex-shrink: 0;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    background-color: var(--mr-nav-bg);
    padding: 1.25rem 0.75rem 1rem;
    border-right: 1px solid rgba(240, 232, 216, 0.07);
}

.sidebar-brand {
    font-family: var(--mr-font-heading) !important;
    font-size: 1.3rem !important;
    font-weight: 700 !important;
    letter-spacing: -0.02em;
    color: #F0E8D8 !important;
    text-decoration: none;
    display: block;
    padding: 0.25rem 0.75rem 0.5rem;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Shared style for nav links, theme toggle, and sign-out button */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.55rem 0.75rem;
    border-radius: 0.5rem;
    color: rgba(240, 232, 216, 0.65);
    text-decoration: none;
    font-family: var(--mr-font-body);
    font-size: 0.9rem;
    transition: color 0.15s, background-color 0.15s;
    width: 100%;
    text-align: left;
    border: none;
    background: none;
    cursor: pointer;
    line-height: 1.4;
}

.sidebar-link:hover {
    color: #F0E8D8;
    background-color: rgba(240, 232, 216, 0.07);
    text-decoration: none;
}

.sidebar-link.active {
    color: var(--mr-accent) !important;
    font-weight: 600;
    background-color: rgba(240, 232, 216, 0.07);
}

.sidebar-bottom {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar-divider {
    border-color: rgba(240, 232, 216, 0.1);
    margin: 0.75rem 0.75rem;
}

/* Username row — clearly interactive */
.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.55rem 0.75rem;
    border-radius: 0.5rem;
    color: #F0E8D8;
    text-decoration: none;
    font-size: 0.9rem;
    font-family: var(--mr-font-body);
    transition: color 0.15s, background-color 0.15s;
    cursor: pointer;
    min-width: 0;
}

.sidebar-user:hover {
    color: var(--mr-accent);
    background-color: rgba(240, 232, 216, 0.1);
    text-decoration: none;
}

.sidebar-user-chevron {
    font-size: 0.7rem;
    opacity: 0.45;
    flex-shrink: 0;
}


/* =============================================================
   Range slider — theme-aware thumb color
   Bootstrap 5 hardcodes #0d6efd so CSS variables have no effect.
   Vendor pseudo-elements must be in separate rules — mixing them
   in one selector group causes the entire block to be discarded.
   ============================================================= */
[data-bs-theme="light"] .form-range::-webkit-slider-thumb { background-color: #B5451B; }
[data-bs-theme="light"] .form-range::-moz-range-thumb     { background-color: #B5451B; }
[data-bs-theme="dark"]  .form-range::-webkit-slider-thumb { background-color: #D47040; }
[data-bs-theme="dark"]  .form-range::-moz-range-thumb     { background-color: #D47040; }

[data-bs-theme="light"] .form-range:focus::-webkit-slider-thumb {
    box-shadow: 0 0 0 1px #FAF7F2, 0 0 0 0.25rem rgba(181, 69, 27, 0.25);
}
[data-bs-theme="dark"] .form-range:focus::-webkit-slider-thumb {
    box-shadow: 0 0 0 1px #1A1007, 0 0 0 0.25rem rgba(212, 112, 64, 0.25);
}

/* =============================================================
   Toggle switch — Bootstrap hardcodes #0d6efd, override directly
   ============================================================= */
[data-bs-theme="light"] .form-check-input:checked {
    background-color: #B5451B;
    border-color: #B5451B;
}
[data-bs-theme="dark"] .form-check-input:checked {
    background-color: #D47040;
    border-color: #D47040;
}


/* =============================================================
   Recipe limit progress bar (shared across My Recipes + Profile)
   Width is set by applyProgressBars() in theme.js from data-pct
   ============================================================= */
.recipe-limit-bar {
    height: 6px;
}

.recipe-limit-fill {
    width: 0%;
    transition: width 0.4s ease;
}


/* =============================================================
   Blazor-specific (preserved from template)
   ============================================================= */
h1:focus {
    outline: none;
}

.valid.modified:not([type=checkbox]) {
    outline: 1px solid #5F7A61;
}

.invalid {
    outline: 1px solid #e50000;
}

.validation-message {
    color: #e50000;
}

[data-bs-theme="dark"] .validation-message {
    color: #ff8a6b;
}

.blazor-error-boundary {
    background-color: #b32121;
    padding: 1rem 1rem 1rem 3.7rem;
    color: white;
}

    .blazor-error-boundary::after {
        content: "An error has occurred."
    }

.darker-border-checkbox.form-check-input {
    border-color: #929292;
}

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}

.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}


/* =============================================================
   Auth pages (login, register, forgot-password, reset-password)
   ============================================================= */
.auth-page {
    min-height: calc(100vh - 58px); /* 58px = mobile top navbar height */
}

.auth-card {
    width: 100%;
    max-width: 420px;
}


/* =============================================================
   Recipe card
   ============================================================= */
.recipe-card {
    display: block;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.recipe-card:hover .recipe-card-inner {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12) !important;
}

/* Landscape thumbnail — 16:9 */
.recipe-card-img {
    width: 100%;
    height: 180px;
    object-fit: cover;
}

/* Placeholder keeps the same 16:9 height */
.recipe-card-img-placeholder {
    height: 180px;
}

.recipe-card-author {
    max-width: 120px;
}

.recipe-card-author:hover {
    color: var(--bs-link-color) !important;
}


/* =============================================================
   Utility — font sizes below Bootstrap's .small / .fs-6
   ============================================================= */
.fs-xs  { font-size: .75rem; }
.fs-2xs { font-size: .7rem; }
.fs-3xs { font-size: .65rem; }


/* =============================================================
   Utility — page container width constraints
   ============================================================= */
.page-narrow     { max-width: 820px; }
.tag-input-group { max-width: 320px; }


/* =============================================================
   Utility — sticky content below fixed navbar
   ============================================================= */
.sticky-below-nav { top: 72px; }


/* =============================================================
   Utility — compact form input column widths
   ============================================================= */
.col-qty  { width: 80px; }
.col-unit { width: 90px; }


/* =============================================================
   Compact recipe thumbnails (used in modal pick-lists)
   ============================================================= */
.recipe-thumb-sm {
    width: 36px;
    height: 36px;
    border-radius: 4px;
    flex-shrink: 0;
    object-fit: cover;
}

.recipe-thumb-sm-placeholder {
    background: var(--bs-secondary-bg);
}

.recipe-thumb-md {
    width: 56px;
    height: 56px;
    border-radius: 6px;
    flex-shrink: 0;
    object-fit: cover;
}


/* =============================================================
   Scrollable list inside modals
   ============================================================= */
.modal-scroll-list {
    max-height: 320px;
    overflow-y: auto;
}


/* =============================================================
   Bottom navigation bar — mobile only (hidden at md+)
   ============================================================= */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 60px;
    background-color: var(--mr-nav-bg);
    border-top: 1px solid rgba(240, 232, 216, 0.07);
    z-index: 1030;
    /* Respect iOS home indicator / Android gesture bar */
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.bottom-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    color: rgba(240, 232, 216, 0.5);
    text-decoration: none;
    font-size: 0.65rem;
    font-family: var(--mr-font-body);
    padding: 6px 0;
    transition: color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.bottom-nav-item i {
    font-size: 1.25rem;
    line-height: 1;
}

.bottom-nav-item.active {
    color: var(--mr-accent);
}

.bottom-nav-item:hover,
.bottom-nav-item:focus {
    color: #F0E8D8;
}


/* =============================================================
   Mobile — push content above bottom nav and account for
   safe-area-inset so nothing is clipped by the notch/indicator
   ============================================================= */
@media (max-width: 991.98px) {
    main {
        padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px));
    }

    /* Tighten page horizontal padding on narrower screens */
    .container,
    .container-fluid,
    .container-xl {
        padding-left: 1rem;
        padding-right: 1rem;
    }
}
