/* ── Base ── */
html { font-size: 13px; }
html, body { height: 100%; margin: 0; overflow: hidden; }
body { background: #fff; color: #1a1a1a; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }

/* ── Remove all Bootstrap shadows & rounded corners globally ── */
*, *::before, *::after { box-shadow: none !important; }
.card, .btn, .form-control, .form-select, .form-check-input,
.dropdown-menu, .modal-content, .alert, .badge, .nav-link {
  border-radius: 0 !important;
}

/* ── Focus ring — subtle gray instead of blue glow ── */
.btn:focus, .form-control:focus, .form-select:focus, .form-check-input:focus {
  outline: 1px solid #ccc;
  box-shadow: none !important;
}

/* ── Override Bootstrap primary to only show on explicit CTAs ── */
.btn-primary { background: #007aff; border-color: #007aff; color: #fff; }
.btn-primary:hover { background: #0063d1; border-color: #0063d1; }
.btn-outline-secondary { color: #555; border-color: #d0d0d0; background: #fff; }
.btn-outline-secondary:hover { background: #f5f5f5; color: #333; border-color: #bbb; }
.btn-outline-danger { color: #c00; border-color: #dcc; background: #fff; }
.btn-outline-danger:hover { background: #fef0f0; }

/* ── SPA Shell Grid ── */
.app-shell {
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: 220px 1fr;
  height: 100vh;
}
.app-topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 42px;
  padding: 0 12px;
  border-bottom: 1px solid #e0e0e0;
  background: #fff;
  z-index: 10;
}
.app-sidebar {
  grid-row: 2;
  grid-column: 1;
  border-right: 1px solid #e0e0e0;
  background: #fafafa;
  overflow-y: auto;
  padding: 8px 0;
}
.app-content {
  grid-row: 2;
  grid-column: 2;
  overflow-y: auto;
  background: #fff;
}

/* ── Topbar ── */
.app-topbar .brand { display: flex; align-items: center; gap: 6px; font-weight: 600; font-size: 14px; color: #1a1a1a; text-decoration: none; }
.app-topbar .brand img { width: 22px; height: 22px; }
.app-topbar .user-info { display: flex; align-items: center; gap: 10px; font-size: 12px; color: #666; }
.app-topbar .user-info button, .app-topbar .user-info a { font-size: 12px; padding: 2px 10px; }
.mobile-menu-btn {
  display: none;
  border: 1px solid #d0d0d0;
  background: #fff;
  color: #333;
  width: 30px;
  height: 28px;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 42px 0 0 0;
  background: rgba(0, 0, 0, 0.2);
  border: 0;
  margin: 0;
  padding: 0;
  z-index: 19;
}

/* ── Sidebar ── */
.sidebar-section { padding: 6px 10px; font-size: 10px; text-transform: uppercase; letter-spacing: .5px; color: #999; font-weight: 600; }
.sidebar-btn {
  display: block;
  width: calc(100% - 16px);
  margin: 0 8px 6px;
  padding: 5px 10px;
  font-size: 12px;
}
.sidebar-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 5px 14px;
  font-size: 12.5px;
  color: #333;
  cursor: pointer;
  text-decoration: none;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.sidebar-item:hover { background: #eee; }
.sidebar-item.active { background: #e0e0e0; font-weight: 600; }
.sidebar-item .badge {
  font-size: 10px;
  padding: 1px 6px;
  background: #999;
  color: #fff;
  font-weight: 500;
}
.sidebar-item.active .badge { background: #555; }
.sidebar-nav-link {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 14px;
  font-size: 12.5px;
  color: #555;
  text-decoration: none;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.sidebar-nav-link:hover { background: #eee; color: #111; }
.sidebar-nav-link.active { background: #e0e0e0; font-weight: 600; color: #111; }
.sidebar-nav-link i { font-size: 13px; width: 18px; text-align: center; }
.sidebar-divider { border-top: 1px solid #e0e0e0; margin: 6px 0; }

/* ── Message list ── */
.list-scroll { width: 100%; overflow-x: auto; overflow-y: hidden; }
.msg-list { width: 100%; min-width: 760px; border-collapse: collapse; table-layout: fixed; }
.msg-list tr { border-bottom: 1px solid #f0f0f0; cursor: pointer; }
.msg-list tr:hover { background: #f8f8f8; }
.msg-list tr.active { background: #e8f0fe; }
.msg-list td { padding: 6px 10px; font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.msg-list .msg-from { width: 200px; font-weight: 500; }
.msg-list .msg-subject { font-weight: 400; color: #333; }
.msg-list .msg-subject .preview { color: #999; font-weight: 300; }
.msg-list .msg-date { width: 140px; text-align: right; color: #888; font-size: 11.5px; }
.msg-list .msg-flag { width: 48px; text-align: center; font-size: 11px; }
.msg-list tr.unread .msg-from,
.msg-list tr.unread .msg-subject { font-weight: 600; }

/* ── Content panels ── */
.content-panel { padding: 16px 20px; }
.content-panel h1 { font-size: 16px; font-weight: 600; margin: 0 0 12px; }
.content-panel h2 { font-size: 14px; font-weight: 600; margin: 0 0 8px; }

/* ── Read view ── */
.read-header { padding: 14px 20px; border-bottom: 1px solid #eee; }
.read-header .subject { font-size: 16px; font-weight: 600; margin: 0 0 8px; }
.read-header .meta { font-size: 12px; color: #666; line-height: 1.6; }
.read-header .meta strong { color: #333; }
.read-actions { display: flex; gap: 6px; padding: 8px 20px; border-bottom: 1px solid #f0f0f0; }
.read-actions .btn { font-size: 12px; padding: 3px 10px; }
.read-body { padding: 16px 20px; font-size: 13px; line-height: 1.55; word-wrap: break-word; overflow-wrap: anywhere; }
.read-body pre { white-space: pre-wrap; font-size: 12.5px; }
.read-attachments { padding: 10px 20px; border-top: 1px solid #f0f0f0; font-size: 12px; }
.read-attachments a { color: #007aff; text-decoration: none; }
.read-attachments a:hover { text-decoration: underline; }

/* ── Compose ── */
.compose-panel { padding: 12px 20px; }
.compose-panel .form-label { font-size: 12px; font-weight: 500; margin-bottom: 2px; color: #555; }
.compose-panel .form-control, .compose-panel .form-select { font-size: 13px; border: 1px solid #ddd; padding: 5px 8px; }
.compose-panel .form-control:focus { border-color: #aaa; }
.compose-panel .mb-3 { margin-bottom: 8px !important; }
.compose-panel .ql-toolbar { border: 1px solid #ddd !important; border-bottom: none !important; background: #fafafa; }
.compose-panel .ql-container { border: 1px solid #ddd !important; font-size: 13px; }
.compose-panel .btn-row { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.compose-panel .compose-sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 5;
  background: #fff;
  border-top: 1px solid #e6e6e6;
  padding: 8px 0;
  margin-top: 12px;
}
.compose-panel .draft-status { font-size: 11px; color: #999; margin-left: auto; }

/* ── Admin / Settings panels ── */
.panel-form { max-width: 480px; }
.panel-form .form-label { font-size: 12px; font-weight: 500; color: #555; }
.panel-form .form-control, .panel-form .form-select { font-size: 13px; border: 1px solid #ddd; padding: 5px 8px; }
.panel-form .mb-3 { margin-bottom: 8px !important; }
.admin-table-wrap { width: 100%; overflow-x: auto; }
.admin-table { width: 100%; min-width: 860px; border-collapse: collapse; table-layout: fixed; }
.admin-table th { font-size: 11px; text-transform: uppercase; letter-spacing: .4px; color: #888; font-weight: 600; padding: 6px 10px; border-bottom: 1px solid #e0e0e0; }
.admin-table td { font-size: 12.5px; padding: 6px 10px; border-bottom: 1px solid #f0f0f0; vertical-align: top; }
.admin-table th:nth-child(1), .admin-table td:nth-child(1) { width: 28%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-table th:nth-child(2), .admin-table td:nth-child(2) { width: 12%; }
.admin-table th:nth-child(3), .admin-table td:nth-child(3) { width: 10%; }
.admin-table th:nth-child(4), .admin-table td:nth-child(4) { width: 50%; }
.admin-table .btn { font-size: 11px; padding: 2px 8px; }

/* ── Pagination ── */
.pager { display: flex; align-items: center; justify-content: space-between; padding: 6px 10px; border-top: 1px solid #f0f0f0; font-size: 11.5px; color: #888; }
.pager .btn { font-size: 11px; padding: 2px 10px; }

/* ── Toast / Flash ── */
.flash-msg { position: fixed; top: 50px; right: 16px; z-index: 9999; padding: 8px 16px; background: #333; color: #fff; font-size: 12px; opacity: 0; transition: opacity .3s; pointer-events: none; }
.flash-msg.show { opacity: 1; }

/* ── Login page (full-page, centered) ── */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: url('/images/login-background.webp') center center / cover no-repeat;
  position: relative;
}
.login-page::before {
  content: '';
  position: absolute;
  inset: 0;
  backdrop-filter: blur(10px);
  background: rgba(255, 255, 255, 0.3);
}
.login-box {
  position: relative;
  width: 360px;
  padding: 32px;
  background: #fff;
  border: 1px solid #e0e0e0;
}
.login-box h1 { font-size: 16px; font-weight: 600; margin-bottom: 16px; }
.login-box .form-label { font-size: 12px; font-weight: 500; color: #555; }
.login-box .form-control { font-size: 13px; border: 1px solid #ddd; padding: 6px 8px; }
.login-box .btn-primary { width: 100%; margin-top: 8px; }

/* ── Utilities ── */
.text-muted { color: #999 !important; }
.gap-2 { gap: 6px !important; }

/* ── Responsive ── */
@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; grid-template-rows: 42px 1fr; }
  .mobile-menu-btn { display: inline-flex; }
  .app-topbar { padding: 0 8px; }
  .app-topbar .brand { font-size: 13px; }
  .app-topbar .user-info span { display: none; }

  .app-content { grid-column: 1; grid-row: 2; }
  .app-sidebar {
    display: block;
    position: fixed;
    top: 42px;
    left: -240px;
    width: 220px;
    height: calc(100vh - 42px);
    z-index: 20;
    transition: left 0.2s ease;
  }
  .app-shell.sidebar-open .app-sidebar { left: 0; }
  .app-shell.sidebar-open .sidebar-backdrop { display: block; }

  .content-panel,
  .read-header,
  .read-actions,
  .read-body,
  .read-attachments,
  .compose-panel {
    padding-left: 12px;
    padding-right: 12px;
  }

  .compose-panel .btn-row {
    flex-wrap: wrap;
    gap: 6px;
  }

  .compose-panel .draft-status {
    width: 100%;
    margin-left: 0;
  }

  .msg-list { min-width: 680px; }
  .admin-table { min-width: 760px; }

  .login-box {
    width: calc(100vw - 24px);
    max-width: 360px;
    padding: 20px;
  }
}