/* Reset & Color Tokens */
:root {
  /* 60% Dominant Background */
  --bg-main: rgb(139, 165, 181);
  --bg-card: rgba(0, 0, 0, 0.1);
  --bg-card-hover: rgba(0, 0, 0, 0.16);
  --bg-panel: rgba(0, 0, 0, 0.14);
  
  /* 30% Accent & Highlights */
  --accent: rgb(177, 205, 187);
  --accent-hover: rgb(197, 225, 207);
  --accent-alpha: rgba(177, 205, 187, 0.25);
  
  /* 10% Text & Details */
  --text-main: rgb(244, 238, 227);
  --text-muted: rgba(244, 238, 227, 0.82);
  --text-dark: #22343f;
  
  --font-family: Cambria, Georgia, serif;
  --border-radius: 6px;
  --max-width: 960px;
}

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

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-family);
  line-height: 1.6;
  font-size: 1.05rem;
}

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

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

h1, h2, h3, h4 {
  color: var(--text-main);
  font-weight: bold;
}

p {
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* Header & Nav */
header {
  border-bottom: 1px solid var(--accent-alpha);
  padding: 1.25rem 1.5rem;
  background-color: rgba(139, 165, 181, 0.95);
}

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

.brand {
  font-size: 1.4rem;
  font-weight: bold;
  color: var(--text-main);
}

.brand span {
  color: var(--accent);
}

.nav-actions {
  display: flex;
  gap: 1rem;
  align-items: center;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 1.3rem;
  border-radius: var(--border-radius);
  font-family: var(--font-family);
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  border: 1px solid var(--accent);
  transition: all 0.2s ease;
}

.btn-primary {
  background-color: var(--accent);
  color: var(--text-dark);
}

.btn-primary:hover {
  background-color: var(--accent-hover);
  color: var(--text-dark);
}

.btn-outline {
  background-color: transparent;
  color: var(--text-main);
}

.btn-outline:hover {
  background-color: var(--accent-alpha);
}

/* Landing Page Hero */
.hero-section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 4.5rem 1.5rem 3.5rem;
  text-align: center;
}

.hero-title {
  font-size: 2.8rem;
  margin-bottom: 1.2rem;
  line-height: 1.25;
}

.hero-lead {
  font-size: 1.25rem;
  max-width: 680px;
  margin: 0 auto 2.5rem;
  color: var(--text-muted);
}

.hero-buttons {
  display: flex;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 3rem;
}

/* Features Grid */
.features-section {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 3rem 1.5rem 5rem;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.5rem;
}

.feature-card {
  background-color: var(--bg-card);
  border: 1px solid var(--accent-alpha);
  border-radius: var(--border-radius);
  padding: 1.8rem;
}

.feature-card h3 {
  font-size: 1.25rem;
  color: var(--accent);
  margin-bottom: 0.6rem;
}

.feature-card p {
  font-size: 0.95rem;
  margin-bottom: 0;
}

/* Onboarding Screen ("Aloitetaan!") */
.onboarding-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: calc(100vh - 65px);
  text-align: center;
  padding: 2rem;
  background-color: rgba(0, 0, 0, 0.08);
}

.onboarding-screen h1 {
  font-size: 3rem;
  color: var(--accent);
  margin-bottom: 1rem;
}

.onboarding-screen p {
  font-size: 1.25rem;
  max-width: 540px;
  margin-bottom: 2rem;
  color: var(--text-main);
}

/* Workspace (/sivustoni) Split-Screen Layout */
.workspace-container {
  display: grid;
  grid-template-columns: 380px 1fr;
  height: calc(100vh - 65px);
  overflow: hidden;
}

.chat-panel {
  background-color: var(--bg-panel);
  border-right: 1px solid var(--accent-alpha);
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
  min-height: 0;
}

.chat-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--accent-alpha);
  flex-shrink: 0;
}

.chat-header h2 {
  font-size: 1.2rem;
}

.chat-messages {
  flex: 1;
  padding: 1.25rem;
  overflow-y: auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.message {
  max-width: 90%;
  padding: 0.8rem 1rem;
  border-radius: 6px;
  font-size: 0.95rem;
  line-height: 1.45;
}

.message.user {
  background-color: var(--accent);
  color: var(--text-dark);
  align-self: flex-end;
}

.message.ai {
  background-color: rgba(244, 238, 227, 0.12);
  color: var(--text-main);
  border: 1px solid var(--accent-alpha);
  align-self: flex-start;
}

.function-badge {
  display: inline-block;
  background-color: var(--accent-alpha);
  border: 1px solid var(--accent);
  color: var(--text-main);
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-size: 0.8rem;
  margin-top: 0.4rem;
  font-family: monospace;
}

.chat-input-area {
  padding: 0.85rem 1rem;
  border-top: 1px solid var(--accent-alpha);
  background-color: rgba(0, 0, 0, 0.12);
  flex-shrink: 0;
}

.chat-form {
  display: flex;
  width: 100%;
}

/* ChatGPT Style Unified Input Box with Left Attachment Clip */
.chat-input-wrapper {
  display: flex;
  align-items: center;
  background: rgba(34, 52, 63, 0.85);
  border: 1px solid var(--accent-alpha, rgba(177, 205, 187, 0.3));
  border-radius: 24px;
  padding: 0.2rem 0.4rem 0.2rem 0.6rem;
  width: 100%;
  box-sizing: border-box;
  gap: 0.4rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-input-wrapper:focus-within {
  border-color: var(--accent, #b1cdbb);
  box-shadow: 0 0 12px rgba(177, 205, 187, 0.25);
}

.chat-attach-btn {
  background: transparent;
  border: none;
  color: var(--accent, #b1cdbb);
  cursor: pointer;
  padding: 0.45rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.chat-attach-btn:hover {
  background: rgba(177, 205, 187, 0.18);
  color: #ffffff;
  transform: scale(1.08);
}

.chat-input-wrapper .chat-input {
  flex: 1;
  background: transparent !important;
  border: none !important;
  color: var(--text-main, #e2ebd9) !important;
  font-size: 0.92rem;
  padding: 0.5rem 0.3rem;
  outline: none !important;
  box-shadow: none !important;
  min-width: 0;
}

.chat-send-btn {
  background: var(--accent, #b1cdbb);
  color: #13222c;
  border: none;
  border-radius: 18px;
  padding: 0.45rem 0.95rem;
  font-weight: bold;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.chat-send-btn:hover {
  background: #ffffff;
  color: #13222c;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(177, 205, 187, 0.3);
}

/* Select & Dropdown Styling Fixes for readable options */
select, .chat-input select, .form-control select {
  background-color: #1c2e39 !important;
  color: var(--text-main, #e2ebd9) !important;
  border: 1px solid var(--accent-alpha, rgba(177, 205, 187, 0.3)) !important;
  border-radius: 6px;
  padding: 0.4rem 0.6rem;
  font-family: inherit;
  font-size: 0.88rem;
  outline: none;
  cursor: pointer;
}

select option {
  background-color: #ffffff !important;
  color: #13222c !important;
  padding: 0.6rem 0.8rem;
  font-size: 0.9rem;
}

select option:checked, select option:hover {
  background-color: #22343f !important;
  color: #b1cdbb !important;
  font-weight: bold;
}

/* Light, clear placeholder styling */
.chat-input::placeholder,
.form-control::placeholder {
  color: rgba(244, 238, 227, 0.75) !important;
  opacity: 1 !important;
  font-style: italic;
}

.chat-input:focus {
  outline: none;
  border-color: var(--accent);
}

.preview-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  background-color: #1a2730;
}

.preview-bar {
  padding: 0.75rem 1.25rem;
  background-color: rgba(0, 0, 0, 0.2);
  border-bottom: 1px solid var(--accent-alpha);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.9rem;
  color: var(--accent);
}

.preview-iframe {
  flex: 1;
  width: 100%;
  height: 100%;
  border: none;
}

/* Modal Popup Dialog Styles */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(5px);
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.25s ease-in-out;
}

.modal-backdrop.active {
  display: flex !important;
  opacity: 1 !important;
  pointer-events: auto !important;
}

.modal-card {
  background-color: #2a3d49;
  border: 1.5px solid var(--accent);
  border-radius: 8px;
  width: 92%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 2rem;
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.5);
  position: relative;
  transform: translateY(15px);
  transition: transform 0.25s ease-in-out;
  color: var(--text-main);
}

.modal-backdrop.active .modal-card {
  transform: translateY(0);
}

.modal-close {
  position: absolute;
  top: 0.8rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover {
  color: var(--accent);
}

.modal-title {
  font-size: 1.6rem;
  color: var(--text-main);
  margin-bottom: 0.4rem;
}

.modal-subtitle {
  color: var(--accent);
  margin-bottom: 1.25rem;
  font-size: 0.92rem;
}

.form-group {
  margin-bottom: 1.1rem;
}

.form-group label {
  display: block;
  color: var(--text-main);
  margin-bottom: 0.35rem;
  font-size: 0.92rem;
}

.form-control {
  width: 100%;
  padding: 0.75rem 0.9rem;
  background-color: rgba(244, 238, 227, 0.1);
  border: 1px solid var(--accent-alpha);
  border-radius: 5px;
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 0.98rem;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  background-color: rgba(244, 238, 227, 0.15);
}

.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem 1rem;
  margin-top: 0.4rem;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-main);
  cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Profile Badge Button in Header */
.token-badge-clickable {
  cursor: pointer;
  transition: all 0.2s ease;
}

.token-badge-clickable:hover {
  background: rgba(177, 205, 187, 0.2) !important;
  border-color: var(--accent) !important;
}

.profile-badge-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.8rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--accent-alpha);
  border-radius: 20px;
  color: var(--text-main);
  font-family: var(--font-family);
  font-size: 0.85rem;
  font-weight: bold;
  cursor: pointer;
  transition: all 0.2s ease;
}

.profile-badge-btn:hover {
  background: var(--accent-alpha);
  border-color: var(--accent);
}

.profile-avatar-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--text-dark);
}

/* Profile Modal Styles */
.profile-modal-card {
  max-width: 620px;
}

.profile-header-section {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1rem;
  margin-bottom: 1.2rem;
  border-bottom: 1px solid var(--accent-alpha);
}

.profile-avatar-lg {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--text-dark);
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.profile-section-card {
  background: rgba(0, 0, 0, 0.15);
  border: 1px solid var(--accent-alpha);
  border-radius: 6px;
  padding: 1.2rem;
  margin-bottom: 1.2rem;
}

.profile-section-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.profile-section-icon {
  font-size: 1.4rem;
}

/* ChatGPT Style Token Meter */
.token-meter-container {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  padding: 1rem;
}

.token-meter-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  margin-bottom: 0.5rem;
}

.token-progress-bar {
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.token-progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent) 0%, #4ecdc4 100%);
  border-radius: 5px;
  transition: width 0.4s ease;
}

.token-meter-footer {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
}

/* Plan Cards Grid inside Profile Modal */
.plan-cards-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.plan-mini-card {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--accent-alpha);
  border-radius: 6px;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  position: relative;
}

.plan-mini-card.featured {
  border-color: var(--accent);
  background: rgba(177, 205, 187, 0.08);
}

.plan-badge {
  position: absolute;
  top: -10px;
  right: 10px;
  background: var(--accent);
  color: var(--text-dark);
  font-size: 0.65rem;
  font-weight: bold;
  padding: 0.15rem 0.5rem;
  border-radius: 10px;
}

.plan-title {
  font-size: 1rem;
  font-weight: bold;
  color: var(--accent);
}

.plan-price {
  font-size: 1.3rem;
  font-weight: bold;
  margin: 0.3rem 0 0.8rem;
}

.plan-price span {
  font-size: 0.8rem;
  font-weight: normal;
  color: var(--text-muted);
}

.plan-features {
  list-style: none;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
  flex: 1;
}

.plan-features li {
  margin-bottom: 0.3rem;
}

/* Footer */
footer {
  text-align: center;
  padding: 2rem 1.5rem;
  border-top: 1px solid var(--accent-alpha);
  font-size: 0.85rem;
  color: var(--text-muted);
}

@media (max-width: 850px) {
  .workspace-container {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
}

@media (max-width: 600px) {
  .plan-cards-grid {
    grid-template-columns: 1fr;
  }
}
