/* =========================================================
   AI-Manager Warm & Mobile-First Stylesheet
   Inspired by The Loft: Warm timber, soft glowing embers, simplicity.
   ========================================================= */

:root {
  --bg-dark: #141210;
  --bg-card: #1f1a16;
  --bg-card-secondary: #27211c;
  --bg-card-hover: #322a24;
  --border-warm: #3d3027;
  --border-subtle: #2d241d;
  
  --accent-warm: #e8804c;
  --accent-gold: #f5a623;
  --accent-glow: rgba(232, 128, 76, 0.25);
  --accent-teams: #505ac9;
  --accent-teams-hover: #434bb7;
  
  --text-primary: #f6efe9;
  --text-secondary: #ad9c8f;
  --text-muted: #796c62;
  
  --danger-color: #e05252;
  --danger-bg: rgba(224, 82, 82, 0.12);
  --success-color: #52c41a;

  --nav-height: 64px;
  --header-height: 60px;
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  background-color: var(--bg-dark);
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
}

/* App Wrapper */
#app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  max-width: 600px;
  margin: 0 auto;
  position: relative;
  background-color: var(--bg-dark);
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.6);
}

/* Hidden Utility */
.hidden {
  display: none !important;
}

/* Top App Header */
.app-header {
  height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  background-color: rgba(22, 18, 15, 0.95);
  border-bottom: 1px solid var(--border-warm);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(10px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e8804c, #b84c16);
  box-shadow: 0 2px 8px rgba(232, 128, 76, 0.4);
}

.brand-icon svg {
  width: 20px;
  height: 20px;
  fill: #fff;
}

.brand-title {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.3px;
  color: var(--text-primary);
}

.brand-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  background-color: rgba(232, 128, 76, 0.15);
  color: var(--accent-warm);
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: 4px;
}

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

.user-pill {
  font-size: 0.82rem;
  color: var(--text-secondary);
  background-color: var(--bg-card);
  padding: 4px 10px;
  border-radius: 20px;
  border: 1px solid var(--border-warm);
  display: flex;
  align-items: center;
  gap: 6px;
}

.user-pill-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background-color: var(--accent-warm);
  box-shadow: 0 0 6px var(--accent-warm);
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.btn-icon:hover {
  color: var(--text-primary);
  background-color: var(--bg-card);
}

/* Install Banner */
.pwa-banner {
  background: linear-gradient(90deg, #2b1f17, #38271c);
  border-bottom: 1px solid var(--accent-warm);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.85rem;
  z-index: 40;
}

.pwa-banner-text {
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-install {
  background-color: var(--accent-warm);
  color: #fff;
  border: none;
  font-weight: 600;
  font-size: 0.8rem;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* Main Content Area */
.app-content {
  flex: 1;
  padding: 16px;
  padding-bottom: calc(var(--nav-height) + 24px);
  overflow-y: auto;
}

/* Auth / Login View */
.login-view {
  min-height: calc(100vh - var(--header-height));
  min-height: calc(100dvh - var(--header-height));
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px 16px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background-color: var(--bg-card);
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.login-header {
  text-align: center;
  margin-bottom: 24px;
}

.login-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 14px;
  background: linear-gradient(135deg, #e8804c, #963b0e);
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 16px var(--accent-glow);
}

.login-icon svg {
  width: 32px;
  height: 32px;
  fill: #fff;
}

.login-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.login-sub {
  font-size: 0.88rem;
  color: var(--text-secondary);
}

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

.form-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  background-color: var(--bg-card-secondary);
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  border-color: var(--accent-warm);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.btn-primary {
  width: 100%;
  padding: 12px;
  background: linear-gradient(135deg, #e8804c, #c85a17);
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.15s, opacity 0.15s;
  box-shadow: 0 4px 12px rgba(232, 128, 76, 0.3);
}

.btn-primary:active {
  transform: scale(0.98);
}

.login-footer-note {
  margin-top: 18px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--text-muted);
  line-height: 1.4;
}

/* Alert Banner */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.alert-danger {
  background-color: var(--danger-bg);
  border: 1px solid rgba(224, 82, 82, 0.4);
  color: #f7a8a8;
}

/* ==========================================
   Tab Views
   ========================================== */
.tab-view {
  display: none;
  animation: fadeIn 0.25s ease-out;
}

.tab-view.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ------------------------------------------
   Feature (2): Next Meeting View
   ------------------------------------------ */
.meeting-hero-card {
  background: linear-gradient(145deg, #241c17, #1d1713);
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin-bottom: 16px;
  position: relative;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
}

.meeting-hero-card::before {
  content: "";
  position: absolute;
  top: -50px;
  right: -50px;
  width: 140px;
  height: 140px;
  background: radial-gradient(circle, rgba(232, 128, 76, 0.18) 0%, transparent 70%);
  pointer-events: none;
}

.meeting-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--accent-warm);
  background-color: rgba(232, 128, 76, 0.12);
  padding: 3px 8px;
  border-radius: 6px;
  margin-bottom: 10px;
}

.meeting-header-title {
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
}

/* Big Join on Teams Button */
.btn-teams-join {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 16px 20px;
  background: linear-gradient(135deg, #5b68df, #444fb5);
  color: #fff;
  text-decoration: none;
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: var(--radius-md);
  box-shadow: 0 6px 18px rgba(80, 90, 201, 0.45);
  transition: transform 0.15s, box-shadow 0.15s;
  margin: 14px 0 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-teams-join:hover, .btn-teams-join:focus {
  background: linear-gradient(135deg, #6875ed, #4c57c4);
  box-shadow: 0 8px 24px rgba(80, 90, 201, 0.6);
  transform: translateY(-1px);
}

.btn-teams-join:active {
  transform: translateY(1px);
}

.btn-teams-join svg {
  width: 24px;
  height: 24px;
  fill: #fff;
  flex-shrink: 0;
}

/* Meeting Details Markdown Renderer */
.meeting-content-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-lg);
  padding: 20px;
  color: var(--text-primary);
  line-height: 1.6;
}

.meeting-content-card h1, .meeting-content-card h2, .meeting-content-card h3 {
  color: var(--accent-warm);
  margin-top: 18px;
  margin-bottom: 8px;
  font-weight: 700;
}

.meeting-content-card h1 { font-size: 1.25rem; }
.meeting-content-card h2 { font-size: 1.1rem; border-bottom: 1px solid var(--border-subtle); padding-bottom: 4px; }
.meeting-content-card h3 { font-size: 1rem; }

.meeting-content-card ul, .meeting-content-card ol {
  padding-left: 20px;
  margin: 10px 0;
}

.meeting-content-card li {
  margin-bottom: 6px;
  color: var(--text-primary);
}

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

.meeting-content-card blockquote {
  border-left: 3px solid var(--accent-warm);
  background-color: var(--bg-card-secondary);
  padding: 10px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  margin: 14px 0;
  font-style: italic;
  color: var(--text-secondary);
}

/* ------------------------------------------
   Feature (3): Group Board View
   ------------------------------------------ */
.board-composer {
  background-color: var(--bg-card);
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
}

.board-textarea {
  width: 100%;
  min-height: 72px;
  background-color: var(--bg-card-secondary);
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-md);
  padding: 12px;
  color: var(--text-primary);
  font-family: inherit;
  font-size: 0.95rem;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
}

.board-textarea:focus {
  border-color: var(--accent-warm);
}

.board-composer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 10px;
}

.char-counter {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.btn-send {
  background-color: var(--accent-warm);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: var(--radius-md);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: opacity 0.2s;
}

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

.board-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.board-post {
  background-color: var(--bg-card);
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  display: flex;
  gap: 12px;
}

.post-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #3d2f24, #271f18);
  border: 1px solid var(--accent-warm);
  color: var(--accent-warm);
  font-weight: 700;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.post-body {
  flex: 1;
}

.post-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.post-author {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
}

.post-time {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.post-text {
  font-size: 0.92rem;
  color: var(--text-primary);
  white-space: pre-wrap;
  word-break: break-word;
}

/* ------------------------------------------
   Feature (4): Private Letterbox View
   ------------------------------------------ */
.letterbox-intro-card {
  background: linear-gradient(145deg, #251d18, #1b1612);
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.letterbox-intro-icon {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background-color: rgba(232, 128, 76, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent-warm);
  flex-shrink: 0;
}

.letterbox-intro-text h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--accent-warm);
  margin-bottom: 2px;
}

.letterbox-intro-text p {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.4;
}

.letterbox-thread {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-bottom: 18px;
}

.letter-bubble {
  max-width: 90%;
  border-radius: var(--radius-lg);
  padding: 14px 16px;
  position: relative;
  word-break: break-word;
}

/* User's own letters */
.letter-bubble.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #32251c, #2a1f17);
  border: 1px solid rgba(232, 128, 76, 0.35);
  border-bottom-right-radius: 4px;
}

/* Miles' replies from The Loft */
.letter-bubble.miles {
  align-self: flex-start;
  background: linear-gradient(135deg, #1d1b19, #171513);
  border: 1px solid var(--border-warm);
  border-left: 3px solid var(--accent-warm);
  border-bottom-left-radius: 4px;
}

.letter-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.letter-sender {
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.letter-sender.miles-sender {
  color: var(--accent-warm);
}

.letter-badge-miles {
  font-size: 0.68rem;
  font-weight: 600;
  background-color: rgba(232, 128, 76, 0.2);
  color: var(--accent-warm);
  padding: 1px 6px;
  border-radius: 4px;
}

.letter-date {
  font-size: 0.72rem;
  color: var(--text-muted);
}

.letter-body {
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text-primary);
  white-space: pre-wrap;
}

.letterbox-composer {
  background-color: var(--bg-card);
  border: 1px solid var(--border-warm);
  border-radius: var(--radius-lg);
  padding: 16px;
}

.letterbox-composer-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ==========================================
   Bottom Navigation Bar (Mobile-First)
   ========================================== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  max-width: 600px;
  margin: 0 auto;
  height: var(--nav-height);
  background-color: rgba(20, 17, 14, 0.97);
  border-top: 1px solid var(--border-warm);
  display: flex;
  align-items: center;
  justify-content: space-around;
  padding: 0 8px;
  z-index: 60;
  backdrop-filter: blur(12px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 100%;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.15s, transform 0.1s;
  padding: 4px 0;
}

.nav-item svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
  transition: transform 0.15s;
}

.nav-item span {
  font-size: 0.72rem;
  font-weight: 500;
}

.nav-item.active {
  color: var(--accent-warm);
}

.nav-item.active svg {
  transform: translateY(-2px);
}

.nav-item.active span {
  font-weight: 700;
}

/* Empty states */
.empty-state {
  text-align: center;
  padding: 36px 16px;
  color: var(--text-muted);
}

.empty-state-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 12px;
  color: var(--text-muted);
  opacity: 0.6;
}

.empty-state p {
  font-size: 0.9rem;
}
