/* style.css */

@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+KR:wght@300;400;700&display=swap");

:root {
  --primary-color: #4caf50; /* 에코 그린 */
  --primary-dark-color: #388e3c;
  --secondary-color: #ffc107; /* 밝은 노랑 (포인트) */
  --background-color: #f8f8f8;
  --card-background: #ffffff;
  --text-color: #333333;
  --sub-text-color: #777777;
  --border-color: #eeeeee;
  --shadow-color: rgba(0, 0, 0, 0.05);
}

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

body {
  font-family: "Noto Sans KR", sans-serif;
  background-color: var(--background-color);
  color: var(--text-color);
  display: flex;
  justify-content: center;
  align-items: flex-start; /* 상단 정렬 */
  min-height: 100vh;
  padding-bottom: 80px; /* 하단 탭 바 높이만큼 여백 */
}

.phone-frame {
  width: 100%;
  max-width: 420px; /* 스마트폰 세로 폭 기준 */
  min-height: 100vh; /* 전체 화면 높이 */
  background-color: #fff;
  box-shadow: 0 0 20px var(--shadow-color);
  display: flex;
  flex-direction: column;
  position: relative; /* 자식 요소 fixed 기준 */
  overflow: hidden; /* 스크롤은 내부 content에서 */
}

/* --- Header --- */
.header {
  width: 100%;
  height: 60px;
  background-color: var(--primary-color);
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 15px;
  font-size: 1.3em;
  font-weight: 700;
  box-shadow: 0 2px 5px var(--shadow-color);
  z-index: 10;
  position: sticky; /* 스크롤 시 상단 고정 */
  top: 0;
}

.header a {
  color: #fff;
  text-decoration: none;
  font-size: 1.2em; /* 뒤로가기 아이콘 크기 */  
}

.header .title {
  flex-grow: 0; /* 중앙 정렬 해제 */
  text-align: left; /* 좌측 정렬 */
  margin-left: 15px; /* 서비스명과 장소 표시 사이 여백 */
}

.header .location-display {
  /* 장소 표시를 위한 새로운 클래스 */
  margin-left: auto; /* 장소 표시를 오른쪽으로 밀어냅니다. */
  display: flex;
  align-items: center;
  padding: 5px 10px;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 20px;
  min-width: 120px;
  height: 36px;
  position: relative;
}

.header .location-select {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 0.8em; /* 원하는 크기로 조절 (예: 1.05em, 1.2em 등) */
  font-weight: 700;
  outline: none;
  padding: 0 38px 0 18px; /* 좌우 패딩 넉넉하게 */
  appearance: none;
  -webkit-appearance: none;
  cursor: pointer;
  min-width: 140px; /* 클릭 영역(셀렉트박스 자체) 넓힘 */
  height: 38px; /* 높이도 약간 키움 */
}

.header .location-select::-ms-expand {
  display: none;
}

.header .location-display::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 0;
  height: 0;
  pointer-events: none;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid #fff;
  transform: translateY(-50%);
}

.header .location-select option {
  color: #222;
  background: #fff;
  min-width: 180px;
  font-size: 1em;
}

/* 헤더에 뒤로가기 버튼이 있는 경우, 서비스명과 장소 표시를 위한 조정 */
.header.with-back .title {
  margin-left: 10px; /* 뒤로가기 버튼과 서비스명 사이 여백 */
}
.header.with-back .location-display {
  margin-left: auto; /* 여전히 오른쪽으로 밀어냄 */
}

/* 홈 아이콘이 있는 경우 제목 스타일 조정 */
.header.with-home .title {
  font-size: 1.2em; /* 원하는 크기로 조절 (예: 2em) */
  font-weight: 800;
}

.header:not(.with-home) .title {
  font-size: 1em; /* 원하는 크기로 조절 (예: 1.5em) */
  font-weight: 800;
}

/* --- Content Area --- */
.content {
  flex-grow: 1;
  padding: 15px;
  overflow-y: auto; /* 내용이 길어지면 스크롤 */
  -webkit-overflow-scrolling: touch; /* 부드러운 스크롤 */
  padding-bottom: 20px; /* 하단 카드와 탭 바 사이 여백 */
}

/* --- Card Styles --- */
.card {
  background-color: var(--card-background);
  border-radius: 12px;
  padding: 20px;
  margin-bottom: 15px;
  box-shadow: 0 4px 15px var(--shadow-color);
  border: 1px solid var(--border-color);
}

.card h3,
.card h4 {
  color: var(--primary-dark-color);
  margin-bottom: 15px;
  font-weight: 700;
}

.card p {
  font-size: 0.95em;
  line-height: 1.5;
  margin-bottom: 10px;
}

.card .value {
  font-size: 1.6em;
  font-weight: 700;
  color: var(--primary-dark-color);
  margin-top: 5px;
}

.card-list {
  list-style: none;
  padding: 0;
}

.card-list li {
  display: flex;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-color);
  font-size: 1em;
}

.card-list li .icon {
  font-size: 1.2em;
  margin-right: 10px;
  color: var(--primary-color);
  flex-shrink: 0;
  width: 28px; /* 아이콘 영역 고정 */
  text-align: center;
}

.card-list li .label {
  flex-grow: 1;
  color: var(--sub-text-color);
  text-align: left;
  font-weight: 700; /* 항목명 굵게 */
  min-width: 0;
  display: block;
  padding-left: 2px; /* 아이콘과 살짝 띄움 */
}

.card-list li .amount {
  font-weight: 700; /* 수치 굵게 */
  color: var(--text-color);
  margin-left: 8px;
  text-align: right;
  min-width: 60px;
  display: block;
}

/* --- Button Styles --- */
.button-primary {
  display: block;
  width: 100%;
  padding: 15px;
  background-color: var(--primary-color);
  color: #fff;
  text-align: center;
  border: none;
  border-radius: 8px;
  font-size: 1.1em;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.3s ease;
  margin-top: 15px;
}

.button-primary:hover {
  background-color: var(--primary-dark-color);
}

.button-secondary {
  display: block;
  width: 100%;
  padding: 12px;
  background-color: var(--card-background);
  color: var(--primary-color);
  text-align: center;
  border: 1px solid var(--primary-color);
  border-radius: 8px;
  font-size: 1em;
  font-weight: 700;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 0.3s ease, color 0.3s ease;
  margin-top: 10px;
}

.button-secondary:hover {
  background-color: var(--primary-color);
  color: #fff;
}

.action-card {
  display: flex;
  align-items: center;
  padding: 15px;
  margin-bottom: 10px;
  background-color: var(--card-background);
  border-radius: 12px;
  box-shadow: 0 2px 10px var(--shadow-color);
  text-decoration: none;
  color: var(--text-color);
  transition: transform 0.2s ease;
}

.action-card:hover {
  transform: translateY(-3px);
}

.action-card .icon {
  font-size: 1.8em;
  color: var(--primary-color);
  margin-right: 15px;
  width: 30px;
  text-align: center;
}

.action-card .text h4 {
  margin: 0;
  color: var(--text-color);
  font-size: 1.1em;
}

.action-card .text p {
  margin: 3px 0 0;
  font-size: 0.85em;
  color: var(--sub-text-color);
}

.action-card .arrow {
  font-size: 1.5em;
  color: var(--sub-text-color);
  margin-left: auto;
}

/* --- Form Styles --- */
.form-group {
  margin-bottom: 15px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.95em;
  font-weight: 700;
  color: var(--sub-text-color);
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select {
  width: 100%;
  padding: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 1em;
  color: var(--text-color);
}

.form-group input[type="text"]:focus,
.form-group input[type="number"]:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.2);
}

/* --- Category/Product Selection --- */
.category-tabs {
  display: grid; /* Flexbox 대신 Grid 사용 */
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); /* 2~3열 */
  gap: 10px;
  margin-bottom: 20px;
}

.category-tab {
  padding: 10px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  text-align: center;
  cursor: pointer;
  font-size: 0.9em;
  font-weight: 500;
  color: var(--sub-text-color);
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column; /* 아이콘 위에 텍스트 */
  align-items: center;
  justify-content: center;
  min-height: 70px; /* 버튼 최소 높이 */
}

.category-tab .icon {
  /* 카테고리 탭 아이콘 */
  font-size: 1.5em;
  margin-bottom: 5px;
  color: var(--sub-text-color); /* 기본 색상 */
}

.category-tab.active .icon {
  /* 활성 탭 아이콘 색상 */
  color: #fff;
}

.category-tab:hover,
.category-tab.active {
  background-color: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
}

/* 새로운 제품 그리드 스타일 */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr); /* 2열 그리드 */
  gap: 10px; /* 버튼 사이 간격 */
  margin-top: 20px;
}

.product-grid .product-button {
  background-color: var(--card-background);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 20px 10px; /* 아이콘 제거 후 상하 패딩 조정 */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 8px var(--shadow-color);
  text-align: center;
  max-height: 50px; /* 버튼 최소 높이 유지 */
}

.product-grid .product-button:hover {
  background-color: var(--primary-color);
  color: #fff;
  border-color: var(--primary-color);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* 아이콘 삭제 - 이 부분 제거 */
/* .product-grid .product-button .icon {
    font-size: 2em;
    margin-bottom: 8px;
    color: var(--primary-color);
}

.product-grid .product-button:hover .icon {
    color: #fff;
} */

.product-grid .product-button h4 {
  margin: 0;
  font-size: 1.05em; /* 글씨 가독성 향상 */
  color: var(--text-color);
  font-weight: 500;
}

.product-grid .product-button:hover h4 {
  color: #fff;
}

.product-grid .product-button p {
  margin: 5px 0 0; /* 위쪽 여백 조정 */
  font-size: 0.85em; /* 글씨 가독성 향상 */
  color: var(--sub-text-color);
  line-height: 1.2;
}

.product-grid .product-button:hover p {
  color: rgba(255, 255, 255, 0.8);
}

.section-title {
  font-size: 1.2em;
  font-weight: 700;
  color: var(--primary-dark-color);
  margin-bottom: 15px;
  padding-top: 10px;
  border-top: 1px solid var(--border-color);
  margin-top: 20px;
}

.section-title:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

/* --- Analysis View Specific --- */
.chart-placeholder {
  width: 100%;
  height: 200px;
  background-color: #f0f0f0;
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--sub-text-color);
  font-size: 0.9em;
  margin-bottom: 20px;
  border: 1px dashed var(--border-color);
}

.tip-list {
  list-style: none;
  padding: 0;
}

.tip-list li {
  background-color: #e8f5e9; /* Light green */
  border-left: 5px solid var(--primary-color);
  padding: 10px 15px;
  margin-bottom: 10px;
  border-radius: 8px;
  font-size: 0.9em;
  line-height: 1.4;
  color: var(--text-color);
}

/* --- Location Management Specific --- */
.location-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px;
  border-bottom: 1px solid var(--border-color);
}

.location-item:last-child {
  border-bottom: none;
}

.location-item .loc-info h4 {
  margin: 0;
  font-size: 1.1em;
  color: var(--text-color);
}

.location-item .loc-info p {
  margin: 3px 0 0;
  font-size: 0.85em;
  color: var(--sub-text-color);
}

.location-item .actions {
  display: flex;
  gap: 8px;
}

.location-item .action-btn {
  padding: 8px 12px;
  border-radius: 5px;
  font-size: 0.85em;
  cursor: pointer;
  border: none;
}

.location-item .action-btn.edit {
  background-color: #03a9f4; /* Light Blue */
  color: #fff;
}

.location-item .action-btn.delete {
  background-color: #f44336; /* Red */
  color: #fff;
}

/* --- Settings Specific --- */
.settings-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px;
  border-bottom: 1px solid var(--border-color);
  text-decoration: none;
  color: var(--text-color);
  cursor: pointer; /* 클릭 가능하도록 커서 변경 */
}

.settings-item:last-child {
  border-bottom: none;
}

.settings-item .setting-info {
  flex-grow: 1;
}

.settings-item .setting-info h4 {
  margin: 0;
  font-size: 1em;
  color: var(--text-color);
}

.settings-item .setting-info p {
  margin: 3px 0 0;
  font-size: 0.8em;
  color: var(--sub-text-color);
}

.settings-item .arrow {
  font-size: 1.2em;
  color: var(--sub-text-color);
  margin-left: 10px;
}

/* --- Bottom Tab Bar --- */
.bottom-nav {
  width: 100%;
  max-width: 420px;
  height: 70px;
  background-color: var(--card-background);
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: stretch; /* stretch로 각 버튼이 nav 전체 높이 차지 */
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -2px 10px var(--shadow-color);
  z-index: 100;
  padding: 0;
}

.nav-item {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center; /* 각 버튼의 내용(아이콘/텍스트) 중앙 정렬 */
  text-decoration: none;
  color: var(--sub-text-color);
  font-size: 0.8em;
  font-weight: 500;
  padding: 5px 0;
  transition: color 0.2s ease;
  position: relative;
  min-width: 0;
  min-height: 0;
  box-sizing: border-box;
  height: 100%; /* 버튼이 nav 전체 높이 차지 */
}

.nav-item:not(:last-child)::after {
  content: "";
  position: absolute;
  top: 14px;
  right: 0;
  width: 1px;
  height: 28px;
  background: var(--border-color);
  opacity: 0.8;
}

.nav-item .icon {
  font-size: 1.5em;
  margin-bottom: 3px;
}

.nav-item.active {
  color: var(--primary-color);
  font-weight: 700;
}

/* --- Modal Styles --- */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.6);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0.3s ease;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-container {
  background-color: var(--card-background);
  padding: 25px;
  border-radius: 12px;
  width: 90%;
  max-width: 380px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  transform: translateY(20px);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  display: flex;
  flex-direction: column;
  max-height: 80vh; /* 모달 최대 높이 */
}

.modal-overlay.active .modal-container {
  transform: translateY(0);
  opacity: 1;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  margin: 0;
  font-size: 1.2em;
  color: var(--primary-dark-color);
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.8em;
  color: var(--sub-text-color);
  cursor: pointer;
  padding: 5px;
  line-height: 1; /* 아이콘 중앙 정렬 */
}

.modal-content {
  font-size: 0.95em;
  line-height: 1.6;
  color: var(--text-color);
  flex-grow: 1;
  overflow-y: auto; /* 내용이 길면 스크롤 */
  -webkit-overflow-scrolling: touch;
  padding-right: 5px; /* 스크롤바 공간 확보 */
}

.modal-content h4 {
  color: var(--primary-dark-color);
  margin-top: 15px;
  margin-bottom: 8px;
  font-size: 1.05em;
}

.modal-content ul {
  list-style: none;
  padding-left: 0;
}

.modal-content ul li {
  margin-bottom: 5px;
}

.modal-content p {
  margin-bottom: 10px;
}

.modal-content strong {
  color: var(--primary-dark-color);
}

/* FAQ 질문 스타일 */
.modal-content .faq-question {
  font-weight: 700;
  color: var(--text-color);
  margin-top: 15px;
  margin-bottom: 5px;
}

.modal-content .faq-answer {
  margin-bottom: 15px;
  padding-left: 10px;
  border-left: 3px solid var(--primary-color);
}

.modal-content table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 0.9em;
}

.modal-content th,
.modal-content td {
  border: 1px solid var(--border-color);
  padding: 8px;
  text-align: center;
}

.modal-content th {
  background-color: #f2f2f2;
  font-weight: 700;
}

.card-header-with-action {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.card-header-with-action h3 {
  margin: 0;
  font-size: 1.1em;
  font-weight: 700;
}
.analyze-btn {
  background: #4caf50;
  color: #fff;
  border: none;
  border-radius: 16px;
  padding: 4px 12px 4px 8px;
  font-size: 0.95em;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  transition: background 0.2s;
}
.analyze-btn i {
  font-size: 1em;
}
.analyze-btn:hover {
  background: #388e3c;
}
