/* DeeAndIvanCare v2 — Mobile-first, warm & homely */
/* Aesthetic: Like a well-loved family kitchen noticeboard — soft, tactile, trustworthy */

@import url('https://fonts.googleapis.com/css2?family=Lora:wght@400;500;600&family=Nunito:wght@300;400;500;600&display=swap');

:root {
    --butter:     #FDF6E3;
    --cream:      #FAF3E0;
    --card:       #FFFDF7;
    --terracotta: #C0714F;
    --terra-soft: #E8A98A;
    --forest:     #4A7C59;
    --forest-soft:#7AAD8A;
    --slate:      #3D3D3D;
    --mid:        #7A7060;
    --muted:      #B5AA98;
    --border:     #EDE5D0;
    --shadow-sm:  0 2px 8px rgba(80,60,20,0.08);
    --shadow-md:  0 4px 20px rgba(80,60,20,0.12);
    --r:          16px;
    --r-sm:       10px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Nunito', sans-serif;
    background: var(--butter);
    color: var(--slate);
    min-height: 100vh;
    padding-bottom: 80px; /* space for bottom nav */
}

/* ── Typography ── */
h1, h2, h3 { font-family: 'Lora', serif; line-height: 1.25; }
h1 { font-size: 1.6rem; font-weight: 600; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 500; }
p  { line-height: 1.65; color: var(--mid); font-size: 0.93rem; }
a  { color: var(--forest); text-decoration: none; }

/* ── Top header ── */
.top-header {
    background: var(--card);
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: var(--shadow-sm);
}
.brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.brand-heart { font-size: 1.3rem; }
.brand-name {
    font-family: 'Lora', serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--slate);
}
.header-user {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-shrink: 0;
}
.profile-link {
    display: inline-flex;
    align-items: center;
    justify-content: flex-start;
    gap: 0.45rem;
    color: inherit;
    flex-wrap: nowrap;
    white-space: nowrap;
}
.avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: var(--cream);
    border: 1px solid var(--border);
    color: var(--forest);
    font-weight: 700;
}
.avatar img,
img.avatar {
    object-fit: cover;
}
.avatar-sm {
    width: 32px;
    height: 32px;
    font-size: 0.82rem;
}
.avatar-md {
    width: 48px;
    height: 48px;
    font-size: 1rem;
}
.avatar-profile {
    width: 88px;
    height: 88px;
    font-size: 2rem;
}
.avatar-fallback {
    text-transform: uppercase;
}
.user-pill {
    font-size: 0.82rem;
    font-weight: 600;
    background: var(--cream);
    border: 1px solid var(--border);
    padding: 0.3rem 0.8rem;
    border-radius: 20px;
    color: var(--mid);
    white-space: nowrap;
}
.btn-signout {
    font-size: 0.78rem;
    color: var(--muted);
    border: 1px solid var(--border);
    padding: 0.3rem 0.7rem;
    border-radius: 20px;
    background: none;
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
    transition: all 0.2s;
}
.btn-signout:hover { color: var(--terracotta); border-color: var(--terracotta); }
.profile-card {
    display: flex;
    align-items: center;
    gap: 1rem;
}
.profile-copy h2 {
    margin-bottom: 0.2rem;
}

/* ── Page body ── */
.page {
    padding: 1.2rem;
    max-width: 640px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

/* ── Section cards ── */
.section-card {
    background: var(--card);
    border-radius: var(--r);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    animation: fadeUp 0.4s ease both;
}
.section-card:nth-child(1) { animation-delay: 0.05s }
.section-card:nth-child(2) { animation-delay: 0.10s }
.section-card:nth-child(3) { animation-delay: 0.15s }
.section-card:nth-child(4) { animation-delay: 0.20s }
.section-card:nth-child(5) { animation-delay: 0.25s }
.section-card:nth-child(6) { animation-delay: 0.30s }
.section-card:nth-child(7) { animation-delay: 0.35s }

@keyframes fadeUp {
    from { opacity:0; transform: translateY(12px); }
    to   { opacity:1; transform: translateY(0); }
}

.section-header {
    padding: 1rem 1.2rem 0.6rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}
.section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: 'Lora', serif;
    font-size: 1rem;
    font-weight: 600;
    color: var(--slate);
}
.section-icon { font-size: 1.1rem; }
.section-body { padding: 1rem 1.2rem; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.55rem 1.2rem;
    border-radius: var(--r-sm);
    font-family: 'Nunito', sans-serif;
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.18s;
    text-decoration: none;
}
.btn-primary   { background: var(--forest); color: #fff; }
.btn-primary:hover { background: #3A6347; color: #fff; }
.btn-soft      { background: var(--cream); color: var(--forest); border: 1.5px solid var(--forest-soft); }
.btn-soft:hover { background: var(--forest); color: #fff; }
.btn-danger    { background: #F5EAE5; color: var(--terracotta); border: 1.5px solid var(--terra-soft); }
.btn-danger:hover { background: var(--terracotta); color: #fff; }
.btn-full      { width: 100%; }
.btn-sm        { padding: 0.35rem 0.8rem; font-size: 0.8rem; }

/* ── Forms ── */
.form-group { margin-bottom: 0.9rem; }
.form-group label {
    display: block;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--mid);
    margin-bottom: 0.35rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.65rem 0.9rem;
    border: 1.5px solid var(--border);
    border-radius: var(--r-sm);
    font-family: 'Nunito', sans-serif;
    font-size: 0.93rem;
    color: var(--slate);
    background: var(--butter);
    outline: none;
    transition: border-color 0.2s;
    -webkit-appearance: none;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus { border-color: var(--forest); background: #fff; }

/* Keep native checkbox/radio behavior (the generic input reset above breaks it). */
.form-group input[type="checkbox"],
.form-group input[type="radio"] {
    width: auto;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: transparent;
    -webkit-appearance: auto;
    appearance: auto;
    accent-color: var(--forest);
    cursor: pointer;
}

/* collapsible add forms */
.add-form {
    border-top: 1px solid var(--border);
    padding: 1rem 1.2rem;
    background: var(--cream);
    display: none;
}
.add-form.open { display: block; }

/* ── Alerts ── */
.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--r-sm);
    font-size: 0.88rem;
    font-weight: 500;
    margin-bottom: 0.8rem;
}
.alert-success { background: #EAF4EC; color: #2D6B3A; border: 1px solid #B8D9BE; }
.alert-error   { background: #FAECEA; color: #8B2A2A; border: 1px solid #F0C0B8; }

/* ── Notice items ── */
.notice-item {
    padding: 0.9rem 0;
    border-bottom: 1px solid var(--border);
}
.notice-item:last-child { border-bottom: none; padding-bottom: 0; }
.notice-item:first-child { padding-top: 0; }
.notice-meta { font-size: 0.78rem; color: var(--muted); margin-top: 0.25rem; }
.pinned-badge {
    font-size: 0.7rem;
    background: #FFF3E0;
    color: #B26A00;
    border: 1px solid #FFD999;
    padding: 0.1rem 0.5rem;
    border-radius: 20px;
    font-weight: 600;
    margin-left: 0.4rem;
}

/* ── Medication items ── */
.med-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}
.med-item:last-child { border-bottom: none; }
.med-check {
    width: 36px; height: 36px;
    border-radius: 50%;
    border: 2px solid var(--border);
    background: var(--butter);
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
    flex-shrink: 0;
    cursor: pointer;
    transition: all 0.2s;
}
.med-check.taken { background: var(--forest); border-color: var(--forest); color: #fff; }
.med-info { flex: 1; }
.med-name { font-weight: 600; font-size: 0.93rem; color: var(--slate); }
.med-detail { font-size: 0.8rem; color: var(--muted); }

/* ── Appointments ── */
.appt-item {
    display: flex;
    gap: 0.9rem;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
    align-items: flex-start;
}
.appt-item:last-child { border-bottom: none; }
.appt-date-block {
    text-align: center;
    min-width: 44px;
    background: var(--cream);
    border-radius: var(--r-sm);
    padding: 0.4rem 0.3rem;
    border: 1px solid var(--border);
}
.appt-day   { font-size: 1.2rem; font-family: 'Lora',serif; font-weight: 600; color: var(--terracotta); line-height:1; }
.appt-month { font-size: 0.65rem; color: var(--muted); text-transform: uppercase; font-weight: 600; }
.appt-info  { flex: 1; }
.appt-title { font-weight: 600; font-size: 0.93rem; }
.appt-sub   { font-size: 0.8rem; color: var(--muted); margin-top: 0.15rem; }

/* ── Mood ── */
.mood-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 0.4rem;
    margin: 0.5rem 0;
}
.mood-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.2rem;
    padding: 0.5rem 0.2rem;
    border: 2px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--butter);
    cursor: pointer;
    font-family: 'Nunito', sans-serif;
    transition: all 0.18s;
}
.mood-btn .emoji { font-size: 1.4rem; }
.mood-btn .label { font-size: 0.65rem; color: var(--muted); font-weight: 600; }
.mood-btn.selected { border-color: var(--forest); background: #EAF4EC; }
.mood-btn input {
    position: absolute;
    opacity: 0;
    width: 1px;
    height: 1px;
    pointer-events: none;
}

/* ── Visit rota ── */
.rota-grid {
    display: grid;
    grid-template-columns: 80px 1fr 1fr 1fr;
    gap: 0;
    font-size: 0.82rem;
}
.rota-head {
    padding: 0.45rem 0.3rem;
    font-weight: 700;
    font-size: 0.72rem;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    text-align: center;
    border-bottom: 2px solid var(--border);
}
.rota-head:first-child { text-align: left; }
.rota-day-label {
    padding: 0.5rem 0.3rem;
    font-weight: 600;
    font-size: 0.82rem;
    color: var(--slate);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
}
.rota-cell {
    padding: 0.4rem 0.3rem;
    border-bottom: 1px solid var(--border);
    border-left: 1px solid var(--border);
    text-align: center;
    vertical-align: top;
    min-height: 36px;
}
.rota-name {
    display: inline-block;
    background: var(--cream);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 0.15rem 0.5rem;
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--forest);
    margin: 0.1rem;
    cursor: pointer;
}
.rota-name:hover { background: #F5EAE5; color: var(--terracotta); border-color: var(--terra-soft); }
.rota-input {
    width: 100%;
    min-width: 0;
    padding: 0.35rem 0.5rem;
    border: 1px dashed var(--border);
    border-radius: 10px;
    background: none;
    font-family: 'Nunito', sans-serif;
    font-size: 0.72rem;
    color: var(--slate);
    text-align: center;
}
.rota-input:focus {
    outline: none;
    border-color: var(--forest);
    background: #fff;
}
.rota-actions {
    display: flex;
    justify-content: flex-end;
    padding-top: 0.75rem;
}

/* ── Care notes ── */
.note-item {
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border);
}
.note-item:last-child { border-bottom: none; }
.note-cat {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--muted);
    background: var(--cream);
    padding: 0.1rem 0.5rem;
    border-radius: 20px;
    display: inline-block;
    margin-bottom: 0.3rem;
}
.note-text { font-size: 0.9rem; color: var(--slate); line-height: 1.55; }
.note-meta { font-size: 0.75rem; color: var(--muted); margin-top: 0.25rem; }

/* ── Photos ── */
.photo-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}
.photo-card {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.photo-thumb {
    width: 100%;
    aspect-ratio: 1;
    border-radius: var(--r-sm);
    overflow: hidden;
    background: var(--cream);
    border: 1px solid var(--border);
    cursor: pointer;
    padding: 0;
    display: block;
}
.photo-thumb img {
    width: 100%; height: 100%;
    object-fit: cover;
    display: block;
}
.photo-caption {
    font-size: 0.8rem;
    color: var(--slate);
    line-height: 1.35;
}
.photo-meta {
    font-size: 0.72rem;
    color: var(--muted);
}
.photo-lightbox {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}
.photo-lightbox[hidden] {
    display: none;
}
.photo-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(18, 22, 26, 0.82);
}
.photo-lightbox-inner {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    background: #111;
    border-radius: 0;
    padding: 0.65rem 0.65rem 0.6rem;
    display: grid;
    grid-template-rows: 1fr auto;
    gap: 0.5rem;
}
.photo-stage {
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    background: #000;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: pan-y;
    height: 100%;
}
.photo-lightbox-inner img {
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}
.photo-lightbox-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 50%;
    background: rgba(255,255,255,0.85);
    color: #111;
    font-size: 1.2rem;
    line-height: 1;
    cursor: pointer;
}
.photo-hit-area {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 22%;
    min-width: 60px;
    border: 0;
    background: transparent;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    text-shadow: 0 2px 8px rgba(0,0,0,0.6);
    opacity: 0.55;
    transition: opacity 0.2s ease;
}
.photo-hit-area:hover { opacity: 1; }
.photo-hit-area span {
    display: inline-flex;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.28);
}
.photo-hit-prev { left: 0; justify-content: flex-start; padding-left: 0.35rem; }
.photo-hit-next { right: 0; justify-content: flex-end; padding-right: 0.35rem; }
.photo-lightbox-footer {
    min-height: 72px;
    padding: 0.1rem 0.25rem 0.2rem;
}
.photo-lightbox-caption {
    color: #F4F4F4;
    font-size: 0.9rem;
}
.photo-lightbox-meta {
    color: #B9BCC0;
    font-size: 0.76rem;
}
.photo-carousel-controls {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.55rem;
}
.photo-control-btn {
    flex: 1;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 999px;
    background: rgba(255,255,255,0.08);
    color: #fff;
    font-size: 0.92rem;
    font-weight: 600;
    padding: 0.55rem 0.75rem;
    cursor: pointer;
}

/* ── Login ── */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    background: var(--butter);
}
.login-card {
    background: var(--card);
    border-radius: var(--r);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-md);
    padding: 2.5rem 1.8rem;
    width: 100%;
    max-width: 380px;
    text-align: center;
}
.login-heart { font-size: 2.8rem; display: block; margin-bottom: 0.5rem; }
.login-title { font-size: 1.5rem; margin-bottom: 0.2rem; }
.login-sub   { font-size: 0.88rem; color: var(--muted); margin-bottom: 2rem; }
.login-card .form-group { text-align: left; }

/* ── Empty states ── */
.empty {
    text-align: center;
    padding: 1.5rem 0.5rem;
    color: var(--muted);
    font-size: 0.88rem;
}
.empty-icon { font-size: 1.8rem; display: block; margin-bottom: 0.4rem; }

/* ── Utility ── */
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.text-muted   { color: var(--muted); font-size: 0.82rem; }
.mt-sm        { margin-top: 0.6rem; }
.mb-sm        { margin-bottom: 0.6rem; }

/* ── Desktop tweaks ── */
@media (min-width: 640px) {
    body { padding-bottom: 2rem; }
    .page { padding: 1.5rem; }
    h1 { font-size: 1.9rem; }
}

@media (max-width: 520px) {
    .top-header {
        gap: 0.75rem;
        padding: 0.9rem 1rem;
    }
    .brand-name {
        font-size: 1rem;
    }
    .btn-signout {
        padding: 0.3rem 0.55rem;
    }
    .profile-card {
        flex-direction: column;
        align-items: flex-start;
    }
    .photo-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .photo-lightbox-inner { padding: 0.5rem 0.5rem 0.55rem; }
    .photo-lightbox-inner img {
        max-height: 100%;
    }
    .photo-hit-area { display: none; }
    .photo-control-btn { font-size: 1rem; padding: 0.72rem 0.95rem; }
}

@media (min-width: 768px) {
    .photo-lightbox {
        padding: 1rem;
    }
    .photo-lightbox-inner {
        width: min(980px, 100%);
        height: min(92vh, 860px);
        height: min(92dvh, 860px);
        border-radius: 12px;
        padding: 0.8rem 0.8rem 0.7rem;
    }
    .photo-carousel-controls {
        display: none;
    }
}
