/* ============================================
   MailCenter Pro - Dark Mode Stylesheet
   ============================================ */

/* --- CSS Custom Properties --- */
:root {
  --bg: #1a1a2e;
  --surface: #16213e;
  --card: #0f3460;
  --primary: #e94560;
  --text: #eee;
  --text-muted: #888;
  --success: #00b894;
  --warning: #f39c12;
  --danger: #e74c3c;
  --border: #2a2a4a;

  /* Account Colors */
  --hermes-harry: #6366f1;
  --hermes-office: #8b5cf6;
  --homegarden: #00b894;
  --hydropon: #00d2a0;
  --gmail: #ea4335;
  --hermyon-hub: #f59e0b;

  --sidebar-width: 260px;
  --radius: 8px;
  --radius-sm: 4px;
  --transition: 0.2s ease;
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  outline: none;
}

input, textarea, select {
  font-family: inherit;
  font-size: inherit;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  outline: none;
  transition: border-color var(--transition);
}

input:focus, textarea:focus, select:focus {
  border-color: var(--primary);
}

/* --- Scrollbar --- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* --- Login Screen --- */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
}

.login-card h1 {
  font-size: 24px;
  margin-bottom: 8px;
  color: var(--primary);
}

.login-card p {
  color: var(--text-muted);
  margin-bottom: 24px;
}

.login-card .form-group {
  margin-bottom: 16px;
  text-align: left;
}

.login-card label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.login-card input {
  width: 100%;
}

.login-card .login-error {
  color: var(--danger);
  font-size: 13px;
  margin-bottom: 12px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: background var(--transition), opacity var(--transition);
}

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

.btn-primary:hover { opacity: 0.85; }

.btn-secondary {
  background: var(--card);
  color: var(--text);
}

.btn-secondary:hover { background: #1a4a7a; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
}

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

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

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-full { width: 100%; }

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

/* --- App Container (3-Column Grid) --- */
.app-container {
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr 1.2fr;
  height: 100vh;
  overflow: hidden;
}

/* --- Sidebar --- */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.sidebar-header {
  padding: 20px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.sidebar-header h2 {
  font-size: 18px;
  color: var(--primary);
  margin-bottom: 12px;
}

.sidebar-header .btn {
  margin-bottom: 8px;
}

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.sidebar-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 12px 16px 4px;
}

.sidebar-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background var(--transition);
  border-left: 3px solid transparent;
}

.sidebar-item:hover {
  background: rgba(255,255,255,0.04);
}

.sidebar-item.active {
  background: rgba(233, 69, 96, 0.1);
  border-left-color: var(--primary);
}

.sidebar-item .icon {
  font-size: 16px;
  width: 20px;
  text-align: center;
}

.sidebar-item .label {
  flex: 1;
  font-size: 13px;
}

.sidebar-item .count {
  font-size: 11px;
  background: var(--card);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: 10px;
}

.account-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-footer .user-info {
  font-size: 12px;
  color: var(--text-muted);
}

/* --- Quick Filter Bar --- */
.quick-filters {
  display: flex;
  gap: 6px;
  padding: 8px 0;
  flex-wrap: wrap;
}

.filter-chip {
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 12px;
  background: var(--card);
  color: var(--text-muted);
  cursor: pointer;
  border: 1px solid transparent;
  transition: all var(--transition);
}

.filter-chip:hover {
  color: var(--text);
  border-color: var(--border);
}

.filter-chip.active {
  background: var(--primary);
  color: #fff;
}

/* --- Mail List --- */
.mail-list {
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  height: 100vh;
  overflow: hidden;
}

.mail-list-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.mail-list-header h3 {
  font-size: 16px;
  margin-bottom: 10px;
}

.search-bar {
  display: flex;
  gap: 8px;
}

.search-bar input {
  flex: 1;
}

.mail-list-body {
  flex: 1;
  overflow-y: auto;
}

.mail-item {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  cursor: pointer;
  transition: background var(--transition);
  position: relative;
}

.mail-item:hover {
  background: rgba(255,255,255,0.03);
}

.mail-item.active {
  background: rgba(233, 69, 96, 0.08);
  border-left: 3px solid var(--primary);
}

.mail-item.unread {
  background: rgba(255,255,255,0.02);
}

.mail-item.unread .mail-item-subject {
  font-weight: 600;
  color: #fff;
}

.mail-item.pinned::before {
  content: '\uD83D\uDCCC';
  position: absolute;
  top: 4px;
  right: 8px;
  font-size: 10px;
}

.mail-item-left {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-top: 2px;
}

.mail-item-content {
  flex: 1;
  min-width: 0;
}

.mail-item-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2px;
}

.mail-item-from {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mail-item-date {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  margin-left: 8px;
}

.mail-item-subject {
  font-size: 13px;
  color: #ccc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.mail-item-preview {
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mail-item-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}

.attachment-icon {
  font-size: 12px;
}

/* --- Priority Badges --- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.badge-dringend {
  background: rgba(231, 76, 60, 0.2);
  color: #e74c3c;
}

.badge-aktion {
  background: rgba(243, 156, 18, 0.2);
  color: #f39c12;
}

.badge-normal {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.badge-newsletter {
  background: rgba(99, 102, 241, 0.15);
  color: #818cf8;
}

/* --- Mail Detail --- */
.mail-detail {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.mail-detail-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 15px;
}

.mail-detail-header {
  padding: 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.mail-detail-subject {
  font-size: 20px;
  font-weight: 600;
  margin-bottom: 8px;
}

.mail-detail-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
  color: var(--text-muted);
  flex-wrap: wrap;
}

.mail-detail-meta strong {
  color: var(--text);
}

.mail-detail-actions {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  flex-wrap: wrap;
}

.mail-detail-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.mail-detail-body .mail-content {
  line-height: 1.7;
  color: #ddd;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* Thread Bubbles */
.thread-message {
  padding: 14px 18px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  max-width: 85%;
  line-height: 1.6;
}

.thread-message.received {
  background: var(--card);
  margin-right: auto;
}

.thread-message.sent {
  background: rgba(233, 69, 96, 0.12);
  margin-left: auto;
}

.thread-message .thread-meta {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

/* AI Suggestions Panel */
.ai-panel {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.ai-panel-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.ai-suggestion {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.ai-suggestion:hover {
  background: #1a4a7a;
}

.ai-suggestion .variant-label {
  font-size: 11px;
  color: var(--primary);
  text-transform: uppercase;
}

/* Brevo / WooCommerce Info */
.contact-info, .order-info {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  background: rgba(0, 184, 148, 0.05);
  font-size: 13px;
}

.contact-info h4, .order-info h4 {
  font-size: 12px;
  color: var(--success);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.info-row {
  display: flex;
  gap: 8px;
  margin-bottom: 2px;
}

.info-row .info-label {
  color: var(--text-muted);
  min-width: 80px;
}

/* Attachments */
.attachments-list {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.attachments-list h4 {
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-bottom: 8px;
}

.attachment-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--card);
  border-radius: var(--radius-sm);
  font-size: 12px;
  margin-right: 6px;
  margin-bottom: 6px;
}

/* --- Compose Modal --- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.compose-form {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.compose-header h3 {
  font-size: 16px;
}

.compose-body {
  flex: 1;
  padding: 16px 20px;
  overflow-y: auto;
}

.compose-body .form-group {
  margin-bottom: 12px;
}

.compose-body label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.compose-body input,
.compose-body textarea,
.compose-body select {
  width: 100%;
}

.compose-body textarea {
  min-height: 200px;
  resize: vertical;
}

.compose-templates {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.compose-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.compose-footer-actions {
  display: flex;
  gap: 8px;
}

/* --- Snooze Popover --- */
.snooze-popover {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 0;
  min-width: 180px;
  z-index: 500;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
}

.snooze-option {
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: background var(--transition);
}

.snooze-option:hover {
  background: rgba(255,255,255,0.06);
}

/* --- Toast / Undo --- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  z-index: 2000;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  animation: slideInRight 0.3s ease;
}

.toast .toast-message {
  font-size: 13px;
}

.toast .toast-undo {
  color: var(--primary);
  font-weight: 600;
  cursor: pointer;
  font-size: 13px;
  background: none;
  border: none;
}

.toast .toast-countdown {
  width: 100%;
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  position: absolute;
  bottom: 0;
  left: 0;
  overflow: hidden;
}

.toast .toast-countdown-bar {
  height: 100%;
  background: var(--primary);
  border-radius: 2px;
  animation: countdown 5s linear forwards;
}

@keyframes slideInRight {
  from { transform: translateX(100px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes countdown {
  from { width: 100%; }
  to { width: 0%; }
}

/* --- Keyboard Shortcuts Hint --- */
.shortcuts-hint {
  position: fixed;
  bottom: 24px;
  left: 24px;
  font-size: 11px;
  color: var(--text-muted);
  opacity: 0.6;
}

.shortcuts-hint kbd {
  display: inline-block;
  padding: 1px 5px;
  font-size: 10px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 3px;
  margin: 0 2px;
  font-family: monospace;
}

/* --- Loading Spinner --- */
.loading-spinner {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
}

.spinner {
  width: 24px;
  height: 24px;
  border: 3px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

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

/* --- Empty State --- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  color: var(--text-muted);
  text-align: center;
}

.empty-state .empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state p {
  font-size: 14px;
}

/* --- Sync Status --- */
.sync-status {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

.sync-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
}

.sync-dot.syncing {
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

/* --- Mobile Bottom Tabs --- */
.mobile-tabs {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  z-index: 100;
}

.mobile-tabs-inner {
  display: flex;
}

.mobile-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0;
  font-size: 10px;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition);
  background: none;
  border: none;
}

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

.mobile-tab .tab-icon {
  font-size: 18px;
}

/* --- Responsive --- */
@media (max-width: 1024px) {
  .app-container {
    grid-template-columns: var(--sidebar-width) 1fr;
  }
  .mail-detail {
    position: fixed;
    inset: 0;
    z-index: 50;
    background: var(--bg);
    display: none;
  }
  .mail-detail.visible {
    display: flex;
  }
}

@media (max-width: 768px) {
  .app-container {
    grid-template-columns: 1fr;
    padding-bottom: 56px;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 56px;
    width: 100%;
    z-index: 60;
    display: none;
  }

  .sidebar.visible {
    display: flex;
  }

  .mail-list {
    border-right: none;
  }

  .mail-detail {
    position: fixed;
    inset: 0;
    bottom: 56px;
    z-index: 50;
    background: var(--bg);
    display: none;
  }

  .mail-detail.visible {
    display: flex;
  }

  .mobile-tabs {
    display: block;
  }

  .shortcuts-hint {
    display: none;
  }

  .compose-form {
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
  }
}

/* --- Utility --- */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-2 { margin-bottom: 8px; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.truncate {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.hidden { display: none !important; }
