@import url("https://cdn.jsdelivr.net/gh/orioncactus/pretendard@v1.3.8/dist/web/static/pretendard-dynamic-subset.css");

:root {
  --bg-color: #f8f9fa;
  --surface-color: #ffffff;
  --primary-color: #3b82f6;
  --primary-dim: rgba(59, 130, 246, 0.1);
  --text-main: #111827;
  --text-muted: #6b7280;
  --border-color: #e5e7eb;
  --tab-height: 64px;
  --safe-area-bottom: env(safe-area-inset-bottom, 0px);
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  --font-family: "Pretendard", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

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

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-main);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  padding-bottom: calc(var(--tab-height) + var(--safe-area-bottom));
}

.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

.content-wrapper {
  flex: 1;
  padding: 20px;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
}

h1 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  letter-spacing: -0.02em;
}

p {
  font-size: 1rem;
  line-height: 1.5;
  color: var(--text-muted);
}

button, .btn {
  min-height: 44px;
  appearance: none;
  border: none;
  background: var(--primary-color);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.1s ease;
  box-shadow: var(--shadow-sm);
}

button:active, .btn:active {
  transform: scale(0.98);
}

input, textarea {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-family: inherit;
  background: var(--surface-color);
  color: var(--text-main);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px var(--primary-dim);
}

.tab-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--tab-height) + var(--safe-area-bottom));
  background-color: var(--surface-color);
  border-top: 1px solid var(--border-color);
  display: flex;
  padding-bottom: var(--safe-area-bottom);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.03);
  z-index: 50;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: var(--text-muted);
  gap: 4px;
  transition: color 0.2s ease;
}

.tab-item.active {
  color: var(--primary-color);
}

.tab-icon {
  font-size: 1.25rem;
  transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.tab-item.active .tab-icon {
  transform: translateY(-2px) scale(1.1);
}

.tab-label {
  font-size: 0.75rem;
  font-weight: 500;
}

.welcome-container {
  background: var(--surface-color);
  padding: 24px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-top: 20px;
  text-align: center;
}

@media (min-width: 600px) {
  .tab-bar {
    max-width: 600px;
    margin: 0 auto;
    border-left: 1px solid var(--border-color);
    border-right: 1px solid var(--border-color);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
}

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}
.modal-content {
  background: var(--surface-color);
  padding: 24px;
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 400px;
  box-shadow: var(--shadow-md);
}
.modal-content h2 {
  margin-bottom: 16px;
  font-size: 1.25rem;
}
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}
.secondary-button {
  background: #e5e7eb;
  color: var(--text-main);
}
.message-image {
  max-width: 100%;
  border-radius: 8px;
  margin-bottom: 8px;
  display: block;
}


/* Album Styles */
.album-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.album-header {
  margin-bottom: 8px;
}

.album-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 0;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
}

.empty-icon {
  font-size: 3rem;
}

.album-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px;
}

.album-card {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  background-color: var(--border-color);
  display: block;
}

.album-card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.album-card:hover .album-card-img {
  transform: scale(1.05);
}

.status-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  font-size: 0.7rem;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 600;
  color: white;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

.status-uploaded { background: rgba(107, 114, 128, 0.8); }
.status-translating { background: rgba(245, 158, 11, 0.8); }
.status-translated { background: rgba(16, 185, 129, 0.8); }
.status-failed { background: rgba(239, 68, 68, 0.8); }

.group-count-badge {
  position: absolute;
  bottom: 8px;
  right: 8px;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 12px;
  color: white;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(4px);
}

/* Album Detail Styles */
.album-detail-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.detail-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#detail-title {
  margin: 0;
  font-size: 1.25rem;
  flex: 1;
  text-align: center;
}

.icon-btn {
  background: none;
  box-shadow: none;
  font-size: 1.5rem;
  padding: 12px;
  color: var(--text-main);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.toggle-container {
  display: flex;
  background: #f3f4f6;
  border-radius: var(--radius-md);
  padding: 4px;
  margin-bottom: 16px;
}

.toggle-btn {
  flex: 1;
  background: transparent;
  color: var(--text-muted);
  box-shadow: none;
  font-size: 0.9rem;
  padding: 12px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.toggle-btn.active {
  background: var(--surface-color);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
}

.image-wrapper {
  position: relative;
  width: 100%;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #e5e7eb;
  min-height: 300px;
  display: flex;
  align-items: center;
  justify-content: center;
}

#detail-image {
  width: 100%;
  height: auto;
  display: block;
}

.overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: 600;
  gap: 12px;
  backdrop-filter: blur(2px);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.small-btn {
  padding: 12px 16px;
  font-size: 0.85rem;
}

.album-card-link {
  display: block;
  width: 100%;
  height: 100%;
}

.album-card {
  display: flex;
  flex-direction: column;
  position: relative;
  background-color: var(--surface-color);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  aspect-ratio: auto;
}

.album-card-link {
  aspect-ratio: 1 / 1;
  position: relative;
}

.card-controls {
  padding: 12px;
  display: flex;
  flex-direction: column;
}

.card-btn {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.8rem;
  border-radius: 6px;
  background: var(--primary-color);
  color: white;
  border: none;
  font-weight: 600;
  cursor: pointer;
}

.card-toggle-container {
  display: flex;
  background: #f3f4f6;
  border-radius: 6px;
  padding: 2px;
}

.card-toggle-btn {
  flex: 1;
  background: transparent;
  color: var(--text-muted);
  border: none;
  font-size: 0.75rem;
  padding: 4px;
  border-radius: 4px;
  font-weight: 500;
}

.card-toggle-btn.active {
  background: var(--surface-color);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
  font-weight: 700;
}

/* Carousel Styles */
.carousel-container {
  position: relative;
  width: 100%;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--border-color);
  aspect-ratio: auto; /* Reverting to default since image heights can vary, but maybe set a max-height */
}

.carousel-track {
  display: flex;
  width: 100%;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none;  /* Internet Explorer 10+ */
  scroll-behavior: smooth;
}

.carousel-track::-webkit-scrollbar {
  display: none; /* Safari and Chrome */
}

.carousel-slide {
  flex: 0 0 100%;
  width: 100%;
  scroll-snap-align: center;
  position: relative;
  display: flex;
  justify-content: center;
  align-items: center;
}

.carousel-slide img {
  max-width: 100%;
  max-height: 70vh;
  object-fit: contain;
  display: block;
}

.carousel-indicators {
  position: absolute;
  bottom: 12px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 6px;
  pointer-events: none;
}

.indicator-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.5);
  transition: background 0.2s ease, transform 0.2s ease;
  box-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.indicator-dot.active {
  background: white;
  transform: scale(1.2);
}

/* Chat Styles */
.chat-room-container, .chat-rooms-container {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.top-nav {
  display: flex;
  align-items: center;
  margin-bottom: 16px;
  gap: 12px;
}
.top-nav h1 {
  margin-bottom: 0;
}
.icon-button {
  background: transparent;
  border: none;
  box-shadow: none;
  font-size: 1.5rem;
  padding: 12px;
  color: var(--text-main);
  display: flex;
  align-items: center;
  justify-content: center;
}
.message-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 16px;
  scroll-behavior: smooth;
  min-height: 50vh;
}
.message {
  max-width: 85%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  line-height: 1.4;
  word-break: break-word;
}
.message.user {
  align-self: flex-end;
  background-color: var(--primary-color);
  color: white;
  border-bottom-right-radius: 4px;
}
.message.assistant {
  align-self: flex-start;
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-bottom-left-radius: 4px;
}
.chat-input-area {
  display: flex;
  align-items: center;
  background-color: var(--surface-color);
  padding: 12px;
  border-top: 1px solid var(--border-color);
  position: sticky;
  bottom: 0;
  margin-left: -20px;
  margin-right: -20px;
  margin-bottom: -20px;
  z-index: 10;
}
#message-input {
  flex: 1;
  min-width: 0;
  margin-right: 8px;
}
.primary-button {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-weight: 600;
  white-space: nowrap;
}
.room-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.room-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}
.room-title-text {
  font-weight: 600;
  font-size: 1.1rem;
}
.typing-indicator {
  display: flex;
  gap: 4px;
  padding: 12px 16px;
  background-color: var(--surface-color);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  align-self: flex-start;
  width: fit-content;
  border-bottom-left-radius: 4px;
}
.typing-dot {
  width: 6px;
  height: 6px;
  background-color: var(--text-muted);
  border-radius: 50%;
  animation: typing 1.4s infinite ease-in-out;
}
.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

/* Location and Map Links */
.map-link-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background-color: var(--surface-color);
  border: 1px solid var(--primary-color);
  color: var(--primary-color);
  padding: 8px 12px;
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  margin-top: 8px;
  transition: all 0.2s ease;
}
.map-link-chip:active {
  background-color: var(--primary-dim);
  transform: scale(0.98);
}
.location-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  background-color: var(--primary-dim);
  color: var(--primary-color);
  border-radius: 50%;
  text-decoration: none;
  font-size: 1.1rem;
  margin-top: 8px;
}
.message-text-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Empty States */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 20px;
  gap: 12px;
  color: var(--text-muted);
  text-align: center;
  background-color: var(--surface-color);
  border-radius: var(--radius-md);
  border: 1px dashed var(--border-color);
  margin-top: 16px;
}
