:root {
  --bg: #ffffff;
  --card: #ffffff;
  --muted: #5f6368;
  --text: #202124;
  --primary: #0b57d0;
  --danger: #d93025;
  --border: #dadce0;
  --accent: #1a73e8;
  --hover: #f1f3f4;
  --input-bg: #f1f3f4;
  --header-bg: #f6f8fc;
  --star: #5f6368;
  --star-active: #f4b400;
  --fab-bg: #ffffff;
  --fab-color: #5f6368;
}

[data-theme="dark"] {
  --bg: #1f1f1f;
  --card: #1f1f1f;
  --muted: #9aa0a6;
  --text: #e8eaed;
  --primary: #8ab4f8;
  --danger: #f28b82;
  --border: #3c4043;
  --accent: #8ab4f8;
  --hover: #303134;
  --input-bg: #303134;
  --header-bg: #1f1f1f;
  --star: #9aa0a6;
  --star-active: #fdd663;
  --fab-bg: #303134;
  --fab-color: #e8eaed;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: 'Roboto', 'Google Sans', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  transition: background-color 0.3s, color 0.3s;
}

/* App Header & Navigation */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  background-color: var(--header-bg);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
  min-height: 57px;
}

.header-left {
  display: flex;
  align-items: center;
}

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-header h1 { 
  margin: 0; 
  font-size: 22px; 
  font-weight: 400;
  color: var(--text);
}

.theme-toggle {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.theme-toggle:hover {
  background-color: var(--hover);
  color: var(--text);
}

.tabs { display: flex; gap: 8px; }
.tab {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  padding: 6px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}
.tab.active { 
  background-color: var(--primary);
  border-color: var(--primary); 
  color: #ffffff; 
}

[data-theme="dark"] .tab.active {
  color: #1f1f1f;
}

main { 
  max-width: 100%; 
  margin: 0 auto; 
  padding: 0;
  padding-bottom: 80px; /* Space for bottom nav */
}

/* Common Components */
.panel-header { 
  display: flex; 
  align-items: center; 
  justify-content: space-between; 
  gap: 12px; 
  margin: 16px;
}

.panel-header h2 { 
  margin: 4px 0; 
  font-size: 20px;
  font-weight: 400;
  color: var(--text);
}

.panel-header p { 
  margin: 0; 
  color: var(--muted); 
  font-size: 14px;
}

.card {
  background: var(--card);
  border-radius: 0;
  padding: 16px;
  margin: 0;
}

/* Inputs */
input, textarea, select {
  background: var(--input-bg);
  border: none;
  color: var(--text);
  padding: 12px 16px;
  border-radius: 8px;
  width: 100%;
  font-size: 16px;
  font-family: inherit;
}

input:focus, textarea:focus, select:focus {
  outline: none;
  background: var(--hover);
}

textarea {
  resize: none;
}

/* Buttons */
button {
  cursor: pointer;
  border-radius: 24px;
  padding: 10px 24px;
  border: none;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  transition: background-color 0.2s;
}

.primary { 
  background: var(--primary); 
  color: #ffffff; 
}

[data-theme="dark"] .primary {
  color: #1f1f1f;
}

.secondary {
  background: transparent;
  color: var(--primary);
  border: 1px solid var(--border);
}

.danger { 
  background: var(--danger); 
  color: #ffffff;
}

[data-theme="dark"] .danger {
  color: #1f1f1f;
}

/* Inbox View */
#inbox-view {
  background: var(--bg);
  min-height: 100vh;
  position: relative;
}

.inbox-header {
  padding: 8px 16px;
  background: var(--header-bg);
  position: sticky;
  top: 57px; /* Height of app-header */
  z-index: 90;
}

.inbox-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
}

.inbox-menu-btn {
  background: transparent;
  border: none;
  color: var(--text);
  padding: 8px;
  margin-left: -8px;
}

.search-bar {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--input-bg);
  border-radius: 8px;
  padding: 4px 12px;
  height: 48px;
  gap: 12px;
}

.search-icon {
  color: var(--muted);
  display: flex;
  align-items: center;
}

.search-bar input {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 16px;
  color: var(--text);
  width: 100%;
  height: 100%;
}

.user-avatar-small {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 500;
  flex-shrink: 0;
}

[data-theme="dark"] .user-avatar-small {
  color: #1f1f1f;
}

.inbox-subheader {
  padding: 12px 16px;
  background: var(--bg);
}

.inbox-label {
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.inbox-list {
  padding-bottom: 80px;
}

.inbox-email-row {
  display: flex;
  align-items: flex-start;
  padding: 12px 16px;
  gap: 16px;
  cursor: pointer;
  background: var(--bg);
  border-bottom: 1px solid rgba(0,0,0,0.05);
}

.inbox-email-row:hover {
  background: var(--hover);
}

.inbox-email-row.unread {
  background: var(--bg);
}

.inbox-email-row.unread .inbox-email-subject,
.inbox-email-row.unread .inbox-email-sender,
.inbox-email-row.unread .inbox-email-date {
  font-weight: 700;
  color: var(--text);
}

/* Read messages - faded appearance */
.inbox-email-row.read {
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.inbox-email-row.read:hover {
  opacity: 0.85;
}

.inbox-email-row.read .inbox-email-subject,
.inbox-email-row.read .inbox-email-sender,
.inbox-email-row.read .inbox-email-date {
  font-weight: 400;
  color: var(--muted);
}

.inbox-email-row.read .inbox-email-body-preview {
  opacity: 0.7;
}

.inbox-email-row.read .inbox-email-avatar {
  opacity: 0.7;
}

.inbox-email-row.read .inbox-email-star {
  opacity: 0.5;
}

.inbox-email-avatar {
  flex-shrink: 0;
  margin-top: 4px;
}

.sender-avatar-img {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  object-fit: cover;
}

.sender-avatar-initial {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-size: 18px;
  font-weight: 500;
  text-transform: uppercase;
}

.inbox-email-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.inbox-email-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.inbox-email-sender {
  font-size: 17px;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inbox-email-date {
  font-size: 13px;
  color: var(--text);
  flex-shrink: 0;
  font-weight: 500;
}

.inbox-email-subject {
  font-size: 15px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inbox-email-body-preview {
  font-size: 15px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.inbox-email-star {
  color: var(--star);
  padding: 4px;
  margin-top: 16px;
}

.compose-btn {
  position: fixed;
  bottom: 90px;
  right: 16px;
  background: var(--fab-bg); /* Use CSS variable for fab background */
  color: var(--fab-color); /* Use CSS variable for fab color */
  border-radius: 16px;
  padding: 0 20px 0 16px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 4px 8px rgba(0,0,0,0.2);
  z-index: 100;
  font-size: 14px;
  font-weight: 500;
  transition: box-shadow 0.2s, background-color 0.2s;
}

.compose-btn:hover {
  box-shadow: 0 6px 12px rgba(0,0,0,0.3);
  background: var(--hover);
}

.compose-btn svg {
  color: var(--danger);
}

/* Bottom Navigation */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 80px;
  background: var(--bg);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: flex-start;
  padding-top: 12px;
  z-index: 100;
}

.nav-item {
  background: transparent;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  width: 64px;
  color: var(--muted);
  position: relative;
}

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

.nav-item.active::before {
  content: '';
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  width: 64px;
  height: 32px;
  background: rgba(217, 48, 37, 0.1);
  border-radius: 16px;
  z-index: -1;
}

.nav-icon-badge {
  position: relative;
  display: inline-block;
}

.nav-badge {
  position: absolute;
  top: -4px;
  right: -8px;
  background: var(--danger);
  color: white;
  font-size: 10px;
  font-weight: bold;
  padding: 2px 6px;
  border-radius: 10px;
  min-width: 16px;
  text-align: center;
}

/* Welcome View */
#welcome-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 57px);
  max-height: calc(100vh - 57px);
  padding: 20px;
  text-align: center;
  background: linear-gradient(135deg, var(--bg) 0%, rgba(26, 115, 232, 0.05) 100%);
  overflow: hidden;
}

/* Hide bottom nav when welcome view is shown */
#review:has(#welcome-view:not(.hidden)) .bottom-nav {
  display: none !important;
}

.welcome-card {
  background: var(--card);
  padding: 40px 32px;
  border-radius: 24px;
  width: 100%;
  max-width: 400px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  animation: slideUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.welcome-logo {
  width: 120px;
  height: auto;
  margin-bottom: 8px;
  animation: popIn 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.welcome-icon {
  font-size: 48px;
  margin-bottom: 8px;
  animation: wave 2s infinite;
}

.welcome-card h2 {
  margin: 0;
  font-size: 24px;
  font-weight: 700;
  color: var(--text);
}

.welcome-card p {
  margin: 0;
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

.welcome-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 8px;
}

.input-group {
  position: relative;
}

.welcome-form input {
  background: var(--input-bg);
  border: 2px solid transparent;
  padding: 16px;
  font-size: 18px;
  text-align: center;
  border-radius: 16px;
  transition: all 0.2s;
}

.welcome-form input:focus {
  background: var(--bg);
  border-color: var(--accent);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(26, 115, 232, 0.15);
}

.privacy-note {
  font-size: 8px;
  color: var(--muted);
  text-align: center;
  margin: 8px 0 0 0;
  line-height: 1.3;
  opacity: 0.5;
}

.start-btn {
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: white;
  padding: 16px;
  font-size: 18px;
  font-weight: 600;
  border-radius: 16px;
  box-shadow: 0 4px 16px rgba(26, 115, 232, 0.3);
  transition: transform 0.2s, box-shadow 0.2s;
}

.start-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(26, 115, 232, 0.4);
}

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

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

@keyframes popIn {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes wave {
  0%, 100% { transform: rotate(0deg); }
  25% { transform: rotate(-10deg); }
  75% { transform: rotate(10deg); }
}

/* Email Detail View */
#email-detail-view {
  background: var(--bg);
  min-height: 100vh;
  padding-bottom: 100px;
}

.back-button {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 15px;
  font-weight: 500;
  width: 100%;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background-color 0.2s;
}

.back-button:hover {
  background: var(--hover);
}

#review-card {
  margin: 0;
  border-radius: 0;
}

.gmail-email-container {
  background: var(--card);
  margin: 0;
  border-radius: 0;
}

.gmail-email-header {
  padding: 20px 16px 16px 16px;
}

.gmail-email-subject-row {
  margin-bottom: 12px;
}

.gmail-email-subject {
  font-size: 24px;
  font-weight: 400;
  color: var(--text);
  line-height: 1.4;
  margin: 0;
  word-wrap: break-word;
}

.gmail-email-badges {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.gmail-badge {
  font-size: 11px;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.gmail-badge-external {
  background: rgba(251, 188, 5, 0.15);
  color: #f59e0b;
}

[data-theme="dark"] .gmail-badge-external {
  background: rgba(251, 188, 5, 0.2);
  color: #fbbf24;
}

.gmail-badge-inbox {
  background: rgba(26, 115, 232, 0.15);
  color: #1a73e8;
  display: flex;
  align-items: center;
  gap: 4px;
}

[data-theme="dark"] .gmail-badge-inbox {
  background: rgba(138, 180, 248, 0.2);
  color: #8ab4f8;
}

.badge-close {
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  opacity: 0.7;
}

.gmail-email-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  margin-top: 4px;
}

.gmail-email-sender-info {
  display: flex;
  gap: 12px;
  flex: 1;
  min-width: 0;
}

.gmail-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 500;
  flex-shrink: 0;
  overflow: hidden;
}

.gmail-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

[data-theme="dark"] .gmail-avatar {
  color: #1f1f1f;
}

.gmail-sender-details {
  flex: 1;
  min-width: 0;
}

.gmail-sender-name {
  font-weight: 500;
  color: var(--text);
  font-size: 15px;
  margin-bottom: 4px;
  line-height: 1.4;
}

.gmail-recipient-info {
  font-size: 13px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.gmail-recipient-email {
  color: var(--text);
}

.gmail-dropdown-icon {
  font-size: 10px;
  opacity: 0.6;
}

.gmail-email-date-info {
  flex-shrink: 0;
  text-align: right;
}

.gmail-email-date {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
}

.gmail-email-body {
  padding: 20px 16px 32px 16px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  word-wrap: break-word;
}

/* Review Actions */
.review-actions {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 16px;
  background: var(--card);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  z-index: 100;
}

.review-actions button {
  flex: 1;
  padding: 14px;
  border-radius: 28px;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

/* Reason Modal - Bottom Sheet */
.reason-modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.5);
  z-index: 2000;
  display: flex;
  align-items: flex-end;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.reason-modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.reason-modal {
  background: var(--card);
  width: 100%;
  padding: 24px;
  border-radius: 24px 24px 0 0;
  transform: translateY(100%);
  transition: transform 0.3s cubic-bezier(0.1, 0.7, 0.1, 1);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.15);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.reason-modal-overlay.active .reason-modal {
  transform: translateY(0);
}

.reason-modal label {
  display: grid;
  gap: 8px;
  margin-bottom: 24px;
}

.reason-modal #reason-label {
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
}

.reason-modal .label-optional {
  font-size: 14px;
  color: var(--muted);
  font-weight: normal;
}

.reason-modal textarea {
  background: var(--input-bg);
  border-radius: 12px;
  padding: 16px;
  font-size: 16px;
  min-height: 120px;
}

.reason-form-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.reason-form-actions button {
  padding: 12px 24px;
  font-size: 15px;
}

/* Feedback Overlay */
.feedback-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.8);
  z-index: 3000;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}

.feedback-content {
  font-size: 80px;
  transform: scale(0.5);
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.feedback-overlay.active {
  opacity: 1;
}

.feedback-overlay.active .feedback-content {
  transform: scale(1.5);
}

/* Utilities */
.hidden { display: none !important; }
.muted { color: var(--muted); }

@media (max-width: 600px) {
  .app-header h1 { font-size: 18px; }
}
