/* ======================
   기록 리스트 스타일
   ====================== */
/* CareDiary: food-record-item을 result-row 카드 스타일로 */
.food-record-item{
  display:flex; flex-direction:column; gap:10px;
  padding:12px 14px;
  background:#fff;
  border:none !important;                 /* ← 보더 완전 제거 */
  border-radius:14px;
  box-shadow:0 1px 3px rgba(0,0,0,.05);   /* 라이트 섀도우 */
  cursor:pointer;
  transition:transform .12s ease, box-shadow .12s ease, background .12s ease;
  margin-bottom:10px;
  -webkit-appearance:none; appearance:none;
  text-align:left;
}

.food-record-item:hover{
  box-shadow:0 2px 8px rgba(0,0,0,.06);
}

.food-record-item:focus-visible{
  outline:none;
  box-shadow:0 0 0 3px rgba(64,108,180,.18);
}

/* 내부 한 줄 구조 */
.food-record-item .record-main {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

/* 제품명 (result-row .title 스타일로) */
.food-record-item .record-food {
  flex: 1 1 auto;
  font-size: 14px;
  font-weight: 400;
  color: #000;
  line-height: 1.35;
  word-break: break-all;
}

/* 시간, 단위 등은 메타톤으로 */
.food-record-item .record-time,
.food-record-item .record-unit {
  font-size: 13px;
  color: #6b7280;
}

/* CareDiary: food-record-item용 썸네일 (nutrition_search .results-list .thumb 복제) */
.food-record-item .thumb{
  width:68px; height:68px; flex:0 0 auto;
  border-radius:10px; overflow:hidden; background:#f3f4f6;
  display:grid; place-items:center;
  margin-right:6px; /* 레이블과 간격 */
}
.food-record-item .thumb img{
  width:100%; height:100%; object-fit:cover; display:block;
}




/* 케어다이어리 카테고리 배지를 nutrition_search 칩 스타일과 동일하게 */
.record-cat-large,
.record-cat-small {
  display: inline-flex;
  align-items: center;
  justify-content: center;

  font-size: 11px;
  padding: 2px 8px;
  border-radius: 9999px;

  background: #f5f7fb;
  color: #3b4b83;
  border: 1px solid #e6eaf6;

  white-space: nowrap;

  /* 2) 섭취 버튼과 같은 폰트사이즈 및 패딩 */
  font-size: 12px;          /* record-label과 동일 */
  padding: 4px 9px 2px 9px; /* record-label과 동일 */

  /* 3) 기존 색상, 모서리 그대로 */
  border-radius: 999px;
  white-space: nowrap;
  
}


.record-main button.record-amount-save {
  width: 50px;
  height: 32px;
  min-width: 50px;
  min-height: 32px;
  box-sizing: border-box;
  font-size: 13px;
  padding: 0;
  border-radius: 9px;
  border: none;
  background: #1976d2;
  color: #fff;
  cursor: pointer;
  display: inline-block;
  text-align: center;
  margin-top: 0;
}

.delete-record-btn {
  color: #c00;
  font-size: 20px;
  cursor: pointer;
  font-weight: bold;
  z-index: 2;
  /* 아래처럼 추가하면 더 예쁨 */
  background: none;
  border: none;
  padding: 0;
  line-height: 1;
}
.delete-record-btn:hover { color: #900; }

.drug-record-item {
  padding: 10px 10px;
  border-radius: 11px;
  border-bottom: 1px solid #f1f1f1;
  margin-bottom: 6px;
  background: #fafbfc;
  display: flex;
  align-items: center;
  transition: background 0.18s;
  cursor: pointer;
}
.drug-record-item:hover,
.drug-record-item:active {
  background: #f0f6ff;
}


.label-eat { /* 음식용, 필요시 구분 */
  background: #31753d; color: #e6f7e6;
}
.label-given, .label-drug { /* 약 구분은 별도 컬러로 해도 됨 */
  background: #fff2e1; color: #a96800;
}

/* 시간, 약명, 용량 */
.record-time {
  color: #888;
  font-size: 13px;
  min-width: 50px;
  max-width: 50px;
  text-align: center;
  flex-shrink: 0;
  padding-top: 5px;
}
.record-drugname {
  color: #222;
  font-weight: bold;
  font-size: 14px;
  min-width: 80px;
  flex: 1 1 auto;
  word-break: break-all;
}
.record-dose {
  color: #406CB4;
  font-size: 14px;
  margin-left: 8px;
  min-width: 40px;
}

.label-given {
  background: #fff2e1; color: #a96800;
}

.drug-amount-input {
  width: 100px !important;
}

/* ======================
   드럭 드로워 컨테이너
   ====================== */
#drawerDim .drawer {
  position: absolute;
  top: 0;
  right: 0;
  width: 360px;
  max-width: calc(100vw - 60px); /* 모바일에서도 여백 확보 */
  height: 100vh;
  background: #fff;
  box-shadow: -4px 0 12px rgba(0,0,0,0.08);
  transform: translateX(100%);
  transition: transform .3s ease;
  overflow-y: auto;
}
#drawerDim .drawer.open {
  transform: translateX(0);
}

/* 닫기 버튼 (optional) */
#drugCloseBtn {
  position: absolute;
  top: 12px;
  right: 16px;
  font-size: 24px;
  background: none;
  border: none;
  cursor: pointer;
  color: #666;
}
#drugCloseBtn:hover {
  color: #333;
}

/* ======================
   기록 리스트 스타일
   (푸드 쪽과 유사하게)
   ====================== */
.drug-record-item {
  padding: 10px;
  border-radius: 11px;
  border-bottom: 1px solid #f1f1f1;
  margin-bottom: 6px;
  background: #fafbfc;
  display: flex;
  align-items: center;
  transition: background .18s;
  cursor: pointer;
}
.drug-record-item:hover {
  background: #f0f6ff;
}

.record-time {
  color: #888;
  font-size: 12px;
  min-width: 50px;
  text-align: center;
  flex-shrink: 0;
}

.record-drugname {
  color: #222;
  font-weight: bold;
  font-size: 14px;
  flex: 1;
  word-break: break-all;
}

.record-dose {
  color: #406CB4;
  font-size: 14px;
  margin-left: 8px;
  min-width: 40px;
  text-align: right;
}


.label-drug {
  background: #a96800;
  color: #fff2e1;
}
.label-given {
  background: #dd1390;
  color: #fff2e1;
}

.label-status-weight   { background: #3498db; } /* 몸무게 – 파랑 */
.label-status-vomit    { background: #e74c3c; } /* 구토 – 빨강 */
.label-status-urine    { background: #1abc9c; } /* 소변 – 청록 */
.label-status-stool    { background: #f39c12; } /* 대변 – 주황 */
.label-status-water    { background: #2980b9; } /* 음수량 – 짙은 파랑 */
.label-status-fluid    { background: #8e44ad; } /* 피하수액 – 보라 */
.label-status-memo     { background: #7f8c8d; } /* 메모 – 회색 */
.label-status-resp { background: #3a25b1; } /* 메모 – 호흡수 */

/* 공통 스타일 */
.record-label {
  color: #fff;
  padding: 4px 9px 2px 9px; 
  border-radius: 20px;
  font-size: 12px;
  font-weight: normal;
  display: grid;
  place-items: center;
}

/* 최근 약 버튼 전용 */
#recentDrugList .recent-drug-btn {
  flex: 0 0 auto;           /* flexbox 축소·확장 금지 */
  padding: 2px 6px;         /* 적당한 패딩 */
  font-size: .75rem !important;  /* 강제 폰트 크기 */
  width: auto !important;        /* 강제 auto 너비 */
  max-width: none;           /* 혹시 max-width가 걸려 있다면 해제 */
  white-space: nowrap;
  border: 1px solid #ccc;
  border-radius: 12px;
  background: #f9f9f9;
  color: #333;
}

/* hover 상태 */
#recentDrugList .recent-drug-btn:hover {
  background: #e0e0e0;
}


.results-list{display:flex;flex-direction:column;gap:10px;margin:8px 0 12px;}
.result-row{display:flex;align-items:center;gap:12px;border:1px solid #e5e7eb;border-radius:12px;padding:10px 12px;background:#fff;cursor:pointer}
.result-row:hover{box-shadow:0 2px 8px rgba(0,0,0,.06)}
.result-row .thumb{width:56px;height:56px;border-radius:8px;overflow:hidden;background:#f3f4f6;flex:0 0 56px}
.result-row .thumb img{width:100%;height:100%;object-fit:cover}
.result-row .body{flex:1;min-width:0}
.result-row .title{text-align:left;font-size:14px;line-height:1.35;color: #000}
.result-row .meta{margin-top:4px;display:flex;gap:6px;flex-wrap:wrap}
.result-row .chip{font-size:11px;padding:2px 8px;border-radius:9999px;background:#f1f5f9;color:#475569}


  /* 오버레이 툴바 버튼들만 전역 규칙을 무시하게 */
  #searchOverlay .toolbar button {
    width: auto !important;
    display: inline-flex !important;
    background: transparent;
    color: #ddd;
    border: 0;
    padding: 8px;
    margin: 0;
    line-height: 1;
    align-items: center;
    justify-content: center;
  }
  #searchOverlay .toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    border-bottom: 1px solid #ddd;
  }
  #searchOverlay .search-pill {
    flex: 1; display:flex; align-items:center; gap:8px;
    background:#3a3a3a; border-radius:9999px; padding:8px 12px;
  }
  #searchOverlay #cds-q {
    flex:1; border:none; outline:none; background:transparent; color:#fff; font-size:16px;
  }

/* === 오버레이 공통 === */
#searchOverlay { /* 백드롭은 JS로 display 토글함 */ }
#searchOverlay .overlay-panel {
  width: 100%;
  max-width: 480px;
  min-height: 100%;
  background: #fff;
  display: flex;
  flex-direction: column;
}

/* 전역 button 규칙 무력화 (겹침 방지) */
#searchOverlay button { width: auto !important; display: inline-flex !important; }

/* === 상단 툴바 === */
#searchOverlay .toolbar{
  display:flex; align-items:center; gap:8px;
  padding:10px 12px; border-bottom:1px solid #e9e9e9;
  background:#fff; position:sticky; top:0; z-index:1;
}
#searchOverlay .toolbar button{
  border:0; background:transparent; padding:8px; margin:0;
  line-height:1; cursor:pointer; color:#666;
}
#searchOverlay .toolbar button:hover{ color:#222; }

/* 둥근 검색 필 */
#searchOverlay .search-pill{
  flex:1; display:flex; align-items:center; gap:10px;
  background:#2f2f2f; border-radius:9999px; padding:10px 14px;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.08);
}
#searchOverlay #cds-q{
  flex:1; border:none; outline:none; background:transparent;
  color:#fff; font-size:16px;
  height: auto !important;
  margin-bottom: 0 !important;
}
#searchOverlay #cds-q::placeholder{ color:#cfcfcf; }

/* 상태/요약/결과 */
#searchOverlay #cds-status{ color:#6b7280; font-size:13px; padding:8px 14px 0; }
#searchOverlay #cds-summary{ padding:6px 14px 8px; font-size:13px; color:#374151; }
#searchOverlay #cds-results{ padding: 12px 12px 20px; background:#fafafa; }

/* 결과 카드 레이아웃(원하면 사용) */
#searchOverlay .results-list{ display:flex; flex-direction:column; gap:10px; }
#searchOverlay .result-row{
  background:#fff; border:1px solid #eee; border-radius:12px;
  padding:12px; box-shadow:0 1px 2px rgba(0,0,0,0.04);
  display:grid; grid-template-columns: auto 1fr; column-gap:10px; row-gap:4px; align-items:center;
}
#searchOverlay .result-icon{ width:32px; height:32px; border-radius:8px; display:flex; align-items:center; justify-content:center; font-size:14px; color:#fff;}
#searchOverlay .result-icon.food{background:#10b981}
#searchOverlay .result-icon.drug{background:#406CB4}
#searchOverlay .result-icon.status{background:#f59e0b}
#searchOverlay .title{ font-weight:700; font-size:14px; color:#111827; line-height:1.35; }
#searchOverlay .meta{ grid-column:2/3; font-size:12px; color:#6b7280; }
#searchOverlay .note{ grid-column:2/3; font-size:13px; color:#374151; margin-top:2px; }
#searchOverlay .badge{ display:inline-block; font-size:11px; padding:2px 6px; border-radius:999px; margin-left:6px; vertical-align:1px; }
#searchOverlay .badge.food{ background:#e7f8f1; color:#107a58; }
#searchOverlay .badge.drug{ background:#e8f0ff; color:#274b94; }
#searchOverlay .badge.status{ background:#fff3e0; color:#9a6200; }
#searchOverlay mark{ background:#ffec99; color:#111; padding:0 2px; border-radius:3px; }

#searchOverlay #cds-load-more{
  margin:12px auto 0; padding:10px 16px; border:1px solid #e5e7eb;
  background:#fff; border-radius:8px; cursor:pointer; color:#374151;
}
#searchOverlay #cds-load-more:hover{ background:#f9fafb; }

/* 패널 높이를 뷰포트 기준으로 고정 */
#searchOverlay .overlay-panel{
  height: 100dvh;            /* or 100vh */
  display: flex;
  flex-direction: column;
}

/* 결과 영역을 진짜 스크롤 컨테이너로 만들기 */
#searchOverlay #cds-results{
  flex: 1;
  min-height: 0;             /* ★ flex 버그 해결 포인트 */
  overflow-y: auto;
  -webkit-overflow-scrolling: touch; /* iOS 부드러운 스크롤 */
}

.icon-btn { background: none !important; border: none !important; padding: 6px; cursor: pointer; line-height: 1; }
.icon-btn i { font-size: 20px; color: #444; display: inline-block; }
.icon-btn:hover i { color: #000; }

/* === Pet 버튼 레이아웃 고정 === */
#petButtons {
  display: grid;
  grid-template-columns: 1fr;    /* 기본 1열(전체 너비) */
  gap: 8px;
}

/* 2마리 이상일 때 2열로 쓰고 싶으면 주석 해제
@media (min-width: 380px) {
  #petButtons { grid-template-columns: 1fr 1fr; }
}
*/

#petButtons label { width: 100%; }
#petButtons input[name="selectedPet"] { display: none; }

/* 라벨/버튼 둘 다 폭 100%로 */
#petButtons label .outline,
#petButtons button.outline {
  display: block;
  width: 100%;
  text-align: center;
  padding: 12px 14px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  background: #fff;
  color: #111;
  line-height: 1.2;
}

/* 선택 상태(둘 다 지원: 라디오 checked, 클래스 selected) */
#petButtons input[name="selectedPet"]:checked + .outline,
#petButtons .outline.selected,
#petButtons button.outline.selected {
  background: #406CB4;
  color: #fff;
  border-color: #406CB4;
}

/* ─── 펫 탭 바 ───────────────────────────────── */
#petButtons {
  display: grid;
  grid-auto-columns: 1fr;
  gap: 10px;
  border-bottom: 1px solid #eee;
  padding: 0 4px 6px;
}

/* 펫 수(최대3)에 따라 1~3열 자동 */
#petButtons:has(label:nth-child(1)):not(:has(label:nth-child(2))) { grid-template-columns: 1fr; }
#petButtons:has(label:nth-child(2)):not(:has(label:nth-child(3))) { grid-template-columns: 1fr 1fr; }
#petButtons:has(label:nth-child(3))                               { grid-template-columns: 1fr 1fr 1fr; }

#petButtons label {
  display: block;
  width: 100%;
}

#petButtons input[name="selectedPet"] { display: none; }

/* 기본 탭 모양 (참고 이미지 느낌) */
#petButtons .pet-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 40px;                 /* 탭 높이 */
  font-size: 15px;
  color: #94a3b8;               /* slate-400 */
  position: relative;
  border-radius: 10px;          /* 살짝 둥글게 */
}

/* 활성 상태: 텍스트 색 강조 + 하단 인디케이터 */
#petButtons .pet-tab.active,
#petButtons input[name="selectedPet"]:checked + .pet-tab {
  color: #0ea5a8;               /* 청록계열(참고 이미지 톤) */
  font-weight: 700;
}

#petButtons .pet-tab.active::after,
#petButtons input[name="selectedPet"]:checked + .pet-tab::after {
  content: "";
  position: absolute;
  left: 16%;
  right: 16%;
  bottom: -6px;
  height: 3px;
  border-radius: 3px;
  background: #0ea5a8;
}

/* 탭 전체 줄의 여백 보정 */
#petButtons + * {
  margin-top: 12px;
}

/* 라디오는 시각적으로만 숨기고, 라벨 클릭은 정상 동작하게 */
#petButtons input[name="selectedPet"]{
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
  pointer-events: none;
}

/* 라벨 자체는 클릭 타겟이 되게 */
#petButtons label{
  position: relative;
  display: block;
  cursor: pointer;
}

/* 기존 */
#searchOverlay .badge.food { background:#e7f8f1; color:#107a58; }
/* 추가 */
#cds-overlay .badge.food   { background:#e7f8f1; color:#107a58; }

#searchOverlay .badge, #cds-overlay .badge {
  display:inline-block; font-size:13px; padding:2px 6px; border-radius:999px;
  margin-left:6px; vertical-align:1px;
}

/* CareDiary: 칼로리 게이지바 (index의 dash-progress 스타일 복제) */
.cdi-progress{
  width:100%;
  height:10px;
  background:#f3f4f6;        /* index: .dash-progress 배경색 */
  border-radius:999px;
  overflow:hidden;
}
.cdi-progress .bar{
  height:100%;
  width:0;                   /* JS가 width %로 채움 */
  background:linear-gradient(90deg, #60a5fa, #34d399); /* index와 동일 그라데이션 */
}
