/* ==========================================================================
   BianccaMail — console stylesheet
   Right-to-left first, light/dark/vivid themes driven by [data-theme].
   ========================================================================== */

:root {
  --bg: #0b1020;
  --surface: #141b31;
  --surface-2: #0e1730;
  --line: #232f4d;
  --text: #e8ecf6;
  --muted: #8fa0c0;
  --accent: #5ee2b0;
  --accent-2: #6aa8ff;
  --danger: #ff7a7a;
  --warning: #ffce5c;
  --radius: 14px;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

[data-theme='dark'] {
  --bg: #080b14;
  --surface: #10131f;
  --surface-2: #0a0d17;
  --line: #1e2436;
  --text: #dde3ef;
  --muted: #7d8aa5;
}

[data-theme='light'] {
  --bg: #f6f8fc;
  --surface: #ffffff;
  --surface-2: #eef2f9;
  --line: #d9e0ec;
  --text: #0f172a;
  --muted: #5b6b86;
  --accent: #0f9d76;
  --accent-2: #2563eb;
  --shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, 'Segoe UI', Tahoma, 'Noto Sans Arabic', sans-serif;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent-2);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

.btn {
  border: 0;
  border-radius: 10px;
  padding: 11px 18px;
  font-weight: 700;
  cursor: pointer;
  background: var(--surface-2);
  color: var(--text);
  transition: filter 0.15s, transform 0.06s;
}

.btn:hover {
  filter: brightness(1.12);
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #06121a;
}

.btn-danger {
  background: var(--danger);
  color: #2a0808;
}

.btn-ghost {
  background: transparent;
  border: 1px solid var(--line);
}

.btn-sm {
  padding: 5px 11px;
  font-size: 12px;
  border-radius: 8px;
}

.field {
  display: block;
  margin-bottom: 14px;
}

.field label {
  display: block;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 6px;
}

.field-hint {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.6;
  color: var(--muted);
}

/* ---- social login ------------------------------------------------------- */
.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 16px 0 12px;
  color: var(--muted);
  font-size: 12px;
}

.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--line);
}

.social-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn-social {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 10px 12px;
  font-size: 13px;
  min-height: 42px;
}

.btn-social:hover {
  filter: brightness(1.12);
}

.btn-social .social-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-weight: 900;
  font-size: 12px;
  line-height: 1;
  color: #ffffff;
  background: #4285f4;
}

.btn-social-facebook .social-icon {
  background: #1877f2;
  font-family: Georgia, serif;
  font-size: 16px;
}

.btn-social.is-disabled {
  opacity: 0.55;
  border-style: dashed;
}

.social-hint {
  text-align: center;
  margin-top: 8px;
}

.input {
  width: 100%;
  padding: 11px 13px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  outline: none;
}

.input:focus {
  border-color: var(--accent);
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

/* ---- shell ------------------------------------------------------------- */
.shell {
  display: grid;
  grid-template-columns: 260px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--surface);
  border-inline-end: 1px solid var(--line);
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}

.card.recommended {
  border-color: var(--accent);
  box-shadow: 0 10px 30px rgba(106, 168, 255, 0.16);
}

.brand-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: #f1f7f9;
  color: #06121a;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 20px;
  object-fit: contain;
  flex: 0 0 auto;
  box-shadow: 0 4px 12px rgba(106, 168, 255, 0.16);
}

/* ---- public marketing pages ------------------------------------------- */
.public-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 28px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--line);
}

.public-header img {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: #f1f7f9;
  object-fit: contain;
  flex: 0 0 auto;
}

.public-header .public-brand {
  font-weight: 800;
  font-size: 18px;
  color: var(--text);
  line-height: 1.2;
}

.public-header .public-brand span {
  display: block;
  font-size: 12px;
  font-weight: 400;
  color: var(--muted);
  margin-top: 3px;
}

.public-header .public-nav {
  margin-inline-start: auto;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.public-header .public-nav a {
  font-size: 13px;
  color: var(--muted);
  text-decoration: none;
  padding: 7px 11px;
  border-radius: 8px;
}

.public-header .public-nav a:hover {
  color: var(--text);
  background: var(--surface-2);
}

.public-footer {
  margin-top: 36px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.public-footer img {
  height: 46px;
  width: auto;
  background: #fff;
  border-radius: 10px;
  padding: 4px;
  display: block;
}

.public-footer .public-copy {
  flex: 1 1 280px;
  line-height: 1.8;
}

.public-footer .public-copy b {
  color: var(--text);
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: 9px;
  color: var(--muted);
  text-decoration: none;
  font-size: 14px;
}

.nav-item:hover {
  background: var(--surface-2);
  color: var(--text);
}

.nav-item.active {
  background: rgba(94, 226, 176, 0.12);
  color: var(--accent);
  font-weight: 700;
}

.main {
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar h1 {
  font-size: 20px;
  margin: 0;
}

.spacer {
  flex: 1 1 auto;
}

/* ---- address ----------------------------------------------------------- */
.address {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  direction: ltr;
  text-align: center;
  background: var(--surface-2);
  border: 1px dashed var(--accent);
  border-radius: 10px;
  padding: 14px;
  font-size: 17px;
  letter-spacing: 0.4px;
  color: var(--accent);
}

/* ---- message list ------------------------------------------------------ */
.message-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: calc(100vh - 320px);
  overflow: auto;
}

.message {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 12px 14px;
  cursor: pointer;
  font-size: 14px;
}

.message:hover {
  border-color: var(--accent-2);
}

.message.unread {
  border-inline-start: 3px solid var(--accent);
}

.message-head {
  display: flex;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
}

.message-from {
  font-weight: 700;
  color: var(--accent-2);
}

.message-time {
  margin-inline-start: auto;
  font-size: 12px;
  color: var(--muted);
}

.message-subject {
  font-weight: 600;
}

.message-snippet {
  color: var(--muted);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.otp {
  font-family: ui-monospace, monospace;
  background: #06121a;
  color: var(--accent);
  padding: 2px 9px;
  border-radius: 6px;
  font-weight: 700;
  letter-spacing: 1px;
  direction: ltr;
  display: inline-block;
}

/* ---- reader ------------------------------------------------------------ */
.reader iframe {
  width: 100%;
  min-height: 420px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

/* ---- misc -------------------------------------------------------------- */
.grid {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
}

.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
}

.stat-value {
  font-size: 26px;
  font-weight: 800;
  color: var(--accent);
}

.stat-label {
  font-size: 13px;
  color: var(--muted);
}

.toast {
  position: fixed;
  inset-inline: 0;
  bottom: 24px;
  margin: auto;
  width: max-content;
  max-width: 90vw;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 20px;
  box-shadow: var(--shadow);
  font-size: 14px;
  z-index: 50;
}

.toast.error {
  border-color: var(--danger);
  color: var(--danger);
}

.hidden {
  display: none !important;
}

.skeleton {
  height: 14px;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--surface-2), var(--line), var(--surface-2));
  background-size: 200% 100%;
  animation: shimmer 1.2s infinite;
}

@keyframes shimmer {
  to {
    background-position: -200% 0;
  }
}

/* ---- admin: Omni-Control tabs + data tables ----------------------------- */
.tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
}

.tab {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.tab:hover {
  color: var(--text);
  background: var(--surface-2);
}

.tab.active {
  color: var(--accent);
  border-color: var(--line);
  background: var(--surface);
}

.tab-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 80px;
}

.table-card {
  overflow-x: auto;
  padding: 0;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table th,
.data-table td {
  text-align: start;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.data-table th {
  color: var(--muted);
  font-weight: 600;
  background: var(--surface-2);
}

.data-table tr:last-child td {
  border-bottom: 0;
}

.meta-note {
  font-size: 12px;
  color: var(--muted);
  margin-top: 8px;
}

.locale-select {
  max-width: 150px;
  padding: 6px 10px;
  font-size: 13px;
}


/* ---- responsive --------------------------------------------------------- */
html, body { overflow-x: hidden; }
img, iframe, video { max-width: 100%; height: auto; }
table { max-width: 100%; }
.main, .card, .tab-panel, .sidebar, .topbar { min-width: 0; }
.card, .message, .address { overflow-wrap: anywhere; }
.table-card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tabs { overflow-x: auto; -webkit-overflow-scrolling: touch; scrollbar-width: thin; }
.tab { flex: 0 0 auto; white-space: nowrap; }

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
    min-height: 100dvh;
  }
  .sidebar {
    position: sticky;
    top: 0;
    z-index: 20;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    gap: 8px;
    padding: 10px 12px;
    border-inline-end: 0;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
  }
  .brand {
    margin: 0;
    flex: 0 0 auto;
  }
  .brand > div:last-child { display: none; }
  .nav-item {
    white-space: nowrap;
    flex: 0 0 auto;
    padding: 8px 10px;
  }
  .sidebar .spacer { display: none; }
  .sidebar .btn { flex: 0 0 auto; }
  .main {
    padding: 16px;
  }
  .message-list {
    max-height: none;
  }
  .grid {
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  }
}

@media (max-width: 640px) {
  .main { padding: 12px; gap: 12px; }
  .topbar { gap: 8px; align-items: stretch; }
  .topbar h1 { font-size: 18px; width: 100%; }
  .topbar .btn { flex: 1 1 auto; }
  .card { padding: 14px; border-radius: 12px; }
  .grid { grid-template-columns: 1fr; }
  .address { font-size: 14px; padding: 12px; }
  .data-table { font-size: 12px; min-width: 560px; }
  .data-table th, .data-table td { padding: 8px 10px; }
  .tabs { flex-wrap: nowrap; padding-bottom: 6px; }
  .tab { font-size: 12px; padding: 7px 10px; }
  .btn { padding: 10px 14px; }
  .input, select.input, textarea.input { font-size: 16px; }
  .message-head { flex-direction: column; align-items: flex-start; gap: 2px; }
  .message-time { margin-inline-start: 0; }
}

@media (max-width: 420px) {
  .main { padding: 10px; }
  .card { padding: 12px; }
  .nav-item { font-size: 13px; padding: 7px 9px; }
}
