/* ==============================================================================
   onesimus.tech User-Facing Mailbox Stylesheet
   Obsidian & Crimson Dark Theme System & Responsive Master-Detail Layout
   ============================================================================== */

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

:root {
  --bg-primary: #09090b;
  --bg-secondary: #0c0c0f;
  --bg-card: #121217;
  --border-color: #27272a;
  --accent-rose: #e11d48;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background-color: var(--bg-primary);
  color: #f4f4f5;
  -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbars */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: #09090b;
}

::-webkit-scrollbar-thumb {
  background: #27272a;
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: #3f3f46;
}

/* Native Dialog Enhancements */
dialog:not([open]) {
  display: none !important;
}

dialog {
  max-height: 90vh;
}

dialog::backdrop {
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

dialog[open] {
  display: flex !important;
  flex-direction: column;
  animation: modal-fade-in 0.15s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes modal-fade-in {
  from {
    opacity: 0;
    transform: scale(0.96) translateY(8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Hide native details disclosure triangles */
details > summary {
  list-style: none;
}
details > summary::-webkit-details-marker {
  display: none;
}
details summary::-moz-list-bullet {
  list-style-type: none;
}

/* Smooth details transitions */
details[open] > summary {
  margin-bottom: 0.25rem;
}

/* Navigation active state */
.folder-nav-btn.active {
  background-color: rgba(225, 29, 72, 0.15);
  color: #ffffff;
  border: 1px solid rgba(225, 29, 72, 0.35);
}

.folder-nav-btn.active i {
  color: #f43f5e;
}

/* Desktop Sidebar Collapsed Rail Mode */
.sidebar-collapsed {
  width: 4.5rem !important; /* 72px */
}

.sidebar-collapsed .sidebar-label {
  display: none !important;
}

.sidebar-collapsed #btn-open-compose {
  padding: 0.625rem !important;
  justify-content: center !important;
  width: 2.75rem !important;
  height: 2.75rem !important;
  margin: 0 auto !important;
  border-radius: 0.75rem !important;
}

.sidebar-collapsed #btn-open-compose .sidebar-label {
  display: none !important;
}

.sidebar-collapsed .folder-nav-btn {
  justify-content: center !important;
  padding: 0.625rem 0 !important;
  position: relative !important;
}

.sidebar-collapsed .folder-nav-btn .sidebar-badge {
  position: absolute !important;
  top: 4px !important;
  right: 10px !important;
  font-size: 0 !important;
  width: 8px !important;
  height: 8px !important;
  min-width: 8px !important;
  padding: 0 !important;
  border-radius: 9999px !important;
  border: 1px solid rgba(225, 29, 72, 0.6) !important;
}

.sidebar-collapsed details summary {
  justify-content: center !important;
}

.sidebar-collapsed details summary .sidebar-label {
  display: none !important;
}

.sidebar-collapsed #quota-bar {
  display: none !important;
}

/* Mobile Off-Canvas Drawer Styles */
@media (max-width: 767px) {
  #mailbox-sidebar.drawer-open {
    transform: translateX(0) !important;
  }

  #sidebar-backdrop.active {
    display: block !important;
    opacity: 1 !important;
  }
}

/* Desktop Reader Focus / Full-Width Mode */
.reader-focused #pane-message-list {
  display: none !important;
}

.reader-focused #mailbox-sidebar {
  display: none !important;
}

/* Message List items */
.message-list-item {
  transition: all 0.12s ease;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.message-list-item:hover {
  background-color: rgba(24, 24, 27, 0.75);
}

.message-list-item.active {
  background-color: rgba(39, 39, 42, 0.75);
  border-left: 3px solid #e11d48;
}

.message-list-item.unread .item-subject {
  font-weight: 700;
  color: #ffffff;
}

.message-list-item.unread .item-sender {
  font-weight: 600;
  color: #ffffff;
}

/* Prose for email viewing */
.prose {
  color: #d4d4d8;
}

.prose p {
  margin-top: 0.75em;
  margin-bottom: 0.75em;
}

.prose code {
  color: #f43f5e;
  background: #18181b;
  padding: 0.15em 0.35em;
  border-radius: 0.25rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.85em;
}

/* Toast animations */
.toast-notice {
  animation: toast-in 0.2s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Mobile Touch Target and Viewport optimizations */
@media (max-width: 640px) {
  button, input, select, textarea {
    font-size: 16px; /* Prevents auto-zoom on iOS Safari when tapping inputs */
  }

  .folder-nav-btn {
    min-height: 40px;
  }
}
