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

/* =============================================
   FreeMail — Cyberpunk Style
   Dark themes + neon accents
   ============================================= */

:root {
  /* Neon accents */
  --primary: #00fff9;
  --primary-hover: #00d4cf;
  --primary-soft: rgba(0, 255, 249, 0.15);
  --neon-orange: #ffb400;
  --neon-orange-soft: rgba(255, 180, 0, 0.15);
  --neon-green: #39ff14;
  --neon-green-soft: rgba(57, 255, 20, 0.15);
  --neon-pink: #ffb400;
  --neon-pink-soft: rgba(255, 180, 0, 0.15);
  --neon-yellow: #f5e642;
  --neon-yellow-soft: rgba(245, 230, 66, 0.15);
  --danger: #ffb400;
  --danger-hover: #e0a000;
  --danger-soft: rgba(255, 180, 0, 0.15);
  --success: #39ff14;
  --success-soft: rgba(57, 255, 20, 0.15);
  --warning: #f5e642;

  /* Dark backgrounds */
  --bg: #0a0a12;
  --bg-card: #12121e;
  --bg-sidebar: #0e0e18;
  --bg-input: #1a1a2e;
  --text: #e0e0f0;
  --text-light: #8888aa;
  --text-muted: #55556a;
  --text-white: #e0e0f0;
  --border: rgba(255,255,255,0.06);

  /* Rounded but edgy */
  --radius: 8px;
  --radius-sm: 6px;
  --radius-xs: 4px;

  /* Neon glow shadows */
  --shadow: 0 0 15px rgba(0,255,249,0.08), inset 0 1px 0 rgba(255,255,255,0.04);
  --shadow-sm: 0 0 8px rgba(0,255,249,0.06), inset 0 1px 0 rgba(255,255,255,0.03);
  --shadow-inset: inset 0 0 15px rgba(0,0,0,0.4), inset 0 1px 0 rgba(255,255,255,0.03);
  --shadow-inset-sm: inset 0 0 8px rgba(0,0,0,0.3);
  --shadow-hover: 0 0 20px rgba(0,255,249,0.15), 0 0 4px rgba(0,255,249,0.3);
  --shadow-pressed: inset 0 0 20px rgba(0,0,0,0.5);
  --transition: 150ms ease;

  /* Glow */
  --glow: 0 0 6px rgba(0,255,249,0.4);
  --glow-orange: 0 0 6px rgba(255,180,0,0.4);
  --glow-pink: 0 0 6px rgba(255,180,0,0.4);
}

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

body {
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
  font-size: 13px;
  color: var(--text);
  background: var(--bg);
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  background-image:
    radial-gradient(ellipse at 15% 50%, rgba(0,255,249,0.05) 0%, transparent 50%),
    radial-gradient(ellipse at 85% 20%, rgba(255,180,0,0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 100%, rgba(0,20,40,0.4) 0%, transparent 70%),
    linear-gradient(180deg, rgba(10,10,18,1) 0%, rgba(5,5,15,1) 50%, rgba(2,2,10,1) 100%);
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: rgba(0,255,249,0.2); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,255,249,0.4); }

/* ---- Layout ---- */
#app {
  display: flex;
  min-height: 100vh;
}

/* ---- Resize Handles ---- */
.resize-handle {
  width: 3px;
  flex-shrink: 0;
  cursor: col-resize;
  background: transparent;
  position: relative;
  z-index: 10;
  transition: background var(--transition);
}
.resize-handle::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 1px;
  width: 1px;
  background: rgba(0,255,249,0.08);
  transition: background var(--transition);
}
.resize-handle:hover::after,
.resize-handle.dragging::after {
  background: var(--primary);
  box-shadow: var(--glow);
}
.resize-handle:hover,
.resize-handle.dragging {
  background: rgba(0,255,249,0.03);
}
.resize-handle.no-hover {
  cursor: default;
  pointer-events: none;
}

/* ---- Sidebar ---- */
.sidebar {
  width: 220px;
  min-height: 100vh;
  background: var(--bg-sidebar);
  background-image:
    radial-gradient(ellipse at 50% 0%, rgba(0,255,249,0.04) 0%, transparent 60%),
    linear-gradient(180deg, rgba(0,255,249,0.02) 0%, transparent 40%);
  color: var(--text-white);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  border-right: 1px solid rgba(0,255,249,0.06);
}

.sidebar-header {
  padding: 18px 14px;
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--primary);
  text-shadow: var(--glow);
}

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

.sidebar-nav .nav-item {
  padding: 9px 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-light);
  opacity: 0.6;
  transition: all var(--transition);
  font-size: 12px;
  border-radius: var(--radius-xs);
  margin-bottom: 2px;
  border-left: 2px solid transparent;
}
.sidebar-nav .nav-item:hover {
  opacity: 0.9;
  color: var(--text);
  background: rgba(0,255,249,0.03);
}
.sidebar-nav .nav-item.active {
  opacity: 1;
  color: var(--primary);
  background: rgba(0,255,249,0.05);
  border-left-color: var(--primary);
  text-shadow: 0 0 4px rgba(0,255,249,0.3);
}

.sidebar-footer {
  padding: 10px 8px;
  font-size: 12px;
}

.sidebar-footer .btn {
  width: 100%;
  text-align: center;
}

/* ---- Main Content ---- */
.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

.main-header {
  padding: 12px 20px;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
}

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

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid rgba(0,255,249,0.2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  background: var(--bg-input);
  color: var(--text);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.btn:hover { border-color: var(--primary); box-shadow: var(--shadow-hover); color: var(--primary); }
.btn:active { box-shadow: var(--shadow-pressed); }

.btn-primary {
  background: rgba(0,255,249,0.08);
  color: var(--primary);
  border-color: rgba(0,255,249,0.3);
}
.btn-primary:hover {
  background: rgba(0,255,249,0.15);
  box-shadow: var(--shadow-hover), var(--glow);
  color: var(--primary-hover);
}

.btn-danger {
  background: rgba(255,180,0,0.08);
  color: var(--danger);
  border-color: rgba(255,180,0,0.3);
}
.btn-danger:hover {
  background: rgba(255,180,0,0.15);
  box-shadow: var(--shadow-hover), var(--glow-pink);
  color: var(--danger-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-light);
  border-color: rgba(255,255,255,0.06);
}
.btn-ghost:hover {
  color: var(--text);
  border-color: rgba(0,255,249,0.15);
}

.btn-sm {
  padding: 5px 10px;
  font-size: 11px;
  border-radius: var(--radius-xs);
}

/* Icon-only button — no text, just icon with title tooltip */
.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  color: var(--text-light);
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  font-size: 16px;
  position: relative;
}
.btn-icon:hover {
  color: var(--primary);
  border-color: rgba(0,255,249,0.2);
}
.btn-icon:active {
  box-shadow: var(--shadow-inset-sm);
}

/* Action icon — slightly smaller, used in message rows */
.action-icon {
  width: 28px;
  height: 28px;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  border-radius: var(--radius-xs);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition);
  font-size: 14px;
  flex-shrink: 0;
}
.action-icon:hover {
  color: var(--text);
  box-shadow: var(--shadow-sm);
}

/* Buttons with text (limited use) */
.btn-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  border: 1px solid rgba(0,255,249,0.06);
  transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-hover); border-color: rgba(0,255,249,0.12); }


.card-header {
  padding: 12px 16px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-body {
  padding: 16px;
}

/* ---- Forms ---- */
.form-group {
  margin-bottom: 14px;
}

.form-group label {
  display: block;
  margin-bottom: 5px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid rgba(0,255,249,0.1);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text);
  background: var(--bg-input);
  transition: all var(--transition);
  outline: none;
  -webkit-appearance: none;
  font-family: inherit;
}

.form-control:focus {
  border-color: var(--primary);
  box-shadow: var(--glow), inset 0 0 10px rgba(0,255,249,0.03);
}

.form-control::placeholder {
  color: var(--text-muted);
}

.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  cursor: pointer;
}

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

select.form-control {
  appearance: none;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 12 12'%3E%3Cpath fill='%2300fff9' d='M6 9L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 30px;
}

/* ---- Auth Page ---- */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  width: 100%;
  background: var(--bg);
  padding: 16px;
  background-image:
    radial-gradient(ellipse at 30% 40%, rgba(0,255,249,0.04) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 60%, rgba(255,180,0,0.03) 0%, transparent 50%);
}

.auth-box {
  width: 100%;
  max-width: 380px;
  padding: 28px 24px;
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid rgba(0,255,249,0.1);
}

.auth-box h1 {
  text-align: center;
  color: var(--primary);
  margin-bottom: 6px;
  font-size: 20px;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-shadow: var(--glow);
}

.auth-box .subtitle {
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 24px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.auth-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  border-radius: var(--radius-xs);
  overflow: hidden;
  background: var(--bg);
  border: 1px solid rgba(0,255,249,0.06);
  padding: 3px;
}

.auth-tab {
  flex: 1;
  padding: 9px;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  background: transparent;
  border: none;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: all var(--transition);
  border-radius: var(--radius-xs);
}
.auth-tab.active {
  background: rgba(0,255,249,0.08);
  color: var(--primary);
}

.error-message {
  background: var(--danger-soft);
  color: var(--danger);
  padding: 9px 12px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  margin-bottom: 12px;
  display: none;
  font-weight: 500;
  border: 1px solid rgba(255,180,0,0.2);
}
.error-message.show {
  display: block;
}

/* ---- Connections List ---- */
.connections-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.connection-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 220px;
  max-width: 300px;
  padding: 14px 16px;
  cursor: pointer;
  transition: all var(--transition);
  background: var(--bg-card);
  background-image:
    radial-gradient(ellipse at 30% 20%, rgba(57,255,20,0.02) 0%, transparent 60%),
    linear-gradient(160deg, rgba(0,255,249,0.02) 0%, transparent 50%);
  border-radius: var(--radius);
  border: 1px solid rgba(0,255,249,0.06);
}
.connection-card:hover {
  border-color: rgba(0,255,249,0.2);
  box-shadow: var(--shadow-hover);
}
.connection-card.active {
  border-color: var(--primary);
  box-shadow: 0 0 12px rgba(0,255,249,0.1);
}

.connection-card .name {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 2px;
  color: var(--neon-green);
  text-shadow: 0 0 4px rgba(57,255,20,0.2);
}

.connection-card .host {
  font-size: 12px;
  color: var(--neon-green);
  opacity: 0.7;
  margin-bottom: 4px;
}

.connection-card .user {
  font-size: 14px;
  font-weight: 600;
  color: var(--primary);
  text-shadow: 0 0 4px rgba(0,255,249,0.2);
}

.connection-card .actions {
  margin-top: 10px;
  display: flex;
  gap: 6px;
}

/* ---- Folders Panel ---- */
.mail-layout {
  display: flex;
  gap: 0;
  height: calc(100vh - 49px);
}

.folders-panel {
  width: 200px;
  min-width: 200px;
  background: var(--bg-sidebar);
  background-image:
    radial-gradient(ellipse at 50% 100%, rgba(0,255,249,0.03) 0%, transparent 50%),
    linear-gradient(180deg, rgba(0,20,40,0.15) 0%, transparent 60%);
  overflow-y: auto;
  flex-shrink: 0;
  padding: 10px 6px;
  border-right: 1px solid rgba(0,255,249,0.04);
}

.folder-item {
  padding: 7px 10px;
  cursor: pointer;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: all var(--transition);
  border-radius: var(--radius-xs);
  margin-bottom: 2px;
  border-left: 2px solid transparent;
  color: var(--text-light);
}
.folder-item:hover {
  background: rgba(0,255,249,0.03);
  color: var(--text);
}
.folder-item.active {
  background: rgba(0,255,249,0.06);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 600;
}

.folder-item .folder-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.folder-item .folder-count {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: 6px;
  flex-shrink: 0;
}
.folder-item.active .folder-count {
  color: var(--primary);
}

/* ---- Messages Panel ---- */
.messages-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  max-width: 50%;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 80% 30%, rgba(255,180,0,0.02) 0%, transparent 50%),
    radial-gradient(ellipse at 20% 80%, rgba(0,255,249,0.02) 0%, transparent 50%);
  border-right: 1px solid rgba(0,255,249,0.04);
}

.messages-toolbar {
  padding: 8px 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.group-select {
  min-width: 130px;
}

.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 0 4px;
}

/* ---- Email Viewer Panel ---- */
.email-viewer-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow-y: auto;
  padding: 0;
  position: relative;
  background-image:
    radial-gradient(ellipse at 20% 20%, rgba(0,255,249,0.03) 0%, transparent 50%),
    linear-gradient(180deg, rgba(0,20,40,0.1) 0%, transparent 60%);
}
.email-viewer-panel:not(.visible) .viewer-placeholder {
  display: flex;
}
.email-viewer-panel.visible .viewer-placeholder {
  display: none;
}

.viewer-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
  text-align: center;
  padding: 20px;
}

.viewer-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 200px;
  text-align: center;
  padding: 20px;
}

.viewer-header {
  padding: 16px 18px;
  border-bottom: 1px solid rgba(0,255,249,0.06);
  position: relative;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.viewer-subject {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  padding-right: 36px;
  word-break: break-word;
  color: var(--primary);
}

.viewer-meta {
  font-size: 12px;
  color: var(--text-light);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.viewer-meta strong {
  color: var(--text-muted);
  display: inline;
}

.viewer-header .btn-icon {
  position: absolute;
  top: 14px;
  right: 14px;
}

.viewer-body {
  padding: 0;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.viewer-body iframe {
  background: #0f0f1a;
  border-radius: var(--radius-sm);
  padding: 6px;
  border: 1px solid rgba(0,255,249,0.04);
  color: var(--text);
}

/* ---- Message Item Selected ---- */
.message-item.selected {
  background: rgba(0,255,249,0.06);
  border-left: 2px solid var(--primary);
}

.message-item.selected .msg-subject {
  color: var(--primary);
}

/* ---- Groups List ---- */
.group-item {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  margin-bottom: 5px;
  border: 1px solid rgba(0,255,249,0.06);
  transition: all var(--transition);
}
.group-item:hover {
  border-color: rgba(0,255,249,0.15);
  box-shadow: var(--shadow-hover);
}

.group-item .group-label {
  font-weight: 500;
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.group-item .group-count {
  font-size: 10px;
  color: var(--primary);
  margin-left: 10px;
  flex-shrink: 0;
  background: rgba(0,255,249,0.08);
  padding: 1px 7px;
  border-radius: 10px;
  border: 1px solid rgba(0,255,249,0.1);
}

.group-item .group-delete {
  opacity: 0;
  margin-left: 6px;
  transition: opacity var(--transition);
}
.group-item:hover .group-delete {
  opacity: 1;
}

/* ---- Breadcrumb ---- */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 13px;
  color: var(--text-light);
}

.breadcrumb .crumb {
  cursor: pointer;
  color: var(--primary);
  font-weight: 500;
}
.breadcrumb .crumb:hover { text-decoration: underline; }
.breadcrumb .separator { color: var(--text-muted); }
.breadcrumb .current { color: var(--text); font-weight: 600; }

/* ---- Message List ---- */
.message-item {
  display: flex;
  align-items: flex-start;
  gap: 15px;
  padding: 11px 14px;
  cursor: pointer;
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid rgba(0,255,249,0.03);
  margin-bottom: 4px;
  transition: all var(--transition);
}
.message-item:hover {
  border-color: rgba(0,255,249,0.12);
}
.message-item:active {
  border-color: rgba(0,255,249,0.2);
}
.message-item.unread {
  border-left: 2px solid var(--neon-pink);
}
.message-item.unread .msg-subject {
  font-weight: 700;
  color: var(--neon-pink);
}

.msg-sender {
  width: 170px;
  min-width: 170px;
  font-size: 12px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-light);
  border-right: 1px solid rgba(0,255,249,0.12);
  padding-right: 15px;
}

.msg-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.msg-subject {
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

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

.msg-date {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
  margin-top: 2px;
}

.msg-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}


.progress-bar-container {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  margin-bottom: 8px;
  overflow: hidden;
  border: 1px solid rgba(0,255,249,0.06);
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--primary), var(--neon-pink));
  border-radius: 3px;
  transition: width 300ms ease;
  box-shadow: 0 0 8px rgba(0,255,249,0.3);
}

.progress-bar-fill.done { background: var(--success); box-shadow: 0 0 8px rgba(57,255,20,0.3); }
.progress-bar-fill.error { background: var(--danger); box-shadow: 0 0 8px rgba(255,180,0,0.3); }

.progress-status {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 6px;
}

.progress-folders {
  font-size: 11px;
  color: var(--text-light);
}

.progress-folder-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 3px 0;
  font-size: 12px;
}

.progress-folder-icon {
  width: 14px;
  text-align: center;
}

.icon-pending { color: var(--text-muted); }
.icon-syncing { color: var(--primary); animation: spin 1s linear infinite; }
.icon-done { color: var(--success); }
.icon-error { color: var(--danger); }

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

/* ---- Sidebar Section Title ---- */
.sidebar-section-title {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  padding: 12px 10px 4px;
  opacity: 0.5;
}

.connection-nav-item {
  font-size: 12px;
}

/* ---- Custom Tooltip (desktop only) ---- */
@media (hover: hover) and (pointer: fine) {
  .custom-tooltip {
    position: fixed;
    z-index: 500;
    background: var(--bg-card);
    color: var(--neon-green);
    font-size: 12px;
    line-height: 1.4;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(57,255,20,0.2);
    box-shadow: 0 0 20px rgba(57,255,20,0.12);
    max-width: 400px;
    word-wrap: break-word;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s ease;
  }
  .custom-tooltip.visible {
    opacity: 1;
  }
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5,5,10,0.8);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--transition);
  padding: 16px;
}
.modal-overlay.show {
  opacity: 1;
  visibility: visible;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid rgba(0,255,249,0.12);
  box-shadow: 0 0 40px rgba(0,255,249,0.08);
  width: 100%;
  max-width: 460px;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  transform: translateY(16px);
  transition: transform var(--transition);
}
.modal-overlay.show .modal {
  transform: translateY(0);
}

.modal-header {
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 14px;
  color: var(--primary);
  border-bottom: 1px solid rgba(0,255,249,0.06);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.modal-body {
  padding: 0 18px 18px;
}

.modal-footer {
  padding: 12px 18px;
  border-top: 1px solid rgba(0,255,249,0.06);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

/* ---- New Mail Notification Modal ---- */
.new-mail-modal {
  max-width: 420px;
}
.new-mail-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.notification-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  background: var(--bg-input);
  border-radius: 8px;
  border: 1px solid var(--border);
}
.notif-icon {
  font-size: 22px;
  flex-shrink: 0;
}
.notif-info {
  flex: 1;
  min-width: 0;
}
.notif-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.notif-count {
  font-size: 12px;
  color: var(--accent);
  margin-top: 2px;
}
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 16px;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.15s;
}
.modal-close:hover {
  color: var(--text);
  background: var(--bg-input);
}
.btn-small {
  padding: 4px 10px;
  font-size: 11px;
  border-radius: 6px;
  flex-shrink: 0;
}

/* ---- Confirm Dialog ---- */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5,5,10,0.8);
  backdrop-filter: blur(6px);
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.confirm-box {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid rgba(0,255,249,0.12);
  box-shadow: 0 0 40px rgba(0,255,249,0.08);
  width: 100%;
  max-width: 380px;
  padding: 24px;
  text-align: center;
  animation: confirmIn 0.15s ease;
}
@keyframes confirmIn {
  from { transform: translateY(12px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.confirm-box .confirm-icon {
  font-size: 36px;
  margin-bottom: 12px;
}

.confirm-box .confirm-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.confirm-box .confirm-message {
  font-size: 12px;
  color: var(--text-light);
  margin-bottom: 20px;
  line-height: 1.5;
}

.confirm-box .confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.confirm-box .confirm-actions .btn {
  min-width: 100px;
}

/* ---- Toast notifications (replaces alert()) ---- */
.toast-container {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 700;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.toast {
  background: var(--bg-card);
  border: 1px solid rgba(0,255,249,0.12);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font-size: 12px;
  color: var(--text);
  box-shadow: 0 0 20px rgba(0,0,0,0.4);
  pointer-events: auto;
  animation: toastIn 0.2s ease;
  max-width: 340px;
}
.toast.error {
  border-color: rgba(255,180,0,0.3);
  color: var(--danger);
}
.toast.success {
  border-color: rgba(57,255,20,0.3);
  color: var(--success);
}
@keyframes toastIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

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

.empty-state svg {
  width: 56px;
  height: 56px;
  margin-bottom: 14px;
  opacity: 0.3;
}

.empty-state h3 {
  font-size: 16px;
  margin-bottom: 6px;
  color: var(--text);
}

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

/* ---- Loading ---- */
.loading-spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid rgba(0,255,249,0.1);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
  box-shadow: 0 0 6px rgba(0,255,249,0.2);
}

/* ---- Badge ---- */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 600;
}
.badge-primary { background: var(--primary-soft); color: var(--primary); }
.badge-success { background: var(--success-soft); color: var(--success); }
.badge-danger { background: var(--danger-soft); color: var(--danger); }

/* ---- Pagination ---- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 12px;
}

.pagination button {
  padding: 5px 10px;
  border: 1px solid rgba(0,255,249,0.08);
  background: var(--bg-card);
  border-radius: var(--radius-xs);
  cursor: pointer;
  font-size: 11px;
  color: var(--text);
  transition: all var(--transition);
}
.pagination button:hover { border-color: rgba(0,255,249,0.2); color: var(--primary); }
.pagination button:disabled {
  opacity: 0.3;
  cursor: default;
  border-color: transparent;
}
.pagination button.active {
  color: var(--primary);
  background: rgba(0,255,249,0.08);
  border-color: var(--primary);
  text-shadow: 0 0 4px rgba(0,255,249,0.3);
}

.pagination .page-info {
  font-size: 11px;
  color: var(--text-muted);
  margin: 0 6px;
}

/* ---- Message View Modal ---- */
.modal-wide {
  max-width: 780px;
}

.modal-wide .modal-body {
  overflow-y: auto;
  flex: 1;
}

.msg-view-header {
  padding: 12px 0;
  border-bottom: 1px solid rgba(0,255,249,0.06);
  margin-bottom: 14px;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.msg-view-header strong {
  color: var(--text-muted);
}

.msg-view-body {
  padding: 6px 0;
  min-height: 80px;
}

.msg-view-body iframe {
  background: #0f0f1a;
  border-radius: var(--radius-sm);
  padding: 6px;
  border: 1px solid rgba(0,255,249,0.04);
  color: var(--text);
}

/* ---- Attachments ---- */
.attachments-section {
  border-radius: var(--radius-sm);
  padding: 12px;
  margin-bottom: 14px;
  background: var(--bg-input);
  border: 1px solid rgba(0,255,249,0.06);
}

.attachments-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.attachment-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--radius-xs);
  margin-bottom: 6px;
  background: var(--bg-card);
  border: 1px solid rgba(0,255,249,0.04);
  transition: all var(--transition);
}
.attachment-item:hover { border-color: rgba(0,255,249,0.15); }
.attachment-item:last-child { margin-bottom: 0; }

.att-icon { font-size: 18px; flex-shrink: 0; }

.att-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.att-size {
  font-size: 11px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.att-download {
  flex-shrink: 0;
  font-size: 12px;
  text-decoration: none;
}

/* ---- Mobile Panel Header (hidden on desktop) ---- */
.mobile-only { display: none !important; }
.mobile-panel-header {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-card);
  flex-shrink: 0;
  -webkit-user-select: none;
  user-select: none;
}
.mobile-panel-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-white);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.mobile-back-btn {
  background: none;
  border: none;
  color: var(--primary);
  font-size: 20px;
  cursor: pointer;
  padding: 4px 8px;
  flex-shrink: 0;
  line-height: 1;
}
.mobile-back-btn:active {
  opacity: 0.6;
}

/* =============================================
   RESPONSIVE — Full mobile adaptation
   ============================================= */

/* Tablet */
@media (max-width: 1024px) {
  .sidebar { width: 200px; }
  .folders-panel { width: 180px; min-width: 180px; }
  .msg-sender { width: 140px; min-width: 140px; padding-right: 15px; border-right: 1px solid rgba(0,255,249,0.12); }
}

/* Small tablet */
@media (max-width: 768px) {
  .sidebar { width: 180px; }
  .folders-panel { width: 160px; min-width: 160px; }
  .messages-panel { max-width: 45%; }
  .msg-sender { width: 120px; min-width: 120px; padding-right: 15px; border-right: 1px solid rgba(0,255,249,0.12); }
  .main-body { padding: 12px; }
  .message-item { padding: 8px 10px; gap: 15px; }
  .modal { max-width: 95vw; }
  .viewer-subject { font-size: 14px; }
  .viewer-body { padding: 0; }
}

/* Mobile: drill-down navigation (≤1280px) */
@media (max-width: 1280px) {
  /* Layout: sidebar stays on top as tab bar */
  body {
    height: 100vh;
    overflow: hidden;
  }
  #app {
    flex-direction: column;
    height: 100vh;
    min-height: 0;
  }
  .sidebar {
    width: 100%;
    min-height: auto;
    flex-direction: column;
  }
  .sidebar-header {
    padding: 10px 14px;
    font-size: 15px;
    justify-content: center;
  }
  .sidebar-nav {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0 6px;
    gap: 2px;
    -webkit-overflow-scrolling: touch;
  }
  .sidebar-nav .nav-item {
    padding: 8px 12px;
    white-space: nowrap;
    font-size: 12px;
  }
  .sidebar-nav .nav-item.active {
    box-shadow: none;
    border-bottom: 2px solid var(--primary);
  }
  .sidebar-footer { display: none; }
  .sidebar-section-title { display: none; }

  /* Main content: fill remaining space */
  .main-content {
    flex: 1;
    overflow: hidden;
    position: relative;
  }

  /* Mail layout: drill-down panels */
  .mail-layout {
    position: relative;
    height: 100%;
    overflow: hidden;
  }

  /* All panels: absolute position, full-width, hidden by default */
  .folders-panel,
  .messages-panel,
  .email-viewer-panel {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100% !important;
    min-width: 100% !important;
    max-width: 100% !important;
    border-right: none;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    transform: translateX(100%);
    opacity: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Folders panel: visible by default as the leftmost drill-down */
  .folders-panel {
    transform: translateX(0);
    opacity: 1;
    z-index: 2;
  }

  /* Mobile-active panels slide in */
  .folders-panel.mobile-active {
    transform: translateX(0);
    opacity: 1;
    z-index: 2;
  }
  .messages-panel.mobile-active {
    transform: translateX(0);
    opacity: 1;
    z-index: 3;
    display: flex !important;
    flex-direction: column;
  }
  .email-viewer-panel.mobile-active {
    transform: translateX(0);
    opacity: 1;
    z-index: 4;
    display: flex !important;
    flex-direction: column;
    position: absolute;
  }
  /* When viewer is not mobile-active, keep it hidden (override .visible) */
  .email-viewer-panel:not(.mobile-active) {
    display: none !important;
  }

  /* Mobile panel headers visible */
  .mobile-only { display: flex !important; }
  .mobile-panel-header { display: flex; }

  /* Hide resize handles */
  .resize-handle { display: none !important; }

  /* Touch-friendly sizes */
  .folder-item {
    padding: 10px 14px;
    font-size: 13px;
    min-height: 44px;
  }
  .folder-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .message-item {
    padding: 10px 14px;
    gap: 4px;
    min-height: 56px;
    flex-wrap: wrap;
  }
  .msg-sender {
    width: 100%;
    min-width: auto;
    max-width: none;
    font-size: 13px;
    font-weight: 600;
    border-right: none;
    padding-right: 0;
    padding-bottom: 4px;
    border-bottom: 1px solid rgba(0,255,249,0.08);
    margin-bottom: 2px;
  }
  .msg-subject { font-size: 13px; }
  .msg-preview { font-size: 12px; }
  .msg-date { font-size: 11px; }
  .messages-toolbar {
    padding: 8px 12px;
    gap: 8px;
  }

  /* Viewer fills the panel */
  .email-viewer-panel {
    flex-direction: column;
    padding-top: 0;
  }
  .viewer-header { display: none; }
  .viewer-body { padding: 0; }

  /* Hide viewer placeholder on mobile (we use back button instead) */
  .viewer-placeholder { display: none; }

  /* Connections view adjustments */
  .main-body { padding: 10px; }
  .connections-grid { gap: 10px; }
  .connection-card { padding: 14px; }

  /* Toolbar compact */
  .main-header {
    padding: 10px 14px;
    gap: 6px;
    flex-wrap: wrap;
  }
  .main-header h2 { font-size: 14px; }

  /* Group items */
  .group-item {
    padding: 10px 14px;
    min-height: 48px;
  }
}

/* Small phones (≤480px) */
@media (max-width: 480px) {
  .modal {
    max-width: 100%;
    margin: 8px;
    border-radius: 14px;
  }
  .modal-wide { max-width: 100%; }
  .modal-header { padding: 12px 14px; font-size: 14px; }
  .modal-body { padding: 0 14px 14px; }
  .modal-footer { padding: 10px 14px; }

  .auth-box {
    padding: 20px 16px;
    border-radius: 14px;
  }
  .auth-box h1 { font-size: 20px; }
  .form-group { margin-bottom: 12px; }
  .form-control { padding: 8px 10px; font-size: 13px; }

  .viewer-body { padding: 0; }
  .viewer-header { padding: 10px 12px; }

  .attachment-item {
    flex-wrap: wrap;
    gap: 4px;
  }
  .att-name { order: 1; flex-basis: calc(100% - 32px); }
  .att-size { order: 3; }
  .att-download { order: 2; margin-left: auto; }

  .pagination { gap: 3px; padding: 8px; }
  .pagination button { padding: 4px 8px; font-size: 11px; }
}
