@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=JetBrains+Mono:wght@400;500&display=swap');

:root {
  /* Core Color System (Cyber-Dark Scale) */
  --bg-primary: #08090d;
  --bg-secondary: #0e1118;
  --bg-tertiary: #161b26;
  --bg-card: rgba(22, 27, 38, 0.4);
  
  --accent-primary: #6366f1;     /* Vibrant Indigo */
  --accent-secondary: #8b5cf6;   /* Cyber Violet */
  --accent-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.15);
  
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-link: #38bdf8;
  
  --border-color: rgba(30, 41, 59, 0.6);
  --border-glow: rgba(99, 102, 241, 0.3);
  
  --color-success: #10b981;
  --color-danger: #ef4444;
  --color-warning: #f59e0b;
  
  /* Fonts */
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Elevation */
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.5);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.6);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, 0.8);
  --glass-blur: blur(12px);
}

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

body {
  background-color: var(--bg-primary);
  color: var(--text-primary);
  font-family: var(--font-sans);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

button, input, select {
  font-family: var(--font-sans);
  background: none;
  border: none;
  color: inherit;
}

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

/* App Header */
.app-header {
  height: 70px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  flex-shrink: 0;
  z-index: 10;
}

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

.logo-glow {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 16px rgba(99, 102, 241, 0.4);
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(to right, #ffffff, #a5b4fc);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.status-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  color: var(--text-secondary);
  background-color: var(--bg-tertiary);
  padding: 6px 14px;
  border-radius: 20px;
  border: 1px solid var(--border-color);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--color-danger);
}

.status-dot.connected {
  background-color: var(--color-success);
  box-shadow: 0 0 10px var(--color-success);
  animation: pulse 2s infinite;
}

/* Dashboard Layout */
.app-container {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* Sidebar - Active Inboxes */
.sidebar-pane {
  width: 320px;
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.sidebar-actions {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
  color: white;
  padding: 12px 18px;
  border-radius: 10px;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(99, 102, 241, 0.2);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}

.btn-secondary {
  background-color: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: 10px;
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background-color: rgba(30, 41, 59, 0.4);
  border-color: var(--text-muted);
}

.sidebar-list-header {
  padding: 16px 20px 8px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.inbox-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.inbox-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  border-radius: 10px;
  background-color: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s ease;
}

.inbox-item:hover {
  background-color: rgba(22, 27, 38, 0.4);
  border-color: var(--border-color);
}

.inbox-item.active {
  background-color: rgba(99, 102, 241, 0.08);
  border-color: var(--border-glow);
}

.inbox-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  flex: 1;
}

.inbox-address {
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.inbox-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.meta-dot {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background-color: var(--text-muted);
}

.inbox-item.active .inbox-address {
  color: var(--accent-primary);
}

.inbox-actions {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s;
}

.inbox-item:hover .inbox-actions,
.inbox-item.active .inbox-actions {
  opacity: 1;
}

.action-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.2s;
}

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

.action-icon.trash:hover {
  background-color: rgba(239, 68, 68, 0.15);
  color: var(--color-danger);
}

/* Middle Pane - Messages List */
.messages-pane {
  width: 360px;
  background-color: var(--bg-primary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.messages-header {
  padding: 20px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.search-box {
  position: relative;
  width: 100%;
}

.search-input {
  width: 100%;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 12px 16px 12px 42px;
  border-radius: 10px;
  font-size: 0.9rem;
  color: var(--text-primary);
  transition: all 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: var(--accent-primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.messages-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  padding: 16px;
  border-radius: 12px;
  cursor: pointer;
  position: relative;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.message-card:hover {
  transform: translateY(-1px);
  border-color: var(--text-muted);
}

.message-card.active {
  background-color: rgba(99, 102, 241, 0.05);
  border-color: var(--accent-primary);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.05);
}

.message-card-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.8rem;
}

.sender-address {
  color: var(--accent-primary);
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 180px;
}

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

.message-subject {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-primary);
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
}

.message-snippet {
  font-size: 0.85rem;
  color: var(--text-secondary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Empty States */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 40px;
  color: var(--text-muted);
  flex: 1;
  gap: 16px;
}

.empty-state-icon {
  color: var(--text-muted);
  opacity: 0.4;
}

.empty-state-title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.empty-state-desc {
  font-size: 0.85rem;
  max-width: 240px;
  line-height: 1.5;
}

/* Right Pane - Email Reader */
.reader-pane {
  flex: 1;
  background-color: var(--bg-primary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.reader-header {
  padding: 28px;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  flex-shrink: 0;
}

.reader-meta-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.reader-subject {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}

.reader-addresses {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.875rem;
}

.address-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.address-label {
  color: var(--text-muted);
  width: 45px;
  font-weight: 600;
}

.address-val {
  color: var(--text-secondary);
  font-weight: 500;
}

.address-val.highlight {
  color: var(--accent-primary);
}

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

/* Content Mode Tabs */
.view-tabs {
  display: flex;
  background-color: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0 28px;
  flex-shrink: 0;
}

.tab-btn {
  padding: 14px 20px;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all 0.2s;
}

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

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

/* Email Viewer Core */
.reader-body-container {
  flex: 1;
  overflow: auto;
  position: relative;
  background-color: #0c0e14;
}

.text-content-wrapper {
  padding: 32px;
  line-height: 1.7;
  font-size: 0.95rem;
  color: #cbd5e1;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 800px;
  margin: 0 auto;
}

.iframe-sandbox {
  width: 100%;
  height: 100%;
  border: none;
  background-color: #ffffff; /* Typically HTML email looks best with light background */
}

/* Modals */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(5, 5, 8, 0.85);
  backdrop-filter: var(--glass-blur);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

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

.modal-card {
  width: 480px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.3s ease;
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-header {
  padding: 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

.modal-close {
  color: var(--text-muted);
  cursor: pointer;
  transition: color 0.2s;
}

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

.modal-body {
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.form-input-wrapper {
  display: flex;
  border: 1px solid var(--border-color);
  border-radius: 10px;
  overflow: hidden;
  background-color: var(--bg-primary);
  transition: border-color 0.2s;
}

.form-input-wrapper:focus-within {
  border-color: var(--accent-primary);
}

.form-input {
  flex: 1;
  padding: 12px 16px;
  font-size: 0.95rem;
  color: var(--text-primary);
}

.form-input:focus {
  outline: none;
}

.form-addon {
  background-color: var(--bg-tertiary);
  padding: 0 16px;
  display: flex;
  align-items: center;
  border-left: 1px solid var(--border-color);
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.9rem;
}

.form-select {
  width: 100%;
  padding: 12px 16px;
  font-size: 0.95rem;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 10px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19.5 8.25l-7.5 7.5-7.5-7.5' /%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 16px center;
  background-size: 16px;
}

.form-select:focus {
  outline: none;
  border-color: var(--accent-primary);
}

.modal-footer {
  padding: 20px 24px;
  background-color: rgba(14, 17, 24, 0.4);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
}

/* Toast Container */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 1000;
}

.toast {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-glow);
  color: var(--text-primary);
  padding: 14px 20px;
  border-radius: 10px;
  box-shadow: var(--shadow-md);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  font-weight: 500;
  min-width: 300px;
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast.success {
  border-color: rgba(16, 185, 129, 0.3);
}

.toast.success .toast-bullet {
  background-color: var(--color-success);
  box-shadow: 0 0 8px var(--color-success);
}

.toast.danger {
  border-color: rgba(239, 108, 108, 0.3);
}

.toast.danger .toast-bullet {
  background-color: var(--color-danger);
  box-shadow: 0 0 8px var(--color-danger);
}

.toast-bullet {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--accent-primary);
}

.toast-text {
  flex: 1;
}

/* Pulsating loading skeleton */
.skeleton-loader {
  animation: pulse-bg 1.5s infinite;
}

@keyframes pulse-bg {
  0% {
    opacity: 0.6;
  }
  50% {
    opacity: 0.3;
  }
  100% {
    opacity: 0.6;
  }
}

@keyframes pulse {
  0% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    transform: scale(1);
    box-shadow: 0 0 0 8px rgba(16, 185, 129, 0);
  }
  100% {
    transform: scale(0.95);
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

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