
/* =========================================
   RESET
========================================= */

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    width: 100%;
    min-height: 100%;
    overflow-x: hidden;
}

body {
    width: 100%;
    min-height: 100vh;
    overflow-x: hidden;

    font-family:
        Arial,
        Helvetica,
        sans-serif;

    background: var(--bg);
    color: var(--text);

    -webkit-tap-highlight-color: transparent;
}


/* =========================================
   VARIABLES
========================================= */

:root {
    --bg: #f1f2f4;
    --card: #ffffff;
    --text: #151515;
    --muted: #777777;
    --border: #dddddd;

    --accent: #111111;
    --accent-text: #ffffff;

    --danger: #c62828;

    --input: #ffffff;

    --shadow:
        0 8px 25px rgba(0, 0, 0, 0.08);
}

body.dark {
    --bg: #0c0c0c;
    --card: #181818;
    --text: #f5f5f5;
    --muted: #999999;
    --border: #303030;

    --accent: #ffffff;
    --accent-text: #000000;

    --danger: #ef5350;

    --input: #202020;

    --shadow:
        0 8px 30px rgba(0, 0, 0, 0.35);
}


/* =========================================
   BACKGROUND
========================================= */

.background {
    position: fixed;
    inset: 0;

    width: 100vw;
    height: 100vh;

    background-image: url("fond.jpg");
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;

    opacity: 0.24;

    z-index: 0;
    pointer-events: none;
}


/* =========================================
   APPLICATION
========================================= */

#app {
    position: relative;
    z-index: 1;

    width: 100%;
    max-width: 430px;

    min-height: 100vh;

    margin: 0 auto;

    background: transparent;
}


/* =========================================
   PAGES
========================================= */

.page {
    display: none;

    width: 100%;

    min-height: 100vh;

    padding:
        20px
        15px
        110px;
}

.page.active {
    display: block;
}


/* =========================================
   HEADER
========================================= */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;

    margin-bottom: 25px;
}

.page-header h1 {
    font-size: 28px;
    line-height: 1.1;

    font-weight: 800;
}

.page-header p {
    margin-top: 7px;

    font-size: 13px;

    color: var(--muted);
}


/* =========================================
   SECTION TITLES
========================================= */

.section-title {
    margin:
        20px
        0
        12px;
}

.section-title h2 {
    font-size: 17px;
    font-weight: 800;
}

.recipe-section-title {
    margin-top: 28px;
}

.form-section-title {
    margin-top: 25px;
}


/* =========================================
   GOAL FILTERS
========================================= */

.goal-filters {
    display: grid;

    grid-template-columns:
        repeat(3, 1fr);

    gap: 7px;
}

.goal-filter {
    min-height: 42px;

    padding: 8px;

    border:
        1px solid
        var(--border);

    border-radius: 12px;

    background: var(--card);
    color: var(--text);

    font-size: 12px;
    font-weight: 700;

    cursor: pointer;
}

.goal-filter.active {
    background: var(--accent);
    color: var(--accent-text);

    border-color: var(--accent);
}


/* =========================================
   CATEGORY GRID
========================================= */

.category-grid {
    display: grid;

    grid-template-columns:
        repeat(2, 1fr);

    gap: 10px;
}

.category-button {
    min-height: 90px;

    padding: 10px;

    display: flex;

    flex-direction: column;

    align-items: center;
    justify-content: center;

    gap: 7px;

    border:
        1px solid
        var(--border);

    border-radius: 16px;

    background: var(--card);
    color: var(--text);

    cursor: pointer;

    box-shadow: var(--shadow);
}

.category-button img {
    width: 38px;
    height: 38px;

    object-fit: contain;
}

.category-button span {
    font-size: 13px;
    font-weight: 700;
}

.category-button.active {
    border-color: var(--accent);

    box-shadow:
        0 0 0 2px
        var(--accent);
}


/* =========================================
   RECIPE LIST
========================================= */

.recipe-list {
    display: flex;

    flex-direction: column;

    gap: 12px;
}

.recipe-card {
    width: 100%;

    display: flex;

    align-items: center;

    gap: 12px;

    padding: 10px;

    border:
        1px solid
        var(--border);

    border-radius: 17px;

    background: var(--card);

    box-shadow: var(--shadow);

    cursor: pointer;
}

.recipe-card-image {
    width: 78px;
    height: 78px;

    flex-shrink: 0;

    border-radius: 13px;

    object-fit: cover;

    background: var(--bg);
}

.recipe-card-content {
    min-width: 0;

    flex: 1;
}

.recipe-card-title {
    font-size: 16px;
    font-weight: 800;

    white-space: nowrap;

    overflow: hidden;

    text-overflow: ellipsis;
}

.recipe-card-category {
    margin-top: 4px;

    font-size: 12px;

    color: var(--muted);
}

.recipe-card-macros {
    display: flex;

    gap: 9px;

    margin-top: 9px;

    font-size: 11px;
    font-weight: 700;

    color: var(--muted);
}

.recipe-card-macros strong {
    color: var(--text);
}


/* =========================================
   EMPTY
========================================= */

.empty-state {
    display: none;

    padding: 35px 15px;

    text-align: center;

    border:
        1px dashed
        var(--border);

    border-radius: 17px;

    background: var(--card);
}

.empty-state.show {
    display: block;
}

.empty-state h3 {
    font-size: 18px;
}

.empty-state p {
    margin-top: 8px;

    font-size: 13px;

    color: var(--muted);
}


/* =========================================
   FORM
========================================= */

#recipe-form {
    display: flex;

    flex-direction: column;

    gap: 16px;
}

.form-group {
    display: flex;

    flex-direction: column;

    gap: 7px;
}

.form-group label {
    font-size: 13px;

    font-weight: 700;
}

input,
select,
textarea {
    width: 100%;

    border:
        1px solid
        var(--border);

    border-radius: 12px;

    background: var(--input);
    color: var(--text);

    font-family: inherit;

    font-size: 14px;

    outline: none;
}

input,
select {
    height: 46px;

    padding: 0 13px;
}

textarea {
    padding: 12px;

    resize: vertical;

    min-height: 120px;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--accent);
}


/* =========================================
   IMAGE UPLOAD
========================================= */

.image-upload {
    min-height: 120px;

    display: flex;

    align-items: center;
    justify-content: center;

    border:
        1px dashed
        var(--border);

    border-radius: 15px;

    background: var(--card);

    cursor: pointer;
}

.image-upload input {
    display: none;
}

.image-upload span {
    font-size: 13px;

    font-weight: 700;

    color: var(--muted);
}

.image-preview {
    display: none;

    width: 100%;
}

.image-preview.show {
    display: block;
}

.image-preview img {
    width: 100%;

    max-height: 230px;

    object-fit: cover;

    border-radius: 15px;
}


/* =========================================
   MACROS
========================================= */

.macros-grid {
    display: grid;

    grid-template-columns:
        repeat(2, 1fr);

    gap: 10px;
}


/* =========================================
   BUTTONS
========================================= */

.primary-button {
    width: 100%;

    min-height: 50px;

    margin-top: 5px;

    border: 0;

    border-radius: 14px;

    background: var(--accent);
    color: var(--accent-text);

    font-size: 14px;
    font-weight: 800;

    cursor: pointer;
}

.primary-button:active {
    transform: scale(0.98);
}


/* =========================================
   SETTINGS
========================================= */

.settings-card {
    margin-bottom: 12px;

    padding: 16px;

    border:
        1px solid
        var(--border);

    border-radius: 17px;

    background: var(--card);

    box-shadow: var(--shadow);
}

.setting-row {
    display: flex;

    align-items: center;
    justify-content: space-between;

    gap: 15px;
}

.setting-row div {
    display: flex;

    flex-direction: column;

    gap: 5px;
}

.setting-row strong {
    font-size: 14px;
}

.setting-row span {
    font-size: 12px;

    color: var(--muted);
}


/* =========================================
   SWITCH
========================================= */

.switch {
    position: relative;

    width: 48px;
    height: 27px;

    flex-shrink: 0;
}

.switch input {
    display: none;
}

.slider {
    position: absolute;

    inset: 0;

    border-radius: 30px;

    background: #cccccc;

    cursor: pointer;

    transition: 0.2s;
}

.slider::before {
    content: "";

    position: absolute;

    width: 21px;
    height: 21px;

    left: 3px;
    top: 3px;

    border-radius: 50%;

    background: white;

    transition: 0.2s;
}

.switch input:checked + .slider {
    background: var(--accent);
}

.switch input:checked + .slider::before {
    transform: translateX(21px);
}


/* =========================================
   SETTINGS BUTTONS
========================================= */

.settings-button {
    width: 100%;

    min-height: 70px;

    margin-top: 10px;

    padding: 10px 13px;

    display: flex;

    align-items: center;

    gap: 13px;

    border:
        1px solid
        var(--border);

    border-radius: 16px;

    background: var(--card);
    color: var(--text);

    text-align: left;

    cursor: pointer;

    box-shadow: var(--shadow);
}

.settings-button img {
    width: 38px;
    height: 38px;

    object-fit: contain;

    flex-shrink: 0;
}

.settings-button span {
    display: flex;

    flex-direction: column;

    gap: 5px;
}

.settings-button strong {
    font-size: 14px;
}

.settings-button small {
    font-size: 11px;

    color: var(--muted);
}

.danger-button {
    color: var(--danger);
}

.danger-button img {
    opacity: 0.9;
}


/* =========================================
   SUBPAGES
========================================= */

.subpage-header {
    display: flex;

    align-items: center;

    gap: 12px;

    margin-bottom: 22px;
}

.subpage-header h1 {
    font-size: 23px;
}

.back-button {
    width: 42px;
    height: 42px;

    display: flex;

    align-items: center;
    justify-content: center;

    border:
        1px solid
        var(--border);

    border-radius: 12px;

    background: var(--card);

    cursor: pointer;
}

.back-button img {
    width: 21px;
    height: 21px;

    object-fit: contain;
}


/* =========================================
   INFO CARDS
========================================= */

.info-card {
    margin-bottom: 12px;

    padding: 16px;

    border:
        1px solid
        var(--border);

    border-radius: 16px;

    background: var(--card);

    box-shadow: var(--shadow);
}

.info-card h2 {
    font-size: 16px;
}

.info-card p {
    margin-top: 9px;

    font-size: 13px;

    line-height: 1.6;

    color: var(--muted);
}


/* =========================================
   BOTTOM NAVIGATION
========================================= */

.bottom-nav {
    position: fixed;

    z-index: 100;

    left: 50%;
    bottom: 10px;

    transform: translateX(-50%);

    width: calc(100% - 20px);

    max-width: 410px;

    height: 68px;

    display: flex;

    align-items: center;
    justify-content: space-around;

    padding: 6px;

    border:
        1px solid
        var(--border);

    border-radius: 21px;

    background:
        rgba(255, 255, 255, 0.94);

    backdrop-filter: blur(14px);

    box-shadow:
        0 10px 30px
        rgba(0, 0, 0, 0.12);
}

body.dark .bottom-nav {
    background:
        rgba(25, 25, 25, 0.94);
}

.nav-button {
    width: 110px;
    height: 56px;

    display: flex;

    flex-direction: column;

    align-items: center;
    justify-content: center;

    gap: 3px;

    border: 0;

    border-radius: 15px;

    background: transparent;

    color: var(--muted);

    cursor: pointer;
}

.nav-button img {
    width: 24px;
    height: 24px;

    object-fit: contain;
}

.nav-button span {
    font-size: 10px;

    font-weight: 700;
}

.nav-button.active {
    color: var(--text);
}

.add-button {
    width: 54px;
    height: 54px;

    border: 0;

    border-radius: 50%;

    display: flex;

    align-items: center;
    justify-content: center;

    background: var(--accent);
    color: var(--accent-text);

    box-shadow:
        0 6px 18px
        rgba(0, 0, 0, 0.2);

    cursor: pointer;
}

.add-button span {
    font-size: 30px;

    line-height: 1;

    font-weight: 300;
}


/* =========================================
   MODAL
========================================= */

.modal {
    position: fixed;

    z-index: 200;

    inset: 0;

    display: none;

    align-items: flex-end;
    justify-content: center;
}

.modal.show {
    display: flex;
}

.modal-overlay {
    position: absolute;

    inset: 0;

    background:
        rgba(0, 0, 0, 0.65);
}

.modal-content {
    position: relative;

    z-index: 2;

    width: 100%;
    max-width: 430px;

    max-height: 92vh;

    overflow-y: auto;

    border-radius:
        25px
        25px
        0
        0;

    background: var(--card);

    color: var(--text);

    animation: modalIn 0.2s ease;
}

@keyframes modalIn {

    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }

}

.modal-close {
    position: absolute;

    z-index: 5;

    top: 12px;
    right: 12px;

    width: 38px;
    height: 38px;

    display: flex;

    align-items: center;
    justify-content: center;

    border: 0;

    border-radius: 50%;

    background:
        rgba(0, 0, 0, 0.55);

    cursor: pointer;
}

.modal-close img {
    width: 19px;
    height: 19px;
}

.modal-image {
    width: 100%;

    height: 230px;

    object-fit: cover;

    background: var(--bg);
}

.modal-body {
    padding: 20px 16px 30px;
}

.modal-body h2 {
    font-size: 24px;
}

.modal-category {
    margin-top: 5px;

    font-size: 12px;

    color: var(--muted);
}

.modal-macros {
    display: grid;

    grid-template-columns:
        repeat(4, 1fr);

    gap: 7px;

    margin: 18px 0;
}

.modal-macros div {
    padding: 10px 5px;

    text-align: center;

    border:
        1px solid
        var(--border);

    border-radius: 12px;

    background: var(--bg);
}

.modal-macros strong {
    display: block;

    font-size: 14px;
}

.modal-macros span {
    display: block;

    margin-top: 3px;

    font-size: 9px;

    color: var(--muted);
}

.modal-section {
    margin-top: 20px;
}

.modal-section h3 {
    font-size: 16px;
}

.modal-section p {
    margin-top: 9px;

    white-space: pre-line;

    font-size: 13px;

    line-height: 1.65;

    color: var(--muted);
}

.modal-delete {
    width: 100%;

    min-height: 48px;

    margin-top: 25px;

    border:
        1px solid
        var(--danger);

    border-radius: 13px;

    background: transparent;

    font-weight: 800;

    cursor: pointer;
}


/* =========================================
   PETITS TELEPHONES
========================================= */

@media (max-width: 360px) {

    .page {
        padding-left: 12px;
        padding-right: 12px;
    }

    .page-header h1 {
        font-size: 24px;
    }

    .goal-filter {
        font-size: 10px;
    }

    .category-button {
        min-height: 82px;
    }

    .recipe-card-image {
        width: 68px;
        height: 68px;
    }

    .recipe-card-macros {
        gap: 5px;
        font-size: 10px;
    }

    .bottom-nav {
        width: calc(100% - 14px);
    }

}


/* =========================================
   DESKTOP : GARDE UNE APP MOBILE
========================================= */

@media (min-width: 431px) {

    body {
        background: #dfe1e5;
    }

    #app {
        background: transparent;
    }

}
