/* public/css/style.css */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --primary:    #4F46E5;
  --primary-d:  #3730A3;
  --success:    #16A34A;
  --danger:     #DC2626;
  --warning:    #D97706;
  --pending:    #6B7280;
  --bg:         #F9FAFB;
  --surface:    #FFFFFF;
  --border:     #E5E7EB;
  --text:       #111827;
  --text-muted: #6B7280;
  --sidebar-w:  220px;
  --radius:     10px;
}

body { font-family: system-ui, -apple-system, sans-serif; font-size: 14px; color: var(--text); background: var(--bg); }

/* ── Login ─────────────────────────────────────────────── */
.page-center { min-height: 100vh; display: flex; align-items: center; justify-content: center; background: linear-gradient(135deg, #EEF2FF 0%, #F5F3FF 100%); }
.login-card  { background: var(--surface); border-radius: 16px; padding: 40px; width: 360px; box-shadow: 0 4px 24px rgba(0,0,0,.08); }
.login-logo  { text-align: center; margin-bottom: 20px; }
.login-title { text-align: center; font-size: 22px; font-weight: 700; color: var(--text); }
.login-sub   { text-align: center; color: var(--text-muted); margin: 6px 0 24px; }

.form-group        { margin-bottom: 16px; }
.form-group label  { display: block; margin-bottom: 6px; font-weight: 500; color: var(--text); }
.form-group input  { width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 14px; outline: none; transition: border-color .2s; }
.form-group input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(79,70,229,.1); }

/* ── Layout ────────────────────────────────────────────── */
#app-page    { display: flex; min-height: 100vh; }
.sidebar     { width: var(--sidebar-w); background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; position: fixed; height: 100vh; }
.main-content{ margin-left: var(--sidebar-w); flex: 1; padding: 28px 32px; min-height: 100vh; }

.sidebar-logo { display: flex; align-items: center; gap: 10px; padding: 20px 16px; font-size: 15px; font-weight: 700; border-bottom: 1px solid var(--border); }
.sidebar-nav  { flex: 1; padding: 12px 8px; overflow-y: auto; }
.nav-section-label { padding: 12px 8px 6px; font-size: 11px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.nav-item { display: flex; align-items: center; gap: 8px; padding: 9px 10px; border-radius: 8px; cursor: pointer; color: var(--text-muted); font-weight: 500; text-decoration: none; transition: background .15s, color .15s; position: relative; user-select: none; }
.nav-item:hover { background: #F3F4F6; color: var(--text); }
.nav-item.active { background: #EEF2FF; color: var(--primary); }
.nav-icon  { font-size: 15px; width: 20px; text-align: center; }
.nav-badge { margin-left: auto; background: #E5E7EB; color: var(--text-muted); font-size: 11px; font-weight: 600; padding: 1px 7px; border-radius: 20px; min-width: 24px; text-align: center; }
.nav-item.active .nav-badge { background: #C7D2FE; color: var(--primary); }
.sidebar-footer { padding: 12px 16px; border-top: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--text-muted); }

/* ── Topbar ────────────────────────────────────────────── */
.topbar         { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 24px; flex-wrap: wrap; gap: 12px; }
.topbar h2      { font-size: 20px; font-weight: 700; }
.topbar-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.search-input   { padding: 8px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; outline: none; width: 200px; }
.search-input:focus { border-color: var(--primary); }
.filter-select  { padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; outline: none; background: var(--surface); cursor: pointer; }
.text-muted     { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

/* ── Summary cards ─────────────────────────────────────── */
.summary-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; margin-bottom: 24px; }
.summary-card  { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; cursor: pointer; transition: box-shadow .15s, border-color .15s; }
.summary-card:hover { box-shadow: 0 2px 12px rgba(0,0,0,.08); border-color: var(--primary); }
.sc-label  { font-size: 11px; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: .05em; }
.sc-count  { font-size: 26px; font-weight: 700; margin: 4px 0; }
.sc-sub    { font-size: 12px; color: var(--text-muted); }
.sc-sub span { color: var(--success); font-weight: 600; }
.sc-sub span.fail { color: var(--danger); }

/* ── Table card ────────────────────────────────────────── */
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }

.email-table { width: 100%; border-collapse: collapse; }
.email-table th { padding: 12px 14px; text-align: left; font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; letter-spacing: .05em; border-bottom: 1px solid var(--border); background: #F9FAFB; }
.email-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.email-table tr:last-child td { border-bottom: none; }
.email-table tr:hover td { background: #F9FAFB; }
.email-table tr { cursor: pointer; }

.badge { display: inline-block; padding: 2px 9px; border-radius: 20px; font-size: 11px; font-weight: 600; }
.badge-sent    { background: #DCFCE7; color: #15803D; }
.badge-failed  { background: #FEE2E2; color: #B91C1C; }
.badge-pending { background: #F3F4F6; color: #6B7280; }

.badge-module  { background: #EEF2FF; color: var(--primary); font-size: 11px; }

.td-email   { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.td-subject { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.td-time    { color: var(--text-muted); font-size: 12px; white-space: nowrap; }

.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); }
.empty-state .empty-icon { font-size: 40px; display: block; margin-bottom: 12px; }

/* ── Pagination ────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 6px; padding: 14px 16px; border-top: 1px solid var(--border); flex-wrap: wrap; }
.page-info  { flex: 1; font-size: 13px; color: var(--text-muted); }
.page-btn   { padding: 6px 12px; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); cursor: pointer; font-size: 13px; transition: background .15s; }
.page-btn:hover    { background: #F3F4F6; }
.page-btn.active   { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: .4; cursor: not-allowed; }

/* ── Buttons ───────────────────────────────────────────── */
.btn         { padding: 9px 18px; border-radius: 8px; font-size: 14px; font-weight: 500; cursor: pointer; border: none; transition: background .15s, opacity .15s; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-d); }
.btn-outline { background: transparent; border: 1px solid var(--border); color: var(--text); }
.btn-outline:hover { background: #F3F4F6; }
.btn-ghost   { background: transparent; border: none; color: var(--text-muted); padding: 5px 10px; font-size: 13px; }
.btn-ghost:hover { color: var(--text); }
.btn-sm      { padding: 7px 14px; font-size: 13px; }
.btn-full    { width: 100%; text-align: center; }
.btn-close   { background: none; border: none; font-size: 18px; cursor: pointer; color: var(--text-muted); padding: 4px 8px; border-radius: 4px; }
.btn-close:hover { background: #F3F4F6; }

/* ── Alerts ────────────────────────────────────────────── */
.alert        { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; }
.alert-error  { background: #FEF2F2; color: #B91C1C; border: 1px solid #FECACA; }

/* ── Modal ─────────────────────────────────────────────── */
.modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,.4); display: flex; align-items: center; justify-content: center; z-index: 100; }
.modal-card    { background: var(--surface); border-radius: 14px; width: min(700px, 96vw); max-height: 85vh; display: flex; flex-direction: column; box-shadow: 0 8px 40px rgba(0,0,0,.15); }
.modal-header  { display: flex; justify-content: space-between; align-items: center; padding: 20px 24px; border-bottom: 1px solid var(--border); }
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-body    { padding: 24px; overflow-y: auto; }
.modal-row     { display: flex; gap: 8px; margin-bottom: 14px; align-items: flex-start; }
.modal-label   { min-width: 110px; font-size: 12px; font-weight: 600; color: var(--text-muted); padding-top: 2px; }
.modal-value   { font-size: 14px; flex: 1; word-break: break-all; }
.modal-body-content { background: #F9FAFB; border: 1px solid var(--border); border-radius: 8px; padding: 14px; font-size: 13px; max-height: 200px; overflow-y: auto; white-space: pre-wrap; word-break: break-word; margin-top: 6px; }