/* ================================================
   HAB (합) — Design System
   Warm, minimal. Not corporate, not techy. Calm.
   ================================================ */

:root {
  --bg: #FAF8F5;
  --bg-elevated: #FFFFFF;
  --bg-hover: #F5F2EE;
  --text: #3D3833;
  --text-secondary: #8B8178;
  --text-tertiary: #B5AFA7;
  --accent: #8B7355;
  --accent-hover: #74604A;
  --accent-light: rgba(139, 115, 85, 0.1);
  --border: #E8E4DF;
  --border-light: #F0ECE7;
  --success: #5C8A5E;
  --warning: #C4973B;
  --error: #B85C5C;
  --radius: 6px;
  --font-body: "Pretendard Variable", "Pretendard", -apple-system, BlinkMacSystemFont, system-ui, "Segoe UI", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Fira Mono", Menlo, monospace;
  --max-width: 960px;
  --max-width-narrow: 640px;
}

/* === RESET === */

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

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

body {
  font-family: var(--font-body);
  color: var(--text);
  background: var(--bg);
  line-height: 1.8;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--text);
  text-decoration: none;
}

a:hover {
  color: var(--accent);
}

img {
  max-width: 100%;
  display: block;
}

ul, ol {
  list-style: none;
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
}

/* === TYPOGRAPHY === */

h1 {
  font-size: 1.1rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.4;
}

h2 {
  font-size: 1rem;
  font-weight: 500;
  letter-spacing: -0.01em;
  line-height: 1.4;
}

h3 {
  font-size: 0.95rem;
  font-weight: 500;
  line-height: 1.5;
}

.text-secondary {
  color: var(--text-secondary);
}

.text-small {
  font-size: 0.85rem;
}

.text-mono {
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

/* === LAYOUT === */

.container {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

.container--narrow {
  max-width: var(--max-width-narrow);
  margin: 0 auto;
  padding: 0 20px;
}

.page-header {
  padding: 32px 0 24px;
}

.page-header h1 {
  margin-bottom: 6px;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

main {
  padding-bottom: 80px;
}

.section {
  margin-top: 40px;
}

/* === NAVIGATION === */

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  max-width: var(--max-width-narrow);
  margin: 0 auto;
}

.nav-logo {
  font-size: 1rem;
  font-weight: 400;
}

.nav-links {
  display: flex;
  gap: 20px;
}

.nav-links a {
  font-size: 0.88rem;
  color: var(--text-secondary);
  transition: color 0.15s;
}

.nav-links a:hover,
.nav-links a.active {
  color: var(--text);
}

.nav--wide {
  max-width: var(--max-width);
}

/* === BUTTONS === */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text);
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--text-tertiary);
}

.btn--primary {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.btn--primary:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
  color: #fff;
}

.btn--danger {
  color: var(--error);
  border-color: var(--error);
}

.btn--danger:hover {
  background: var(--error);
  color: #fff;
}

.btn--small {
  padding: 6px 12px;
  font-size: 0.82rem;
}

.btn--ghost {
  border: none;
  background: none;
  color: var(--text-secondary);
  padding: 6px 10px;
}

.btn--ghost:hover {
  color: var(--text);
  background: var(--bg-hover);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* === FORMS === */

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--text);
}

.form-group label .required {
  color: var(--accent);
  margin-left: 2px;
}

.form-group .hint {
  font-size: 0.8rem;
  color: var(--text-tertiary);
  margin-top: 4px;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="url"],
input[type="number"],
input[type="password"],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.95rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  transition: border-color 0.15s;
  outline: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}

textarea {
  resize: vertical;
  min-height: 100px;
}

input::placeholder,
textarea::placeholder {
  color: var(--text-tertiary);
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%238B8178' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}

.checkbox-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.checkbox-group input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* === TABS === */

.tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab {
  padding: 10px 20px;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
}

.tab:hover {
  color: var(--text);
}

.tab.active {
  color: var(--text);
  border-bottom-color: var(--accent);
}

/* === CALENDAR === */

.calendar {
  user-select: none;
}

.calendar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.calendar-header h2 {
  font-family: var(--font-mono);
  font-size: 1rem;
  font-weight: 500;
}

.calendar-nav {
  display: flex;
  gap: 4px;
}

.calendar-nav button {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  cursor: pointer;
  font-size: 1rem;
  color: var(--text-secondary);
  transition: all 0.15s;
}

.calendar-nav button:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.calendar-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  margin-bottom: 4px;
}

.calendar-weekdays span {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-tertiary);
  padding: 8px 0;
  text-transform: uppercase;
}

.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 2px;
}

.calendar-day {
  position: relative;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  cursor: default;
  transition: all 0.15s;
  padding: 4px;
}

.calendar-day.empty {
  visibility: hidden;
}

.calendar-day.other-month {
  color: var(--text-tertiary);
  opacity: 0.4;
}

.calendar-day.today {
  font-weight: 700;
}

.calendar-day.today::after {
  content: '';
  position: absolute;
  bottom: 4px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--text);
}

/* Available */
.calendar-day.available {
  cursor: pointer;
}

.calendar-day.available:hover {
  background: var(--accent-light);
  color: var(--accent);
}

/* Selected (in date picker) */
.calendar-day.selected {
  background: var(--accent);
  color: #fff;
}

.calendar-day.selected::after {
  display: none;
}

/* Pending */
.calendar-day.pending {
  color: var(--text-tertiary);
  background: var(--bg-hover);
}

.calendar-day .day-label {
  font-size: 0.65rem;
  color: var(--text-tertiary);
  line-height: 1;
  margin-top: 2px;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: var(--font-body);
}

/* Booked */
.calendar-day.booked {
  color: var(--text);
}

.calendar-day.booked::before {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--accent);
}

/* Blocked */
.calendar-day.blocked {
  color: var(--text-tertiary);
  text-decoration: line-through;
}

/* Calendar tooltip */
.calendar-day .tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  font-size: 0.75rem;
  font-family: var(--font-body);
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  z-index: 10;
  pointer-events: none;
}

.calendar-day:hover .tooltip {
  display: block;
}

/* === TABLE === */

.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  color: var(--text-tertiary);
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

tbody td {
  padding: 12px;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.9rem;
  vertical-align: middle;
}

tbody tr {
  transition: background 0.1s;
}

tbody tr:hover {
  background: var(--bg-hover);
}

tbody tr.clickable {
  cursor: pointer;
}

/* === STATUS BADGES === */

.badge {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 12px;
  white-space: nowrap;
}

.badge--submitted {
  background: #EDE9E4;
  color: var(--text-secondary);
}

.badge--talking {
  background: #FFF3E0;
  color: #B8860B;
}

.badge--confirmed {
  background: #E8F5E9;
  color: #2E7D32;
}

.badge--paid {
  background: #E3F2FD;
  color: #1565C0;
}

.badge--used {
  background: #F3E5F5;
  color: #7B1FA2;
}

.badge--archived {
  background: var(--accent-light);
  color: var(--accent);
}

.badge--rejected {
  background: #FFEBEE;
  color: var(--error);
}

/* === MESSAGES / EMAIL THREAD === */

.messages {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  max-height: none;
  overflow-y: visible;
}

.message {
  padding: 16px 0;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.88rem;
  line-height: 1.8;
}

.message:last-child {
  border-bottom: none;
}

.message-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 8px;
  font-size: 0.78rem;
}

.message-sender {
  font-weight: 500;
  color: var(--text);
}

.message--inbound .message-sender {
  color: var(--accent);
}

.message-time {
  color: var(--text-tertiary);
}

.message-body {
  white-space: pre-wrap;
  color: var(--text);
}

.message--outbound {
  border-left: 2px solid var(--border);
  padding-left: 16px;
}

.message--inbound {
  border-left: 2px solid var(--accent);
  padding-left: 16px;
}

.message--system {
  padding: 8px 0;
  font-size: 0.78rem;
  color: var(--text-tertiary);
  text-align: center;
  border-left: none;
  border-bottom: none;
}

.compose {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px 0;
  border-top: 1px solid var(--border-light);
}

.compose textarea {
  min-height: 140px;
  resize: vertical;
}

.compose-actions {
  display: flex;
  justify-content: flex-end;
}

/* === CARDS (Archive) === */

.archive-grid {
  display: grid;
  gap: 24px;
}

.archive-year {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-tertiary);
  padding: 12px 0;
  position: sticky;
  top: 0;
  background: var(--bg);
  z-index: 5;
  border-bottom: 1px solid var(--border-light);
}

.archive-card {
  display: block;
  transition: transform 0.15s;
}

.archive-card:hover {
  transform: translateY(-2px);
}

.archive-card img {
  width: 100%;
  aspect-ratio: 16/10;
  object-fit: cover;
  border-radius: var(--radius);
}

.archive-card--text {
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 20px;
}

.archive-card-meta {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-tertiary);
  margin-top: 10px;
}

.archive-card-title {
  font-weight: 500;
  margin-top: 4px;
}

.archive-card-excerpt {
  font-size: 0.88rem;
  color: var(--text-secondary);
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Archive detail */
.archive-hero {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-radius: var(--radius);
  margin-bottom: 24px;
}

.archive-photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin-top: 24px;
}

.archive-photos img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: var(--radius);
}

/* === COMMENTS === */

.comments {
  margin-top: 40px;
  border-top: 1px solid var(--border);
  padding-top: 24px;
}

.comment {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}

.comment:last-child {
  border-bottom: none;
}

.comment-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.comment-name {
  font-weight: 500;
  font-size: 0.88rem;
}

.comment-time {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-tertiary);
}

.comment-body {
  font-size: 0.9rem;
  line-height: 1.6;
}

/* === ADMIN LAYOUT === */

.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.ticket-detail {
  display: grid;
  grid-template-columns: 1fr;
  gap: 32px;
}

.ticket-info {
  background: var(--bg-elevated);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 24px;
}

.ticket-field {
  padding: 10px 0;
  border-bottom: 1px solid var(--border-light);
  display: grid;
  grid-template-columns: 100px 1fr;
  gap: 12px;
  font-size: 0.9rem;
}

.ticket-field:last-child {
  border-bottom: none;
}

.ticket-field dt {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text-secondary);
  padding-top: 2px;
}

.ticket-field dd {
  line-height: 1.6;
}

.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 16px 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin: 16px 0;
}

.action-bar select {
  width: auto;
  min-width: 160px;
}

/* === SEARCH === */

.search-bar {
  position: relative;
  margin-bottom: 24px;
}

.search-bar input {
  padding-left: 36px;
}

.search-bar::before {
  content: '⌕';
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-tertiary);
  font-size: 1rem;
}

/* === FILTER TABS === */

.filter-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.filter-tab {
  padding: 6px 14px;
  font-size: 0.82rem;
  font-weight: 500;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s;
}

.filter-tab:hover {
  border-color: var(--text-tertiary);
  color: var(--text);
}

.filter-tab.active {
  background: var(--text);
  color: var(--bg);
  border-color: var(--text);
}

/* === DATE PICKER (for apply form) === */

.date-picker-selected {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.date-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  padding: 4px 10px;
  background: var(--accent-light);
  color: var(--accent);
  border-radius: 4px;
}

.date-tag button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--accent);
  font-size: 1rem;
  line-height: 1;
  padding: 0;
}

/* Time selectors per date */
.date-times {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.date-time-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.88rem;
}

.date-time-row .date-label {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-secondary);
  min-width: 90px;
}

.date-time-row select {
  width: auto;
  min-width: 100px;
}

/* === PRICING === */

.pricing {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin: 20px 0;
}

.pricing-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
}

.pricing-card h3 {
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.pricing-card .price {
  font-family: var(--font-mono);
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--accent);
}

.pricing-card .note {
  font-size: 0.78rem;
  color: var(--text-tertiary);
  margin-top: 2px;
}

/* === LOADING & EMPTY STATES === */

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-tertiary);
  font-size: 0.9rem;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-tertiary);
}

.empty-state p {
  margin-top: 8px;
  font-size: 0.9rem;
}

/* === SUCCESS MESSAGE === */

.success-message {
  text-align: center;
  padding: 80px 20px;
}

.success-message h2 {
  margin-bottom: 12px;
}

.success-message p {
  color: var(--text-secondary);
}

/* === TOAST === */

.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: var(--text);
  color: var(--bg);
  font-size: 0.88rem;
  border-radius: var(--radius);
  z-index: 1000;
  opacity: 0;
  transform: translateY(12px);
  transition: all 0.3s;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* === UTILITIES === */

.hidden {
  display: none !important;
}

.mt-4 { margin-top: 16px; }
.mt-8 { margin-top: 32px; }
.mb-4 { margin-bottom: 16px; }
.mb-8 { margin-bottom: 32px; }
.text-center { text-align: center; }

/* === RESPONSIVE === */

@media (min-width: 768px) {
  .nav {
    padding: 20px;
  }

  .calendar-day {
    aspect-ratio: auto;
    min-height: 72px;
    align-items: flex-start;
    justify-content: flex-start;
    padding: 8px;
  }

  .ticket-detail {
    grid-template-columns: 1fr 1fr;
  }

  .archive-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .archive-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 640px) {
  .form-row {
    grid-template-columns: 1fr;
  }

  .ticket-field {
    grid-template-columns: 1fr;
    gap: 2px;
  }

  .action-bar {
    flex-direction: column;
  }

  .action-bar select,
  .action-bar .btn {
    width: 100%;
  }

  .pricing {
    grid-template-columns: 1fr;
  }

  .nav-links {
    gap: 16px;
  }

  .nav-links a {
    font-size: 0.85rem;
  }
}
