/* MAIPL SMS Portal — Professional UI */

/* ── Variables ──────────────────────────────────────────── */
:root {
  --maipl-primary:        #0d3b66;
  --maipl-primary-light:  #1a5a9a;
  --maipl-primary-dark:   #09284a;
  --maipl-accent:         #f4a261;
  --sidebar-width:        240px;
  --sidebar-bg:           #0d2137;
  --topbar-height:        56px;
}

/* ── Base ───────────────────────────────────────────────── */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: #f1f5f9;
  color: #1e293b;
}

/* ── App Shell ──────────────────────────────────────────── */
.app-wrapper {
  display: flex;
  min-height: 100vh;
}

/* ══════════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════════ */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  z-index: 1040;
  transition: transform .25s ease;
  overflow: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  padding: 18px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  text-decoration: none;
  gap: 12px;
}

.sidebar-brand-icon {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--maipl-primary-light), var(--maipl-accent));
  border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
  font-size: 19px; color: #fff;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(244,162,97,.3);
}

.sidebar-brand-name { font-size: .92rem; font-weight: 700; color: #fff; line-height: 1.2; }
.sidebar-brand-sub  { font-size: .67rem; color: rgba(255,255,255,.4); letter-spacing: .3px; }

.sidebar-nav {
  padding: 10px 0;
  flex: 1;
  overflow-y: auto;
}

.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-thumb { background: rgba(255,255,255,.1); border-radius: 4px; }

.sidebar-divider {
  height: 1px;
  background: rgba(255,255,255,.07);
  margin: 6px 16px;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 20px;
  color: rgba(255,255,255,.6);
  text-decoration: none;
  font-size: .875rem;
  font-weight: 500;
  border-radius: 0 999px 999px 0;
  margin-right: 12px;
  transition: background .15s, color .15s;
  line-height: 1.3;
}

.sidebar-link i { font-size: 16px; flex-shrink: 0; width: 18px; text-align: center; }

.sidebar-link:hover {
  background: rgba(255,255,255,.07);
  color: rgba(255,255,255,.9);
}

.sidebar-link.active {
  background: rgba(255,255,255,.13);
  color: #fff;
}

.sidebar-link.active i { color: var(--maipl-accent); }

.sidebar-footer {
  padding: 12px 20px;
  border-top: 1px solid rgba(255,255,255,.08);
  font-size: .72rem;
  color: rgba(255,255,255,.3);
  display: flex;
  align-items: center;
  gap: 7px;
}

/* ── Mobile Overlay ─────────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 1039;
}
.sidebar-overlay.show { display: block; }

/* ── Main Content ───────────────────────────────────────── */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
}

/* ══════════════════════════════════════════════════════════
   TOP BAR
══════════════════════════════════════════════════════════ */
.top-bar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 1030;
  display: flex;
  align-items: center;
  padding: 0 20px;
  gap: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
}

.btn-sidebar-toggle {
  width: 34px; height: 34px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 8px;
  border: 1px solid #e2e8f0;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  flex-shrink: 0;
  transition: background .15s, border-color .15s, color .15s;
  padding: 0;
}
.btn-sidebar-toggle:hover {
  background: #f8fafc;
  color: var(--maipl-primary);
}

.top-bar-title {
  font-size: .8rem;
  font-weight: 500;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.top-bar-user .dropdown-toggle {
  display: flex; align-items: center; gap: 8px;
  font-size: .875rem;
  font-weight: 500;
  color: #1e293b;
  text-decoration: none;
}
.top-bar-user .dropdown-toggle::after { display: none; }

.user-avatar {
  width: 32px; height: 32px;
  background: linear-gradient(135deg, var(--maipl-primary), var(--maipl-primary-light));
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}

/* ── Page Content ───────────────────────────────────────── */
.page-content {
  padding: 28px;
  flex: 1;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 24px;
}

.page-header h3 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
}

/* ── Footer ─────────────────────────────────────────────── */
.app-footer {
  padding: 14px 28px;
  border-top: 1px solid #e2e8f0;
  font-size: .73rem;
  color: #94a3b8;
  text-align: center;
}

/* ══════════════════════════════════════════════════════════
   RESPONSIVE — MOBILE
══════════════════════════════════════════════════════════ */
@media (max-width: 991.98px) {
  .main-content { margin-left: 0; }
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .page-content { padding: 20px 16px; }
  .app-footer { padding: 12px 16px; }
}

/* ══════════════════════════════════════════════════════════
   CARDS
══════════════════════════════════════════════════════════ */
.card {
  border: 1px solid #e2e8f0;
  border-radius: .75rem;
  box-shadow: 0 1px 3px rgba(0,0,0,.05);
  background: #fff;
}

.card-header {
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  padding: 14px 20px;
  border-radius: .75rem .75rem 0 0 !important;
}

.card-body { padding: 20px; }

/* ══════════════════════════════════════════════════════════
   STAT CARDS (dashboard + results)
══════════════════════════════════════════════════════════ */
.stat-card {
  border: 1px solid #e2e8f0;
  border-radius: .75rem;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
  transition: transform .15s ease, box-shadow .15s ease;
  overflow: hidden;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0,0,0,.1);
}

.stat-card .card-body { padding: 20px; }

.stat-icon {
  width: 48px; height: 48px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  flex-shrink: 0;
}

.stat-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .55px;
  color: #64748b;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.1;
  color: #0f172a;
  margin-bottom: 3px;
}

.stat-sub {
  font-size: .73rem;
  color: #94a3b8;
}

/* ══════════════════════════════════════════════════════════
   TABLES
══════════════════════════════════════════════════════════ */
.table {
  font-size: .875rem;
  color: #334155;
  margin-bottom: 0;
}

.table thead th {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: #64748b;
  background: #f8fafc;
  border-bottom: 1px solid #e2e8f0;
  padding: 10px 16px;
  white-space: nowrap;
}

.table tbody td { padding: 12px 16px; vertical-align: middle; border-bottom: 1px solid #f1f5f9; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #f8fafc; }
.table-actions .btn { padding: .2rem .5rem; border-radius: 6px; }

/* ══════════════════════════════════════════════════════════
   BADGES
══════════════════════════════════════════════════════════ */
.badge {
  font-weight: 600;
  font-size: .7rem;
  letter-spacing: .3px;
  border-radius: 999px;
  padding: .3em .75em;
}

.badge-soft-primary   { background: #dbeafe; color: #1d4ed8; }
.badge-soft-success   { background: #dcfce7; color: #15803d; }
.badge-soft-danger    { background: #fee2e2; color: #b91c1c; }
.badge-soft-warning   { background: #fef9c3; color: #a16207; }
.badge-soft-info      { background: #e0f2fe; color: #0369a1; }
.badge-soft-secondary { background: #f1f5f9; color: #475569; }

/* ══════════════════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════════════════ */
.btn {
  border-radius: .5rem;
  font-weight: 500;
  font-size: .875rem;
}

.btn-primary {
  background: var(--maipl-primary) !important;
  border-color: var(--maipl-primary) !important;
  color: #fff !important;
}
.btn-primary:hover {
  background: var(--maipl-primary-light) !important;
  border-color: var(--maipl-primary-light) !important;
}

.btn-outline-primary {
  color: var(--maipl-primary) !important;
  border-color: var(--maipl-primary) !important;
  background: transparent !important;
}
.btn-outline-primary:hover {
  background: var(--maipl-primary) !important;
  color: #fff !important;
}

.text-primary { color: var(--maipl-primary) !important; }
.bg-primary   { background: var(--maipl-primary) !important; }

/* ══════════════════════════════════════════════════════════
   FORM CONTROLS
══════════════════════════════════════════════════════════ */
.form-control, .form-select {
  border-radius: .5rem;
  border-color: #cbd5e1;
  font-size: .875rem;
  color: #1e293b;
}
.form-control:focus, .form-select:focus {
  border-color: var(--maipl-primary);
  box-shadow: 0 0 0 3px rgba(13,59,102,.12);
  outline: none;
}
.form-label {
  font-weight: 500;
  font-size: .875rem;
  color: #374151;
  margin-bottom: .3rem;
}
.form-text { color: #64748b; }
.input-group-text { border-color: #cbd5e1; background: #f8fafc; }

/* ══════════════════════════════════════════════════════════
   ALERTS
══════════════════════════════════════════════════════════ */
.alert {
  border-radius: .75rem;
  border: 0;
  font-size: .875rem;
}
.alert-info    { background: #eff6ff; color: #1e40af; }
.alert-warning { background: #fffbeb; color: #92400e; }
.alert-success { background: #f0fdf4; color: #166534; }
.alert-danger  { background: #fef2f2; color: #991b1b; }
.alert-secondary { background: #f8fafc; color: #475569; }
.alert .alert-link { font-weight: 600; }

/* ══════════════════════════════════════════════════════════
   DROPDOWN MENU
══════════════════════════════════════════════════════════ */
.dropdown-menu {
  border-radius: .65rem;
  border-color: #e2e8f0;
  box-shadow: 0 8px 24px rgba(0,0,0,.1);
  padding: .4rem;
  font-size: .875rem;
}
.dropdown-item {
  border-radius: .4rem;
  padding: .5rem .75rem;
  color: #334155;
}
.dropdown-item:hover { background: #f1f5f9; color: #0f172a; }

/* ══════════════════════════════════════════════════════════
   SMS VARIABLE CHIPS
══════════════════════════════════════════════════════════ */
.var-chip {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: .35rem;
  background: #eff6ff;
  color: var(--maipl-primary);
  font-size: .7rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  margin: 1px;
}
.var-chip.over { background: #fee2e2; color: #991b1b; }

/* ══════════════════════════════════════════════════════════
   PREVIEW MESSAGE (used in logs/show)
══════════════════════════════════════════════════════════ */
.preview-msg {
  white-space: pre-wrap;
  background: #f8fafc;
  border-left: 4px solid var(--maipl-primary);
  padding: .85rem 1rem;
  font-size: .875rem;
  border-radius: .5rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: #334155;
}

/* ══════════════════════════════════════════════════════════
   DATATABLES
══════════════════════════════════════════════════════════ */
.dt-search input, .dt-length select {
  border-radius: .5rem;
  border: 1px solid #cbd5e1;
  font-size: .875rem;
  padding: .35rem .65rem;
}
div.dt-container .dt-search { margin-bottom: 0; }

/* ══════════════════════════════════════════════════════════
   PHONE MOCK
══════════════════════════════════════════════════════════ */
.phone-panel {
  position: sticky;
  top: calc(var(--topbar-height) + 20px);
}

.phone-panel-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: #64748b;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.phone-mock {
  width: 256px;
  margin: 0 auto;
  background: #1c1c1e;
  border-radius: 46px;
  padding: 12px;
  box-shadow:
    0 28px 72px rgba(0,0,0,.5),
    0 0 0 1px rgba(255,255,255,.1),
    inset 0 0 0 1px rgba(255,255,255,.06);
}

.phone-dynamic-island {
  width: 112px; height: 30px;
  background: #000;
  border-radius: 20px;
  margin: 4px auto 10px;
}

.phone-screen {
  background: #e5ddd5;
  border-radius: 36px;
  height: 496px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.phone-status-bar {
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 18px;
  font-size: 10px;
  font-weight: 700;
  color: #1e293b;
  border-bottom: 1px solid #f1f5f9;
  flex-shrink: 0;
}

.phone-status-icons { display: flex; gap: 5px; align-items: center; }

.phone-screen-header {
  background: linear-gradient(135deg, var(--maipl-primary) 0%, var(--maipl-primary-light) 100%);
  color: #fff;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.phone-sender-avatar {
  width: 30px; height: 30px;
  background: rgba(255,255,255,.22);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}

.phone-sender-name  { font-size: 12.5px; font-weight: 700; line-height: 1.2; }
.phone-sender-sub   { font-size: 9.5px; opacity: .7; }

.phone-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
}

.phone-messages::-webkit-scrollbar { width: 3px; }
.phone-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,.15); border-radius: 3px; }

.phone-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: #94a3b8;
  font-size: 12px;
  text-align: center;
  padding: 20px;
  gap: 10px;
}
.phone-placeholder i { font-size: 30px; color: #cbd5e1; }

.sms-bubble {
  background: #fff;
  border-radius: 4px 14px 14px 14px;
  padding: 10px 13px;
  font-size: 11.5px;
  line-height: 1.65;
  box-shadow: 0 1px 2px rgba(0,0,0,.1);
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 95%;
  transition: opacity .2s;
}

.sms-bubble .sms-link {
  color: var(--maipl-primary);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-style: dotted;
}

.sms-bubble-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 5px;
  font-size: 9.5px;
  color: #94a3b8;
}

.phone-hint {
  font-size: .7rem;
  color: #94a3b8;
  text-align: center;
  margin-top: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

/* Highlight row being previewed */
tr.row-preview-active td { background: #eff6ff !important; }

/* ══════════════════════════════════════════════════════════
   LOGIN PAGE (public layout)
══════════════════════════════════════════════════════════ */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--maipl-primary-dark) 0%, var(--maipl-primary) 50%, var(--maipl-primary-light) 100%);
  padding: 24px 16px;
}

.login-card {
  width: 100%;
  max-width: 400px;
  border-radius: 1.1rem;
  border: 0;
  box-shadow: 0 16px 64px rgba(0,0,0,.25);
  overflow: hidden;
}

.login-card-header {
  background: #fff;
  padding: 32px 32px 0;
  text-align: center;
}

.login-brand-icon {
  width: 56px; height: 56px;
  background: linear-gradient(135deg, var(--maipl-primary), var(--maipl-primary-light));
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: #fff;
  margin: 0 auto 14px;
  box-shadow: 0 6px 20px rgba(13,59,102,.3);
}

.login-card-body { background: #fff; padding: 24px 32px 32px; }
.login-footer {
  text-align: center;
  font-size: .73rem;
  color: rgba(255,255,255,.55);
  margin-top: 20px;
}

/* ══════════════════════════════════════════════════════════
   MISC UTILITIES
══════════════════════════════════════════════════════════ */
.kbd-amount {
  font-feature-settings: "tnum";
  font-variant-numeric: tabular-nums;
}

@media (max-width: 768px) {
  .stat-value { font-size: 1.5rem; }
}
