/* inbox.css — iOS Mail App Complete Styling */

/* ══════════════════════════════════════════════════════════════
   RESET & BASE
   ══════════════════════════════════════════════════════════════ */
.mail-container {
  font-family: -apple-system, 'SF Pro Text', 'SF Pro Display', system-ui, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #f2f2f7;
  min-height: 100vh;
  color: #000;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  position: relative;
  overflow-x: hidden;
}

.mail-container * {
  box-sizing: border-box;
}

/* ══════════════════════════════════════════════════════════════
   ICONS
   ══════════════════════════════════════════════════════════════ */
.mail-ico {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mail-ico svg,
.mail-container svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════════════
   NAVIGATION BAR
   ══════════════════════════════════════════════════════════════ */
.mail-navbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 8px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 0.5px solid rgba(60,60,67,0.12);
  position: sticky;
  top: 0;
  z-index: 100;
}

.mail-nav-back {
  display: flex;
  align-items: center;
  gap: 2px;
  background: none;
  border: none;
  color: #007aff;
  font-size: 17px;
  cursor: pointer;
  padding: 8px 4px;
  min-width: 44px;
  -webkit-tap-highlight-color: transparent;
}

.mail-nav-back svg {
  width: 22px;
  height: 22px;
}

.mail-nav-back span {
  font-size: 17px;
}

.mail-nav-title {
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 0 8px;
}

.mail-nav-action {
  background: none;
  border: none;
  color: #007aff;
  cursor: pointer;
  padding: 8px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.mail-nav-action svg {
  width: 22px;
  height: 22px;
}

.mail-nav-send {
  background: none;
  border: none;
  color: #007aff;
  cursor: pointer;
  padding: 8px;
  min-width: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
}

.mail-nav-send svg {
  width: 24px;
  height: 24px;
}

/* ══════════════════════════════════════════════════════════════
   LARGE HEADER (Mailboxes screen)
   ══════════════════════════════════════════════════════════════ */
.mail-header-lg {
  padding: 8px 16px 4px;
  background: rgba(255,255,255,0.92);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  position: sticky;
  top: 0;
  z-index: 100;
}

.mail-header-lg h1 {
  font-size: 34px;
  font-weight: 700;
  letter-spacing: -0.5px;
  margin: 0;
  padding: 0;
}

/* ══════════════════════════════════════════════════════════════
   SECTIONS (Mailboxes groups)
   ══════════════════════════════════════════════════════════════ */
.mail-section {
  background: #fff;
  border-radius: 10px;
  margin: 12px 16px;
  overflow: hidden;
}

.mail-section-title {
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  color: #8e8e93;
  padding: 24px 16px 8px;
  letter-spacing: 0.2px;
  background: transparent;
}

.mail-section:first-of-type .mail-section-title {
  padding-top: 16px;
}

/* ══════════════════════════════════════════════════════════════
   MAILBOX ROWS
   ══════════════════════════════════════════════════════════════ */
.mail-mailbox-row {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 0.5px solid rgba(60,60,67,0.12);
  -webkit-tap-highlight-color: transparent;
}

.mail-mailbox-row:last-child {
  border-bottom: none;
}

.mail-mailbox-row:active {
  background: #e5e5ea;
}

.mail-mailbox-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  flex-shrink: 0;
  color: #fff;
}

.mail-mailbox-icon svg {
  width: 18px;
  height: 18px;
}

.mail-mailbox-label {
  flex: 1;
  font-size: 17px;
}

/* Badge */
.mail-badge {
  background: #007aff;
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  min-width: 22px;
  height: 22px;
  line-height: 22px;
  text-align: center;
  border-radius: 11px;
  padding: 0 7px;
  margin-right: 6px;
}

/* Chevron */
.mail-chevron-sm {
  color: #c7c7cc;
  display: flex;
  align-items: center;
}

.mail-chevron-sm svg {
  width: 16px;
  height: 16px;
}

/* ══════════════════════════════════════════════════════════════
   ACCOUNT ROWS
   ══════════════════════════════════════════════════════════════ */
.mail-account-row {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 0.5px solid rgba(60,60,67,0.12);
  -webkit-tap-highlight-color: transparent;
}

.mail-account-row:active {
  background: #e5e5ea;
}

.mail-account-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  margin-right: 12px;
  flex-shrink: 0;
}

.mail-account-info {
  flex: 1;
  min-width: 0;
}

.mail-account-name {
  font-size: 17px;
  font-weight: 400;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-account-email {
  font-size: 13px;
  color: #8e8e93;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mail-account-unread {
  margin-right: 6px;
}

.mail-chevron {
  color: #c7c7cc;
  display: flex;
  align-items: center;
  transition: transform 0.2s;
}

.mail-chevron svg {
  width: 18px;
  height: 18px;
}

.mail-chevron.open {
  transform: rotate(90deg);
}

/* Account sub-folders */
.mail-account-folders {
  background: #f9f9fb;
}

.mail-folder-row {
  display: flex;
  align-items: center;
  padding: 10px 16px 10px 60px;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 0.5px solid rgba(60,60,67,0.12);
  -webkit-tap-highlight-color: transparent;
}

.mail-folder-row:last-child {
  border-bottom: none;
}

.mail-folder-row:active {
  background: #e5e5ea;
}

.mail-folder-ico {
  display: flex;
  align-items: center;
  margin-right: 10px;
}

.mail-folder-ico svg {
  width: 18px;
  height: 18px;
}

.mail-folder-name {
  flex: 1;
  font-size: 16px;
}

/* ══════════════════════════════════════════════════════════════
   SEARCH BAR
   ══════════════════════════════════════════════════════════════ */
.mail-search-wrap {
  padding: 8px 16px;
  background: #f2f2f7;
}

.mail-search {
  display: flex;
  align-items: center;
  background: rgba(118,118,128,0.12);
  border-radius: 10px;
  padding: 0 10px;
  height: 36px;
}

.mail-search-ico {
  color: #8e8e93;
  display: flex;
  align-items: center;
  margin-right: 6px;
}

.mail-search-ico svg {
  width: 16px;
  height: 16px;
}

.mail-search-input {
  flex: 1;
  border: none;
  background: none;
  font-size: 17px;
  color: #000;
  outline: none;
  font-family: inherit;
}

.mail-search-input::placeholder {
  color: #8e8e93;
}

/* ══════════════════════════════════════════════════════════════
   LIST SUBTITLE
   ══════════════════════════════════════════════════════════════ */
.mail-list-subtitle {
  font-size: 13px;
  color: #8e8e93;
  padding: 4px 20px 8px;
  text-transform: uppercase;
  font-weight: 600;
  letter-spacing: 0.2px;
}

/* ══════════════════════════════════════════════════════════════
   MESSAGE LIST
   ══════════════════════════════════════════════════════════════ */
.mail-messages {
  background: #fff;
}

.mail-msg {
  display: flex;
  align-items: flex-start;
  padding: 12px 16px 12px 0;
  cursor: pointer;
  transition: background 0.15s;
  border-bottom: 0.5px solid rgba(60,60,67,0.12);
  -webkit-tap-highlight-color: transparent;
}

.mail-msg:last-child {
  border-bottom: none;
}

.mail-msg:active {
  background: #e5e5ea;
}

/* Unread dot area */
.mail-msg-dot-area {
  width: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding-top: 6px;
  flex-shrink: 0;
}

.mail-unread-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #007aff;
}

/* Avatar */
.mail-msg-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  margin-right: 12px;
  flex-shrink: 0;
}

/* Content */
.mail-msg-content {
  flex: 1;
  min-width: 0;
}

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

.mail-msg-sender {
  font-size: 16px;
  color: #000;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.mail-msg-sender.bold {
  font-weight: 600;
}

.mail-msg-date {
  font-size: 14px;
  color: #8e8e93;
  white-space: nowrap;
  margin-left: 8px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.mail-msg-date svg {
  width: 14px;
  height: 14px;
  color: #c7c7cc;
}

.mail-msg-subject {
  font-size: 14px;
  color: #333;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-bottom: 1px;
}

.mail-msg-subject.bold {
  font-weight: 600;
  color: #000;
}

.mail-msg-preview {
  font-size: 14px;
  color: #8e8e93;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ══════════════════════════════════════════════════════════════
   PAGINATION
   ══════════════════════════════════════════════════════════════ */
.mail-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  gap: 16px;
}

.mail-page-btn {
  background: none;
  border: 1.5px solid #007aff;
  color: #007aff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.mail-page-btn:disabled {
  border-color: #c7c7cc;
  color: #c7c7cc;
  cursor: default;
}

.mail-page-btn svg {
  width: 16px;
  height: 16px;
}

.mail-page-info {
  font-size: 14px;
  color: #8e8e93;
}

/* ══════════════════════════════════════════════════════════════
   FAB (Floating Action Button)
   ══════════════════════════════════════════════════════════════ */
.mail-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #007aff;
  color: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,122,255,0.4);
  z-index: 200;
  transition: transform 0.15s, box-shadow 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.mail-fab:active {
  transform: scale(0.92);
  box-shadow: 0 2px 8px rgba(0,122,255,0.3);
}

.mail-fab svg {
  width: 24px;
  height: 24px;
}

/* ══════════════════════════════════════════════════════════════
   DETAIL SCREEN
   ══════════════════════════════════════════════════════════════ */
.mail-detail-screen {
  background: #fff;
  padding-bottom: 60px;
}

.mail-detail-header {
  padding: 16px;
  border-bottom: 0.5px solid rgba(60,60,67,0.12);
}

.mail-detail-from {
  display: flex;
  align-items: center;
  margin-bottom: 12px;
}

.mail-detail-avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  margin-right: 12px;
  flex-shrink: 0;
}

.mail-detail-from-info {
  flex: 1;
  min-width: 0;
}

.mail-detail-sender {
  font-size: 17px;
  font-weight: 600;
}

.mail-detail-email {
  font-size: 14px;
  color: #8e8e93;
}

.mail-detail-date {
  font-size: 14px;
  color: #8e8e93;
  white-space: nowrap;
}

.mail-detail-to {
  font-size: 14px;
  color: #8e8e93;
  margin-bottom: 12px;
}

.mail-detail-to strong {
  color: #000;
  font-weight: 500;
}

.mail-detail-subject {
  font-size: 22px;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 4px;
}

.mail-detail-fulldate {
  font-size: 13px;
  color: #8e8e93;
}

/* Body */
.mail-detail-body {
  padding: 0;
  min-height: 200px;
}

.mail-body-iframe {
  width: 100%;
  min-height: 300px;
  border: none;
  display: block;
}

.mail-body-text {
  padding: 16px;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-wrap: break-word;
  margin: 0;
}

/* ══════════════════════════════════════════════════════════════
   TOOLBAR (bottom of detail)
   ══════════════════════════════════════════════════════════════ */
.mail-toolbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 50px;
  background: rgba(255,255,255,0.95);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-top: 0.5px solid rgba(60,60,67,0.12);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 200;
}

.mail-tb-btn {
  background: none;
  border: none;
  color: #007aff;
  cursor: pointer;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  -webkit-tap-highlight-color: transparent;
  border-radius: 8px;
  transition: background 0.15s;
}

.mail-tb-btn:active {
  background: rgba(0,122,255,0.1);
}

.mail-tb-btn svg {
  width: 22px;
  height: 22px;
}

.mail-tb-btn.danger {
  color: #ff3b30;
}

.mail-tb-btn.danger:active {
  background: rgba(255,59,48,0.1);
}

/* ══════════════════════════════════════════════════════════════
   COMPOSE SCREEN
   ══════════════════════════════════════════════════════════════ */
.mail-compose-screen {
  background: #fff;
  min-height: 100vh;
}

.mail-compose-fields {
  border-bottom: 0.5px solid rgba(60,60,67,0.12);
}

.mail-compose-row {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 0.5px solid rgba(60,60,67,0.12);
}

.mail-compose-row:last-child {
  border-bottom: none;
}

.mail-compose-label {
  width: 60px;
  font-size: 16px;
  color: #8e8e93;
  flex-shrink: 0;
}

.mail-compose-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px;
  font-family: inherit;
  color: #000;
  background: transparent;
}

.mail-compose-input::placeholder {
  color: #c7c7cc;
}

.mail-compose-select {
  flex: 1;
  border: none;
  outline: none;
  font-size: 16px;
  font-family: inherit;
  color: #007aff;
  background: transparent;
  -webkit-appearance: none;
  cursor: pointer;
}

.mail-compose-body {
  width: 100%;
  min-height: 300px;
  border: none;
  outline: none;
  resize: none;
  font-size: 16px;
  font-family: inherit;
  line-height: 1.5;
  color: #000;
  padding: 16px;
}

.mail-compose-body::placeholder {
  color: #c7c7cc;
}

/* ══════════════════════════════════════════════════════════════
   LOADING & EMPTY STATES
   ══════════════════════════════════════════════════════════════ */
.mail-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  gap: 12px;
  color: #8e8e93;
  font-size: 15px;
}

.mail-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid #e5e5ea;
  border-top-color: #007aff;
  border-radius: 50%;
  animation: mail-spin 0.7s linear infinite;
}

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

.mail-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
}

.mail-empty-ico {
  color: #c7c7cc;
  margin-bottom: 12px;
}

.mail-empty-ico svg {
  width: 56px;
  height: 56px;
}

.mail-empty-text {
  font-size: 18px;
  color: #8e8e93;
  font-weight: 500;
}

/* ══════════════════════════════════════════════════════════════
   TOAST
   ══════════════════════════════════════════════════════════════ */
.mail-toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,0.8);
  color: #fff;
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 15px;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}

.mail-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ══════════════════════════════════════════════════════════════
   ANIMATIONS
   ══════════════════════════════════════════════════════════════ */
.mail-screen {
  animation: mail-fadeIn 0.2s ease;
}

@keyframes mail-fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.mail-detail-screen,
.mail-compose-screen {
  animation: mail-slideIn 0.25s ease;
}

@keyframes mail-slideIn {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */

/* Tablet */
@media (min-width: 768px) {
  .mail-container {
    max-width: 800px;
    margin: 0 auto;
  }

  .mail-fab {
    bottom: 32px;
    right: calc(50% - 400px + 24px);
  }

  .mail-toolbar {
    max-width: 800px;
    margin: 0 auto;
    left: auto;
    right: auto;
  }
}

/* Desktop hover states */
@media (hover: hover) {
  .mail-mailbox-row:hover {
    background: #f2f2f7;
  }

  .mail-account-row:hover {
    background: #f2f2f7;
  }

  .mail-folder-row:hover {
    background: #e5e5ea;
  }

  .mail-msg:hover {
    background: #f9f9fb;
  }

  .mail-tb-btn:hover {
    background: rgba(0,122,255,0.08);
  }

  .mail-tb-btn.danger:hover {
    background: rgba(255,59,48,0.08);
  }

  .mail-fab:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0,122,255,0.5);
  }

  .mail-page-btn:hover:not(:disabled) {
    background: #007aff;
    color: #fff;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .mail-screen,
  .mail-detail-screen,
  .mail-compose-screen {
    animation: none;
  }

  .mail-spinner {
    animation-duration: 1.5s;
  }
}

/* ══════════════════════════════════════════════════════════════
   OVERRIDE: Ensure container fills parent
   ══════════════════════════════════════════════════════════════ */
.mail-mailboxes {
  padding-bottom: 80px;
}

.mail-list-screen {
  padding-bottom: 80px;
  background: #f2f2f7;
}

.mail-list-screen .mail-messages {
  border-radius: 0;
}
