/*
 * CARE KIT — giao diện nhật ký chăm sóc (dùng chung Desktop + Mobile)
 * Theme "Maroon & Sand". Font kế thừa từ trang.
 */
:root {
    --ck-brand: #6B1238;
    --ck-brand-2: #8E2350;
    --ck-brand-soft: #F8EEF2;
    --ck-gold: #B8956A;
    --ck-gold-soft: #EADCC6;
    --ck-gold-dark: #8F6F48;
    --ck-sage: #6A9A6B;
    --ck-water: #3A7CA5;
    --ck-water-soft: #E6F0F6;
    --ck-danger: #C8414B;
    --ck-surface: #FFFDFA;
    --ck-field: #F5EFEA;
    --ck-border: #ECE4DE;
    --ck-text: #43333A;
    --ck-strong: #2E1F25;
    --ck-muted: #8C7C82;
    --ck-shadow: 0 10px 24px -14px rgba(74, 20, 44, 0.3);
    --ck-display: 'Fraunces', Georgia, serif;
}

.ck-hidden { display: none !important; }
.admin-only-block { display: none; }
body.is-admin .admin-only-block { display: block; }
.ck-muted { color: var(--ck-muted); font-size: 13px; }
.ck-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.ck-empty { color: var(--ck-muted); font-size: 14px; padding: 18px 4px; text-align: center; }
.ck-hint { font-size: 12px; color: var(--ck-muted); margin-top: 6px; }
.ck-subhead { font-size: 11px; font-weight: 800; letter-spacing: 1.1px; text-transform: uppercase; color: var(--ck-gold-dark); margin-bottom: 10px; }

/* ---------- Buttons ---------- */
.ck-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    min-height: 40px; padding: 8px 16px; border-radius: 999px; border: 1px solid var(--ck-border);
    background: var(--ck-surface); color: var(--ck-text); font: inherit; font-size: 14px; font-weight: 700;
    cursor: pointer; transition: transform .15s, background .2s, box-shadow .2s; white-space: nowrap;
}
.ck-btn:hover { background: var(--ck-field); }
.ck-btn:active { transform: scale(.97); }
.ck-btn--primary { background: linear-gradient(135deg, var(--ck-brand), var(--ck-brand-2)); color: #FFFDFA; border-color: transparent; box-shadow: 0 8px 18px -10px rgba(107, 18, 56, .7); }
.ck-btn--primary:hover { background: linear-gradient(135deg, #561030, var(--ck-brand)); }
.ck-btn--ghost { background: transparent; }
.ck-link { background: none; border: none; color: var(--ck-brand); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; padding: 6px 0; text-decoration: underline; text-underline-offset: 3px; }
.ck-icon-btn { width: 34px; height: 34px; border-radius: 50%; border: none; background: transparent; color: var(--ck-muted); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.ck-icon-btn:hover { background: var(--ck-field); color: var(--ck-brand); }
.ck-icon-btn--danger:hover { color: var(--ck-danger); background: #FBE9EA; }

/* ---------- List badge & quick water ---------- */
.ck-badge { display: inline-flex; align-items: center; gap: 3px; font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; white-space: nowrap; font-family: inherit; letter-spacing: 0; text-transform: none; }
.ck-badge--none { background: var(--ck-field); color: var(--ck-muted); }
.ck-badge--ok { background: #EEF5EC; color: #3F6B41; }
.ck-badge--soon { background: #FBF1DF; color: #8A6420; }
.ck-badge--overdue { background: #FBE9EA; color: #A8323B; }
.ck-badge--alive { background: #EEF5EC; color: #3F6B41; }
.ck-badge--dead { background: #EDE7E9; color: #6E5C63; }
.ck-quick {
    width: 36px; height: 36px; flex-shrink: 0; border-radius: 50%; border: 1px solid #CFE0EA; background: var(--ck-water-soft);
    font-size: 16px; line-height: 1; cursor: pointer; align-items: center; justify-content: center; transition: transform .15s, background .2s;
}
.ck-quick:hover { background: #D5E6F0; transform: scale(1.08); }
.ck-quick:active { transform: scale(.9); }

/* ---------- Panel ---------- */
.ck-panel { display: flex; flex-direction: column; gap: 16px; }
.ck-panel__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.ck-panel__title { font-family: var(--ck-display); font-size: 24px; font-weight: 700; color: var(--ck-strong); margin: 0; }
.ck-panel__actions { display: flex; gap: 8px; flex-wrap: wrap; }
.ck-panel__grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); gap: 16px; }
.ck-card { background: var(--ck-surface); border-radius: 22px; padding: 18px; box-shadow: var(--ck-shadow); border: 1px solid rgba(236, 228, 222, .7); min-width: 0; }

/* Suggestion */
.ck-suggest { display: flex; gap: 14px; align-items: flex-start; border-radius: 20px; padding: 16px 18px; background: var(--ck-surface); box-shadow: var(--ck-shadow); border-left: 5px solid var(--ck-gold); }
.ck-suggest--now { border-left-color: var(--ck-water); background: linear-gradient(100deg, var(--ck-water-soft), var(--ck-surface) 60%); }
.ck-suggest--soon { border-left-color: #D9A441; }
.ck-suggest--wait { border-left-color: var(--ck-sage); }
.ck-suggest--dead { border-left-color: var(--ck-muted); background: var(--ck-field); box-shadow: none; }
.ck-suggest__icon { font-size: 26px; line-height: 1; }
.ck-suggest__title { font-family: var(--ck-display); font-size: 18px; font-weight: 700; color: var(--ck-strong); }
.ck-suggest__notes { margin: 6px 0 0; padding-left: 18px; color: var(--ck-text); font-size: 13px; line-height: 1.55; list-style: disc; }
.ck-suggest__weather { margin-top: 6px; }

/* Stats (ticket stubs) */
.ck-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; }
.ck-stat {
    position: relative; padding: 18px 16px 12px; border-radius: 16px;
    background:
        radial-gradient(circle at 0 50%, transparent 8px, var(--ck-surface) 8.5px) left / 51% 100% no-repeat,
        radial-gradient(circle at 100% 50%, transparent 8px, var(--ck-surface) 8.5px) right / 51% 100% no-repeat;
    filter: drop-shadow(0 8px 12px rgba(74, 20, 44, .1));
}
.ck-stat::before { content: ''; position: absolute; left: 14px; right: 14px; top: 8px; height: 3px; border-radius: 2px; background: repeating-linear-gradient(90deg, var(--ck-gold-soft) 0 6px, transparent 6px 11px); }
.ck-stat__label { font-size: 10px; font-weight: 800; letter-spacing: 1.2px; text-transform: uppercase; color: var(--ck-gold-dark); }
.ck-stat__value { font-family: var(--ck-display); font-size: 20px; font-weight: 700; color: var(--ck-brand); margin-top: 2px; }
.ck-stat__sub { font-size: 12px; color: var(--ck-muted); }

/* Month bars */
.ck-bars__row { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; align-items: end; height: 110px; }
.ck-bars__col { display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; gap: 4px; }
.ck-bars__bar { width: 100%; max-width: 30px; min-height: 3px; border-radius: 8px 8px 3px 3px; background: linear-gradient(180deg, #6FA8CC, var(--ck-water)); }
.ck-bars__val { font-size: 11px; font-weight: 800; color: var(--ck-water); min-height: 14px; }
.ck-bars__lbl { font-size: 11px; color: var(--ck-muted); font-weight: 700; }

/* Calendar */
.ck-cal__head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.ck-cal__title { font-family: var(--ck-display); font-size: 17px; font-weight: 700; color: var(--ck-strong); }
.ck-cal__nav { width: 36px; height: 36px; border-radius: 50%; border: 1px solid var(--ck-border); background: var(--ck-surface); color: var(--ck-brand); font-size: 20px; line-height: 1; cursor: pointer; }
.ck-cal__nav:disabled { opacity: .3; cursor: default; }
.ck-cal__grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; }
.ck-cal__dow { text-align: center; font-size: 11px; font-weight: 800; color: var(--ck-gold-dark); padding-bottom: 4px; }
.ck-cal__cell {
    position: relative; aspect-ratio: 1; min-height: 38px; border-radius: 12px; border: none; background: var(--ck-field);
    display: flex; flex-direction: column; align-items: center; justify-content: flex-start; padding: 4px 2px; cursor: pointer; font: inherit; color: var(--ck-text);
}
.ck-cal__cell:hover:not(:disabled) { outline: 2px solid var(--ck-gold-soft); }
.ck-cal__cell--pad { background: transparent; pointer-events: none; }
.ck-cal__cell.has-water { background: var(--ck-water-soft); }
.ck-cal__cell.is-today { box-shadow: inset 0 0 0 2px var(--ck-brand); }
.ck-cal__cell.is-future { opacity: .4; cursor: default; }
.ck-cal__num { font-size: 11px; font-weight: 700; }
.ck-cal__ev { font-size: 13px; line-height: 1.1; letter-spacing: -2px; }
.ck-cal__photo { position: absolute; top: 4px; right: 4px; width: 6px; height: 6px; border-radius: 50%; background: var(--ck-gold); }
.ck-cal__photo--inline { position: static; display: inline-block; vertical-align: middle; }
.ck-cal__legend { display: flex; flex-wrap: wrap; gap: 6px 12px; margin-top: 10px; font-size: 12px; color: var(--ck-muted); }

/* Log list */
.ck-logs { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 4px; }
.ck-log { display: flex; gap: 12px; align-items: flex-start; padding: 10px 6px; border-bottom: 1px dashed var(--ck-border); }
.ck-log:last-child { border-bottom: none; }
.ck-log__icon { width: 36px; height: 36px; flex-shrink: 0; border-radius: 12px; display: flex; align-items: center; justify-content: center; font-size: 17px; background: color-mix(in srgb, var(--ck-type) 14%, white); }
.ck-log__body { flex: 1; min-width: 0; }
.ck-log__title { font-weight: 800; color: var(--ck-strong); font-size: 14px; }
.ck-log__tags { font-weight: 600; color: var(--ck-text); }
.ck-log__meta { font-size: 12px; color: var(--ck-muted); margin-top: 2px; }
.ck-log__note { font-size: 13px; color: var(--ck-text); margin-top: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.ck-log__actions { gap: 2px; flex-shrink: 0; }
.ck-more { display: block; margin: 8px auto 0; }

/* Merged timeline */
.ck-tl { position: relative; padding-left: 26px; }
.ck-tl::before { content: ''; position: absolute; left: 15px; top: 6px; bottom: 6px; width: 2px; background: linear-gradient(var(--ck-gold-soft), var(--ck-brand-soft)); border-radius: 2px; }
.ck-tl__month { font-family: var(--ck-display); font-weight: 700; font-size: 17px; color: var(--ck-brand); margin: 18px 0 8px -26px; padding-left: 36px; }
.ck-tl__month:first-child { margin-top: 0; }
.ck-tl__item { position: relative; display: flex; gap: 12px; margin-bottom: 10px; }
.ck-tl__dot {
    position: absolute; left: -26px; top: 6px; width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
    font-size: 15px; background: color-mix(in srgb, var(--ck-type, #B8956A) 16%, white); border: 3px solid var(--ck-surface); box-shadow: 0 2px 6px rgba(74, 20, 44, .15); z-index: 1;
}
.ck-tl__item--photo .ck-tl__dot { background: var(--ck-gold-soft); }
.ck-tl__care, .ck-tl__photo { margin-left: 16px; flex: 1; min-width: 0; background: var(--ck-surface); border-radius: 16px; padding: 10px 14px; box-shadow: var(--ck-shadow); display: flex; flex-direction: column; gap: 2px; text-align: left; }
.ck-tl__photo { flex-direction: row; gap: 12px; align-items: center; border: none; font: inherit; color: inherit; cursor: zoom-in; padding: 8px; }
.ck-tl__photo img { width: 84px; height: 84px; object-fit: cover; border-radius: 12px; flex-shrink: 0; }
.ck-tl__photo-body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ck-tl__date { font-size: 12px; font-weight: 800; color: var(--ck-gold-dark); }
.ck-tl__text { font-size: 14px; color: var(--ck-text); overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.ck-tl__text b { color: var(--ck-strong); }
.ck-tl__note { font-size: 13px; color: var(--ck-muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.ck-tl__after { font-size: 11px; color: var(--ck-water); font-weight: 700; margin-top: 2px; }

/* Heatmap */
.ck-heat { overflow-x: auto; padding-bottom: 4px; }
.ck-heat__months { display: grid; gap: 3px; margin-left: 26px; font-size: 10px; color: var(--ck-muted); font-weight: 700; min-width: 280px; }
.ck-heat__body { display: flex; gap: 4px; }
.ck-heat__dows { display: grid; grid-template-rows: repeat(7, 1fr); gap: 3px; font-size: 9px; color: var(--ck-muted); width: 22px; }
.ck-heat__grid { display: flex; gap: 3px; flex: 1; min-width: 254px; }
.ck-heat__col { display: grid; grid-template-rows: repeat(7, 1fr); gap: 3px; flex: 1; }
.ck-heat__cell { display: block; aspect-ratio: 1; border-radius: 3px; background: var(--ck-field); min-width: 10px; }
.ck-heat__cell--1 { background: #CFE3EF; }
.ck-heat__cell--2 { background: #9CC4DC; }
.ck-heat__cell--3 { background: #5D9CC2; }
.ck-heat__cell--4 { background: #2F6C93; }
.ck-heat__cell--x { background: transparent; }
.ck-heat__legend { display: flex; align-items: center; justify-content: flex-end; gap: 3px; font-size: 11px; color: var(--ck-muted); margin-top: 8px; }
.ck-heat__legend .ck-heat__cell { width: 11px; min-width: 11px; }

/* Overview */
.ck-overview { display: flex; flex-direction: column; gap: 16px; }
.ck-neglect { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.ck-neglect li { display: flex; align-items: center; gap: 8px; }
.ck-neglect__open { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 10px 12px; border-radius: 14px; border: none; background: var(--ck-field); font: inherit; color: var(--ck-text); cursor: pointer; text-align: left; }
.ck-neglect__open:hover { background: var(--ck-brand-soft); }
.ck-neglect__name { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Weather */
.ck-weather__now { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; font-size: 14px; }
.ck-weather__temp { font-family: var(--ck-display); font-size: 42px; font-weight: 700; color: var(--ck-brand); line-height: 1; }
.ck-weather__days { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.ck-weather__days > div { background: var(--ck-field); border-radius: 12px; padding: 8px; display: flex; flex-direction: column; gap: 2px; font-size: 12px; text-align: center; }
.ck-weather__advice { font-size: 14px; line-height: 1.5; background: var(--ck-brand-soft); color: var(--ck-strong); border-radius: 14px; padding: 10px 12px; }

/* Form */
.ck-field { margin-bottom: 16px; }
.ck-label { display: block; font-size: 11px; font-weight: 800; letter-spacing: 1px; text-transform: uppercase; color: var(--ck-gold-dark); margin-bottom: 8px; }
.ck-input { width: 100%; box-sizing: border-box; min-height: 46px; padding: 12px 14px; border-radius: 14px; border: 1px solid transparent; background: var(--ck-field); font: inherit; font-size: 16px; color: var(--ck-strong); }
.ck-input:focus { outline: none; border-color: var(--ck-brand); background: var(--ck-surface); box-shadow: 0 0 0 4px rgba(107, 18, 56, .1); }
textarea.ck-input { resize: vertical; min-height: 80px; line-height: 1.5; }
.ck-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ck-chip { min-height: 38px; padding: 7px 14px; border-radius: 999px; border: 1px solid var(--ck-border); background: var(--ck-surface); font: inherit; font-size: 14px; font-weight: 700; color: var(--ck-text); cursor: pointer; transition: all .15s; }
.ck-chip:hover { border-color: var(--ck-gold); }
.ck-chip.is-on { background: var(--ck-brand); border-color: var(--ck-brand); color: #FFFDFA; box-shadow: 0 6px 14px -8px rgba(107, 18, 56, .8); }

/* Snackbar */
#ck-snackbar {
    position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translate(-50%, 140%);
    z-index: 4000; display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    background: var(--ck-strong); color: #FFFDFA; border-radius: 18px; padding: 8px 8px 8px 16px;
    box-shadow: 0 16px 32px -12px rgba(46, 10, 26, .6); opacity: 0; transition: transform .35s cubic-bezier(.2, .8, .2, 1), opacity .25s; max-width: calc(100vw - 32px);
}
#ck-snackbar.is-on { transform: translate(-50%, 0); opacity: 1; }
.ck-snackbar__msg { font-size: 14px; font-weight: 600; margin-right: 6px; }
.ck-snackbar__btn { min-height: 36px; padding: 6px 12px; border-radius: 999px; border: none; background: rgba(234, 220, 198, .16); color: var(--ck-gold-soft); font: inherit; font-size: 13px; font-weight: 800; cursor: pointer; }
.ck-snackbar__btn:hover { background: rgba(234, 220, 198, .3); }
@media (max-width: 600px) {
    #ck-snackbar { left: 12px; right: 84px; transform: translateY(140%); bottom: calc(20px + env(safe-area-inset-bottom, 0px)); }
    #ck-snackbar.is-on { transform: translateY(0); }
    .ck-panel__title { font-size: 20px; }
    .ck-card { padding: 14px; border-radius: 18px; }
    .ck-stat__value { font-size: 17px; }
    .ck-stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
}
