/* ------------------------------
   ESTIL GENERAL
------------------------------ */

body {
    font-family: Arial, sans-serif;
    background-color: #fffbe6; /* groc pastís suau */
    margin: 0;
    padding: 0.65rem;
    padding-top: calc(0.65rem + env(safe-area-inset-top));
    padding-right: calc(0.65rem + env(safe-area-inset-right));
    padding-bottom: calc(0.65rem + env(safe-area-inset-bottom));
    padding-left: calc(0.65rem + env(safe-area-inset-left));
    box-sizing: border-box;
}

*,
*::before,
*::after {
    box-sizing: inherit;
}

.home-wrapper {
    max-width: 480px;
    margin: auto;
    padding: 1.1rem 0.35rem 1.4rem;
}

.home-logo {
    display: block;
    width: 112px;
    height: 112px;
    object-fit: cover;
    border-radius: 24px;
    margin: 0.4rem auto 0.7rem;
    box-shadow: 0 4px 14px rgba(0,0,0,0.16);
}

.home-title {
    text-align: center;
    font-size: 2rem;
    font-weight: bold;
    margin-top: 0.6rem;
}

.home-subtitle {
    text-align: center;
    font-size: 1rem;
    color: #444;
    margin-top: 0.2rem;
    margin-bottom: 1.2rem;
}

.home-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
}

.home-card {
    min-height: 112px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.12);
    text-decoration: none;
    color: #111;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.45rem;
    border-left: 10px solid #a7c7ff;
}

.home-card:nth-child(2) {
    border-left-color: #ffd36b;
}

.home-card:nth-child(3) {
    border-left-color: #9ff2c3;
}

.home-card:nth-child(4) {
    border-left-color: #dcd0ff;
}

.home-card:nth-child(5) {
    border-left-color: #ffb3c6;
}

.home-card:nth-child(6) {
    border-left-color: #b3d9ff;
}

.home-card:nth-child(7) {
    border-left-color: #9fded8;
}

.home-card:nth-child(8) {
    border-left-color: #ffc8a2;
}

.home-card:last-child:nth-child(odd) {
    grid-column: 1 / -1;
}

.home-emoji {
    font-size: 2.1rem;
    line-height: 1;
}

.home-label {
    font-size: 1rem;
    font-weight: bold;
    text-align: center;
}

.home-card-pending {
    opacity: 0.55;
}

.home-footer-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    margin-top: 1rem;
}

.home-footer-actions.home-footer-single {
    grid-template-columns: 1fr;
}

.home-footer-button {
    align-items: center;
    border: none;
    border-radius: 15px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.12);
    color: #111;
    cursor: pointer;
    display: flex;
    font-family: inherit;
    font-size: 1rem;
    font-weight: bold;
    justify-content: center;
    min-height: 48px;
    padding: 0.85rem 0.6rem;
    text-align: center;
    text-decoration: none;
}

.login-wrapper {
    max-width: 420px;
    margin: auto;
    padding: 1.1rem 0.35rem 1.4rem;
}

.login-card {
    background: #fff;
    border-left: 10px solid #ffd36b;
    border-radius: 15px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.12);
    padding: 1rem;
}

.login-card label {
    display: block;
    margin: 0.75rem 0 0.25rem;
    font-weight: bold;
}

.login-card input {
    width: 100%;
    box-sizing: border-box;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 0.7rem;
    font-size: 1rem;
}

.login-error {
    margin-top: 0.8rem;
    padding: 0.65rem;
    background: #fff0f6;
    border-radius: 10px;
    color: #8a2348;
    font-weight: bold;
}

.login-message {
    margin-top: 0.8rem;
    padding: 0.65rem;
    background: #eaf8ef;
    border-radius: 10px;
    color: #225b35;
    font-weight: bold;
}

.login-recover-button {
    width: 100%;
    margin-top: 0.7rem;
    padding: 0.8rem;
    background: #fff;
    border: 2px solid #dcd0ff;
    border-radius: 12px;
    color: #111;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
}

.week-wrapper {
    max-width: 480px;
    margin: auto;
    padding: 1rem 0.35rem 1.4rem;
}

/* ------------------------------
   TÍTOLS
------------------------------ */

.week-title {
    text-align: center;
    font-size: 1.6rem;
    font-weight: bold;
    margin-bottom: 0.2rem;
}

.week-subtitle {
    text-align: center;
    font-size: 0.95rem;
    color: #555;
    margin-top: 0.15rem;
    margin-bottom: 0.9rem;
}

.week-range {
    text-align: center;
    font-size: 0.9rem;
    margin-bottom: 1rem;
    color: #444;
}

/* ------------------------------
   BOTONS DE SETMANA
------------------------------ */

.nav-button {
    padding: 0.5rem 0.8rem;
    background: #dcd0ff;
    border: none;
    border-radius: 20px;
    font-size: 1rem;
    color: #111;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0,0,0,0.15);
    transition: 0.2s;
}

.nav-button:hover {
    transform: translateY(-2px);
}

.section-top-actions {
    display: flex;
    gap: 0.5rem;
    margin: 1rem 0;
}

.section-top-actions a {
    flex: 1;
    text-decoration: none;
}

.section-top-actions .edit-button {
    margin-top: 0;
    padding: 0.75rem 0.45rem;
    border-radius: 10px;
}

.week-nav-card {
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.12);
    padding: 1rem;
    margin: 1rem 0;
}

.week-nav-card .week-range {
    margin-bottom: 0.8rem;
}

.week-nav-row {
    display: flex;
    gap: 0.5rem;
}

.week-nav-row a {
    flex: 1;
}

.week-nav-row .nav-button {
    width: 100%;
    color: #111;
    font-size: 1rem;
}

.week-wrapper > a .main-menu-button {
    display: none;
}

/* ------------------------------
   INTERRUPTOR AMPLIAR
------------------------------ */

.switch-block {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-left: 0.5rem;
}

.switch-label {
    font-size: 0.75rem;
    margin-bottom: 0.2rem;
    color: #444;
}

.switch {
    position: relative;
    width: 48px;
    height: 26px;
    background: #dcdcdc;
    border-radius: 20px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.switch.active {
    background: #9ff2c3; /* verd menta */
}

.switch-ball {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
}

.switch.active .switch-ball {
    transform: translateX(22px);
}

/* ------------------------------
   GRID
------------------------------ */

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    margin-top: 1rem;
}

/* Vista ampliada → 1 columna + lletra més gran */
.one-column .grid-2 {
    grid-template-columns: 1fr !important;
}

.one-column .day-card-small {
    font-size: 1rem !important;
}

.one-column .day-header-small {
    font-size: 1.1rem;
}

.one-column .meal-title {
    font-size: 1.05rem;
    margin-top: 0.55rem;
}

.one-column .meal-content {
    font-size: 1rem;
    line-height: 1.35;
}

/* ------------------------------
   TARGETES DEL DIA
------------------------------ */

.day-card-small {
    background: white;
    border-radius: 15px;
    padding: 0.8rem;
    box-shadow: 0 3px 8px rgba(0,0,0,0.12);
    font-size: 0.85rem;
}

/* Franges pastel alternades */
.day-0 { border-left: 10px solid #ffb3c6; }
.day-1 { border-left: 10px solid #b3d9ff; }
.day-2 { border-left: 10px solid #c6ffb3; }
.day-3 { border-left: 10px solid #ffd9b3; }
.day-4 { border-left: 10px solid #e6b3ff; }
.day-5 { border-left: 10px solid #fff2b3; }

/* Quimio */
.quimio {
    border-left: 10px solid #ff9a3c !important;
    background: #ffe7cc !important;
}

.day-header-small {
    font-weight: bold;
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}

/* ------------------------------
   MENÚ
------------------------------ */

.meal-title {
    font-weight: bold;
    margin-top: 0.3rem;
}

.meal-content {
    font-size: 0.8rem;
    margin-left: 0.4rem;
}

.rate-day-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    width: auto;
    margin: 0.2rem 0 0.45rem auto;
    padding: 0.38rem 0.65rem;
    border: 2px solid #dcd0ff;
    border-radius: 999px;
    background: #fbf8ff;
    color: #111;
    font-size: 0.82rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.rate-day-button span {
    color: #d95b86;
    line-height: 1;
}

.rating-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.3);
    padding: 1rem;
}

.rating-panel {
    width: 100%;
    max-width: 430px;
    max-height: 88vh;
    overflow: auto;
    background: #fffdf5;
    border: 2px solid #ffd36b;
    border-radius: 18px;
    box-shadow: 0 5px 18px rgba(0,0,0,0.22);
    padding: 1rem;
}

.rating-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.8rem;
    margin-bottom: 0.8rem;
}

.rating-kicker {
    font-size: 0.8rem;
    color: #555;
    font-weight: bold;
}

.rating-panel h3 {
    margin: 0.1rem 0 0;
    font-size: 1.15rem;
}

.rating-close {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: #dcd0ff;
    color: #111;
    font-size: 1.3rem;
    font-weight: bold;
    cursor: pointer;
}

.rating-cards {
    display: grid;
    gap: 0.75rem;
}

.rating-card {
    background: #fff;
    border-left: 8px solid #a7c7ff;
    border-radius: 12px;
    padding: 0.85rem;
    box-shadow: 0 2px 7px rgba(0,0,0,0.1);
}

.rating-card:nth-child(2) { border-left-color: #9ff2c3; }
.rating-card:nth-child(3) { border-left-color: #ffd36b; }
.rating-card:nth-child(4) { border-left-color: #dcd0ff; }
.rating-card:nth-child(5) { border-left-color: #ffb3c6; }

.rating-card h4 {
    margin: 0 0 0.45rem;
    font-size: 1rem;
}

.rating-foods {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-bottom: 0.65rem;
}

.rating-foods span {
    background: #fff7d6;
    border-radius: 999px;
    padding: 0.28rem 0.55rem;
    font-size: 0.85rem;
}

.rating-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.rating-choice {
    border: 2px solid #e5e5e5;
    border-radius: 10px;
    background: #fff;
    color: #111;
    padding: 0.6rem 0.35rem;
    font-size: 0.9rem;
    font-weight: bold;
    cursor: pointer;
}

.rating-choice.active {
    border-color: #dcd0ff;
    background: #f1ecff;
}

.rating-message {
    display: none;
    margin-top: 0.75rem;
    padding: 0.65rem;
    border-radius: 10px;
    background: #eaf8ef;
    color: #111;
    font-weight: bold;
    text-align: center;
}

/* ------------------------------
   NOTES
------------------------------ */

.notes-card {
    background: #fff7d6;
    border-left: 10px solid #ffd36b;
    border-radius: 15px;
    padding: 1rem;
    box-shadow: 0 3px 8px rgba(0,0,0,0.12);
    display: flex;
    flex-direction: column;
}

.notes-card form {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

.notes-title {
    font-weight: bold;
    font-size: 1rem;
    margin-bottom: 0.5rem;
}

.notes-area {
    width: 100%;
    flex: 1;
    min-height: 120px;
    border: none;
    border-radius: 10px;
    padding: 0.6rem;
    font-size: 0.9rem;
    resize: none;
    background: #fffdf5;
    box-sizing: border-box;
}

.save-notes {
    margin-top: 0.6rem;
    width: 100%;
    padding: 0.7rem;
    background: #ffd36b;
    border: none;
    border-radius: 10px;
    font-weight: bold;
    font-size: 1rem;
    color: #111;
    cursor: pointer;
}

/* ------------------------------
   BOTÓ EDITAR
------------------------------ */

.edit-button {
    width: 100%;
    padding: 0.9rem;
    background: #a7c7ff;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: bold;
    color: #111;
    cursor: pointer;
    margin-top: 1.5rem;
}

.main-action-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
    margin-top: 1.5rem;
}

.main-action-row a {
    display: block;
}

.main-action-row .edit-button {
    height: 100%;
    margin-top: 0;
    padding: 0.8rem 0.45rem;
}

.shopping-button {
    background: #9ff2c3;
    color: #111;
}

.print-button {
    background: #ffb3c6;
    color: #111;
}

.main-menu-button {
    background: #ffd36b;
    color: #111;
    margin-top: 0.8rem;
}

.install-button {
    background: #dcd0ff;
    color: #111;
    margin-top: 0.8rem;
}

.home-footer-actions .install-button {
    margin-top: 0;
}

.privacy-button {
    background: #9ff2c3;
    color: #111;
}

.week-wrapper #installAppButton {
    display: none !important;
}

.install-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
}

.install-box {
    width: 82%;
    max-width: 350px;
    background: #fff7d6;
    border: 2px solid #ffd36b;
    border-radius: 18px;
    padding: 1.4rem;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.install-box h3 {
    margin-top: 0;
}

.install-box p {
    white-space: pre-line;
    color: #444;
}

.install-close {
    width: 100%;
    padding: 0.8rem;
    background: #ffd36b;
    border: none;
    border-radius: 10px;
    font-weight: bold;
    font-size: 1rem;
    color: #111;
    cursor: pointer;
}

.consult-add-card,
.consult-week-group,
.consult-answers-card {
    background: #fff;
    border-radius: 15px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.12);
    padding: 1rem;
    margin-top: 1rem;
}

.consult-add-card {
    border-left: 10px solid #dcd0ff;
}

.consult-title,
.consult-week-title {
    font-size: 1rem;
    font-weight: bold;
    margin-bottom: 0.7rem;
}

.consult-section-heading {
    font-weight: bold;
    margin: 1rem 0 0.6rem;
    color: #333;
}

.consult-week-title {
    color: #333;
}

.consult-week-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
    margin-bottom: 0.7rem;
}

.consult-week-row label {
    font-size: 0.85rem;
    font-weight: bold;
    color: #444;
}

.consult-week-row input {
    width: 100%;
    margin-top: 0.25rem;
    border: 1px solid #ddd;
    border-radius: 10px;
    padding: 0.55rem;
    font-size: 1rem;
}

.consult-current-week {
    display: inline-block;
    background: #f1ecff;
    border-radius: 999px;
    padding: 0.35rem 0.65rem;
    margin-bottom: 0.7rem;
    color: #444;
    font-size: 0.85rem;
    font-weight: bold;
}

.consult-textarea {
    width: 100%;
    min-height: 110px;
    border: 1px solid #ddd;
    border-radius: 12px;
    padding: 0.75rem;
    resize: vertical;
    font-size: 1rem;
    background: #fffdf5;
}

.consult-list {
    margin-top: 1rem;
}

.consult-note {
    display: grid;
    grid-template-columns: 36px 1fr;
    gap: 0.65rem;
    align-items: start;
    background: #fffdf5;
    border: 1px solid #f0e7c8;
    border-radius: 12px;
    padding: 0.7rem;
    margin-top: 0.6rem;
}

.consult-note-done {
    opacity: 0.62;
    background: #f7f7f7;
}

.consult-note-done .consult-note-text {
    text-decoration: line-through;
}

.consult-check-form {
    margin: 0;
}

.consult-check {
    width: 34px;
    height: 34px;
    border: 2px solid #9ff2c3;
    border-radius: 10px;
    background: #fff;
    color: #111;
    font-size: 1rem;
    font-weight: bold;
    cursor: pointer;
}

.consult-note-done .consult-check {
    background: #9ff2c3;
}

.consult-origin {
    display: inline-block;
    background: #f1ecff;
    border-radius: 999px;
    padding: 0.22rem 0.55rem;
    font-size: 0.78rem;
    font-weight: bold;
    margin-bottom: 0.35rem;
}

.consult-origin-nutricion {
    background: #e8f8dd;
}

.consult-origin-medicacion {
    background: #e8efff;
}

.consult-origin-manual {
    background: #fff1c8;
}

.consult-note-text {
    white-space: normal;
    line-height: 1.35;
}

.consult-empty {
    background: #fff;
    border-left: 10px solid #ffd36b;
    border-radius: 15px;
    box-shadow: 0 3px 8px rgba(0,0,0,0.12);
    padding: 1rem;
    color: #555;
}

.consult-answers-card {
    border-left: 10px solid #a7c7ff;
}

.consult-answers-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.7rem;
    flex-wrap: wrap;
}

.consult-free-answer-button {
    border: 1px solid #cbbcff;
    border-radius: 999px;
    background: #f1ecff;
    color: #111;
    font-size: 0.85rem;
    font-weight: bold;
    padding: 0.42rem 0.75rem;
    cursor: pointer;
}

.consult-search-form {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.6rem;
    align-items: center;
}

.consult-search-form input {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 12px;
    padding: 0.75rem;
    font-size: 1rem;
    background: #fffdf5;
}

.consult-clear-search {
    display: inline-block;
    margin-top: 0.7rem;
    color: #111;
    font-weight: bold;
}

.consult-answer-list {
    margin-top: 0.8rem;
}

.consult-answer-card {
    background: #f8fbff;
    border: 1px solid #dce8ff;
    border-radius: 12px;
    padding: 0.8rem;
    margin-top: 0.7rem;
}

.consult-answer-meta {
    display: inline-block;
    background: #e8efff;
    border-radius: 999px;
    padding: 0.25rem 0.6rem;
    font-size: 0.78rem;
    font-weight: bold;
    color: #444;
    margin-bottom: 0.55rem;
}

.consult-answer-question {
    font-weight: bold;
    line-height: 1.35;
    margin-bottom: 0.5rem;
}

.consult-answer-text {
    background: #fff;
    border-radius: 10px;
    padding: 0.7rem;
    line-height: 1.4;
}

.consult-answer-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 0.45rem;
}

.consult-small-button {
    border: 0;
    border-radius: 999px;
    color: #111;
    font-size: 0.78rem;
    font-weight: bold;
    padding: 0.25rem 0.6rem;
    cursor: pointer;
}

.consult-edit-answer {
    background: #dcd0ff;
    border: 1px solid #cbbcff;
}

.consult-modal-delete {
    width: 100%;
    border: 1px solid #ffc1c1;
    border-radius: 999px;
    background: #fff2f2;
    color: #111;
    font-size: 0.9rem;
    font-weight: bold;
    padding: 0.65rem;
    margin-top: 0.7rem;
    cursor: pointer;
}

.consult-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.28);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 999;
}

.consult-modal-card {
    width: min(94vw, 520px);
    max-height: 88vh;
    overflow: auto;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 18px 40px rgba(0,0,0,0.18);
    padding: 1rem;
    border-left: 10px solid #dcd0ff;
    position: relative;
}

.consult-modal-card label {
    display: block;
    font-weight: bold;
    margin: 0.75rem 0 0.3rem;
    color: #333;
}

.consult-modal-close {
    position: absolute;
    top: 0.55rem;
    right: 0.65rem;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: #fff1c8;
    color: #111;
    font-size: 1.3rem;
    font-weight: bold;
    cursor: pointer;
}

.consult-modal-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.55rem;
    margin-top: 0.85rem;
}

.consult-secondary-button {
    width: 100%;
    border: 0;
    border-radius: 12px;
    background: #a7c7ff;
    color: #111;
    font-size: 1rem;
    font-weight: bold;
    padding: 0.85rem;
    cursor: pointer;
}

@media (max-width: 520px) {
    .consult-search-form {
        grid-template-columns: 1fr;
    }
}
