/* BNIX Webmail - Custom Styles */

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  margin: 0;
  padding: 0;
  overflow: hidden;
  height: 100dvh;
  /* Prevent iOS Safari auto-scroll on input focus */
  overscroll-behavior: none;
}

#app {
  height: 100dvh;
  overflow: hidden;
}

/* Prevent iOS Safari from auto-scrolling and zooming on input focus */
input, textarea, [contenteditable] {
  font-size: 16px !important;
  touch-action: manipulation;
  -webkit-user-select: text;
  user-select: text;
  /* Disable tap highlight on mobile so touching inputs doesn't flash a highlight */
  -webkit-tap-highlight-color: transparent;
}

/* Email HTML content */
.email-html {
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.5;
}
.email-html img { max-width: 100%; height: auto; }
.email-html table { max-width: 100%; }
.email-html a { color: #2563eb; text-decoration: underline; }

/* Compose editor */
.compose-editor {
  outline: none;
  min-height: 300px;
  padding: 12px;
  line-height: 1.6;
  font-size: 14px;
}
.compose-editor:empty::before {
  content: attr(data-placeholder);
  color: #94a3b8;
  pointer-events: none;
}
.compose-editor img {
  max-width: 100%;
  height: auto;
}

/* Signature editor */
.signature-mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid #cbd5e1;
  border-radius: 8px;
  background: #f8fafc;
}
.signature-mode-btn {
  height: 28px;
  padding: 0 10px;
  border-radius: 6px;
  font-size: 13px;
  color: #475569;
}
.signature-mode-btn:hover {
  background: #e2e8f0;
}
.signature-mode-btn.active {
  background: #fff;
  color: #1e40af;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12);
}
.signature-image-btn.is-uploading {
  opacity: 0.6;
  cursor: wait;
}
.signature-editor {
  outline: none;
  min-height: 200px;
  padding: 12px;
  line-height: 1.5;
  font-size: 14px;
}
.signature-editor img {
  max-width: 100%;
  height: auto;
}
.signature-editor:empty::before {
  content: attr(data-placeholder);
  color: #94a3b8;
  pointer-events: none;
}
.signature-html-source {
  display: block;
  width: 100%;
  min-height: 220px;
  padding: 12px;
  border: 0;
  outline: none;
  resize: vertical;
  font: 13px/1.55 ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  color: #0f172a;
  background: #fff;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* Message list item transitions */
.msg-item {
  transition: background-color 0.1s ease;
  cursor: pointer;
}

/* Sidebar transition */
.sidebar-panel {
  transition: width 0.2s ease;
}

/* Mobile sidebar overlay */
.mobile-overlay {
  transition: opacity 0.2s ease;
}
.mobile-panel {
  transition: transform 0.25s ease;
}

/* Compose modal */
.compose-modal {
  animation: slideUp 0.2s ease;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* Toast notification */
.toast {
  animation: fadeIn 0.3s ease, fadeOut 0.3s ease 1.5s;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeOut { from { opacity: 1; } to { opacity: 0; } }

/* Recipient chip */
.recipient-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 9999px;
  font-size: 13px;
  line-height: 1.4;
}
.recipient-chip.valid { background: #dcfce7; color: #166534; }
.recipient-chip.invalid { background: #fee2e2; color: #991b1b; }

/* Recipient input — must be relative so the suggestions dropdown positions correctly */
.recipient-input { position: relative; }

/* Contact suggestions dropdown */
.contact-suggestions { box-shadow: 0 4px 12px rgba(0,0,0,0.12); }
.contact-suggestion-row { border-bottom: 1px solid #f1f5f9; }
.contact-suggestion-row:last-child { border-bottom: none; }

/* Attachment item */
.attachment-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  font-size: 13px;
}

/* Rich text toolbar button */
.toolbar-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  border: none;
  background: transparent;
  cursor: pointer;
  color: #475569;
}
.toolbar-btn:hover { background: #e2e8f0; }
.toolbar-btn.active { background: #dbeafe; color: #2563eb; }

/* Quick reply rich editor */
.qr-rich-wrap .qr-toolbar {
  border-bottom: 1px solid #f1f5f9;
  padding: 4px 6px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
}
.qr-editor {
  outline: none;
  display: block;
  width: 100%;
  min-height: 72px;
}
.qr-attach-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding: 6px 10px;
  border-top: 1px solid #f1f5f9;
}
.qr-attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: #f1f5f9;
  border-radius: 6px;
  font-size: 12px;
  color: #475569;
  max-width: 180px;
}
.qr-attach-chip .qr-attach-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.qr-attach-chip button {
  background: none;
  border: none;
  cursor: pointer;
  color: #94a3b8;
  font-size: 14px;
  line-height: 1;
  padding: 0;
}
.qr-attach-chip button:hover { color: #ef4444; }

/* Folder item */
.folder-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  color: #475569;
  transition: all 0.1s ease;
  white-space: nowrap;
  overflow: hidden;
}
.folder-item:hover { background: #f1f5f9; }
.folder-item.active { background: #dbeafe; color: #1d4ed8; font-weight: 500; }

/* Avatar */
.avatar-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  font-weight: 600;
  color: white;
  overflow: hidden;
  flex-shrink: 0;
}
.avatar-badge img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Loading spinner */
.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 9999px;
  animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Calendar grid */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background: #e2e8f0;
}
.cal-grid > div {
  background: white;
  min-height: 80px;
  padding: 4px;
}
.cal-grid .cal-day-header {
  background: #f8fafc;
  min-height: auto;
  padding: 8px 4px;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
}

/* Event dot */
.event-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background: #3b82f6;
}

/* Responsive helpers */
@media (max-width: 768px) {
  .desktop-only { display: none !important; }
}
@media (min-width: 769px) {
  .mobile-only { display: none !important; }
}

/* Mobile FAB compose button */
.fab-compose {
  position: fixed;
  bottom: 100px;
  right: 24px;
  z-index: 30;
  width: 56px;
  height: 56px;
  border-radius: 9999px;
  background: #284f7d;
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(40, 79, 125, 0.4);
  transition: transform 0.15s ease, background 0.15s ease;
}
@media (min-width: 769px) {
  .fab-compose { bottom: 24px; }
}
.fab-compose:hover {
  background: #3d83bd;
  transform: scale(1.06);
}
.fab-compose:active {
  transform: scale(0.95);
}
.fab-compose svg {
  width: 22px;
  height: 22px;
}

/* Thread view bubbles */
.thread-bubble {
  transition: box-shadow 0.15s ease;
}
.thread-bubble:hover {
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

/* ─── Login Page ────────────────────────────────────────────────────────────── */

.login-page {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* Left panel: background */
.login-panel-left {
  flex: 1;
  position: relative;
  background-color: rgb(237, 248, 255);
  background-image: url("/brand/mail-view.png");
  background-size: cover;
  background-position: center center;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Right panel: form */
.login-panel-right {
  flex: 0 0 45%;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  background: #fff;
  padding: 20px;
}

.login-right-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* Center wrapper: topbar + form, vertically centered */
.login-center {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  width: 100%;
  max-width: 500px;
}

/* Language flag images */
.login-flag-img {
  width: 24px;
  height: 16px;
  border-radius: 3px;
  object-fit: cover;
  display: block;
}

/* Top bar */
.login-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 32px;
  flex-shrink: 0;
  width: 100%;
  max-width: 500px;
}

/* Language group */
.login-lang-group {
  display: flex;
  gap: 4px;
}
.login-lang-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  cursor: pointer;
  transition: opacity 0.15s ease;
  padding: 2px;
}
.login-lang-btn:hover { opacity: 0.7; }
.login-lang-btn.active {
  opacity: 1;
}
.login-flag-img {
  display: block;
  width: 24px;
  height: 16px;
  border-radius: 3px;
  object-fit: cover;
}
.login-flag { font-size: 16px; line-height: 1; }

/* Theme toggle */
.login-theme-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 8px;
  background: #f1f5f9;
  color: #64748b;
  cursor: pointer;
  transition: all 0.15s ease;
}
.login-theme-btn:hover { background: #e2e8f0; color: #334155; }

/* Brand section */
.login-brand {
  text-align: center;
  padding: 32px 32px 16px;
  flex-shrink: 0;
}
.login-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 56px;
  border-radius: 14px;
  background: linear-gradient(135deg, #284f7d, #3d83bd);
  color: #fff;
  margin-bottom: 12px;
  box-shadow: 0 4px 12px rgba(40, 79, 125, 0.3);
}
.login-title {
  font-size: 20px;
  font-weight: 700;
  color: #1e293b;
  margin: 0;
  letter-spacing: 2px;
}
.login-subtitle {
  font-size: 13px;
  color: #94a3b8;
  margin: 2px 0 0;
}

/* Form */
.login-form {
  width: 100%;
  padding: 0 32px 32px;
}

/* Field */
.login-field {
  margin-bottom: 14px;
}
.login-field label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.login-field input {
  width: 100%;
  padding: 10px 12px;
  border: 1.5px solid #dde3ea;
  border-radius: 8px;
  font-size: 14px;
  color: #1e293b;
  background: #fff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
}
.login-field input:focus {
  border-color: #284f7d;
  box-shadow: 0 0 0 3px rgba(40, 79, 125, 0.1);
}
.login-field input::placeholder { color: #b0bac6; }

/* Remember checkbox */
.login-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: #64748b;
  cursor: pointer;
  margin-bottom: 16px;
  user-select: none;
}
.login-remember input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #284f7d;
  cursor: pointer;
}

/* Error message */
.login-error {
  padding: 10px 12px;
  margin-bottom: 14px;
  border-radius: 8px;
  background: #fef2f2;
  color: #dc2626;
  font-size: 13px;
  border: 1px solid #fecaca;
}

/* Submit button */
.login-submit {
  width: 100%;
  padding: 11px;
  border: none;
  border-radius: 10px;
  background: linear-gradient(135deg, #284f7d, #3d83bd);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s ease, transform 0.1s ease;
  box-shadow: 0 2px 8px rgba(40, 79, 125, 0.3);
}
.login-submit:hover { opacity: 0.92; }
.login-submit:active { transform: scale(0.985); }

/* Advanced settings */
.login-advanced {
  margin-top: 18px;
  border-top: 1px solid #f1f5f9;
  padding-top: 14px;
}
.login-advanced-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: #94a3b8;
  font-size: 12px;
  cursor: pointer;
  padding: 0;
  transition: color 0.15s ease;
}
.login-advanced-toggle:hover { color: #64748b; }
.login-advanced-toggle svg { transition: transform 0.2s ease; }

.login-advanced-fields {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.2s ease;
  opacity: 0;
}
.login-advanced-fields.open {
  max-height: 500px;
  opacity: 1;
  margin-top: 10px;
}
.login-advanced-hint {
  font-size: 11px;
  color: #94a3b8;
  margin: 0 0 10px;
}
.login-advanced-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.login-advanced-grid input {
  padding: 8px 10px;
  border: 1.5px solid #dde3ea;
  border-radius: 7px;
  font-size: 13px;
  color: #1e293b;
  background: #fff;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.login-advanced-grid input:focus {
  border-color: #284f7d;
  box-shadow: 0 0 0 3px rgba(40, 79, 125, 0.1);
}
.login-advanced-grid input::placeholder { color: #b0bac6; font-size: 12px; }

/* ─── Responsive: hide screenshot on mobile ─────────────────────────────── */
@media (max-width: 768px) {
  .login-page { flex-direction: column; }
  .login-panel-left { display: none; }
  .login-panel-right {
    flex: 1;
    width: 100%;
    max-width: 100%;
    padding: 12px;
  }
  .login-topbar {
    padding: 8px 12px;
    max-width: 100%;
  }
  .login-form {
    padding: 0 12px 24px;
  }
  .login-advanced-toggle {
    font-size: 11px;
  }
  .login-advanced-grid {
    grid-template-columns: 1fr;
  }
}
