/* Broker Email Distribution Control Panel Stylesheet */
*, ::before, ::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background-color: #020617;
  color: #f8fafc;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

/* Wide Container - fits 1920x1080 and desktop screens with zero horizontal scroll */
.container {
  max-width: 1600px;
  width: min(1600px, calc(100vw - 2.5rem));
  margin: 0 auto;
  padding: 1.5rem 1.25rem;
}

header {
  background-color: #0f172a;
  border-bottom: 1px solid #1e293b;
  position: sticky;
  top: 0;
  z-index: 30;
}

.header-inner {
  max-width: 1600px;
  width: min(1600px, calc(100vw - 2.5rem));
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 4rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand { display: flex; align-items: center; gap: 0.75rem; }
.brand-icon { width: 2.5rem; height: 2.5rem; border-radius: 0.75rem; background-color: #4f46e5; display: flex; align-items: center; justify-content: center; font-size: 1.25rem; }
.brand-title { font-size: 1.125rem; font-weight: 700; color: #fff; }
.brand-sub { font-size: 0.75rem; color: #94a3b8; display: flex; align-items: center; gap: 0.375rem; }
.pulse-dot { display: inline-block; width: 0.5rem; height: 0.5rem; border-radius: 9999px; background-color: #10b981; }

.header-actions { display: flex; align-items: center; gap: 0.6rem; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem; padding: 0.4rem 0.85rem; border-radius: 0.5rem; font-size: 0.875rem; font-weight: 500; cursor: pointer; border: 1px solid transparent; transition: all 0.15s; text-decoration: none; }
.btn-secondary { background-color: #1e293b; color: #cbd5e1; border-color: #334155; }
.btn-secondary:hover { background-color: #334155; color: #fff; }
.btn-primary { background-color: #4f46e5; color: #fff; }
.btn-primary:hover { background-color: #4338ca; }
.btn-danger { background-color: #e11d48; color: #fff; }
.btn-danger:hover { background-color: #be123c; }
.btn-signout { font-size: 0.75rem; color: #94a3b8; text-decoration: none; padding: 0.25rem 0.5rem; transition: color 0.15s; }
.btn-signout:hover { color: #fb7185; }

/* Compact Action Buttons for Table */
.btn-xs {
  padding: 0.2rem 0.42rem;
  font-size: 0.72rem;
  font-weight: 600;
  border-radius: 0.375rem;
  border: 1px solid #334155;
  background-color: #1e293b;
  color: #cbd5e1;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.btn-xs:hover { background-color: #334155; color: #fff; }
.btn-return { background-color: rgba(6, 78, 59, 0.6); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.4); }
.btn-return:hover { background-color: rgba(6, 95, 70, 0.9); color: #a7f3d0; border-color: #10b981; }
.btn-suspend { color: #fda4af; border-color: rgba(225, 29, 72, 0.3); }
.btn-suspend:hover { background-color: rgba(225, 29, 72, 0.25); color: #fecdd3; border-color: #f43f5e; }
.btn-reactivate { color: #6ee7b7; border-color: rgba(16, 185, 129, 0.3); }
.btn-reactivate:hover { background-color: rgba(16, 185, 129, 0.25); color: #a7f3d0; border-color: #10b981; }
.btn-delete { color: #94a3b8; border-color: #334155; padding: 0.2rem 0.35rem; }
.btn-delete:hover { background-color: rgba(225, 29, 72, 0.2); color: #fda4af; border-color: #f43f5e; }

/* Grid Metrics */
.metrics-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 1rem; margin-bottom: 1.5rem; }
.metric-card { background-color: #0f172a; border: 1px solid #1e293b; border-radius: 1rem; padding: 1.25rem; }
.metric-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: #94a3b8; margin-bottom: 0.25rem; }
.metric-val { font-size: 1.875rem; font-weight: 800; }
.val-green { color: #34d399; }
.val-blue { color: #60a5fa; }
.val-amber { color: #fbbf24; }
.val-rose { color: #fb7185; }
.val-indigo { color: #818cf8; }
.val-purple { color: #c084fc; }

/* Filter & Search Bar */
.filter-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 1rem; background-color: #0f172a; border: 1px solid #1e293b; border-radius: 1rem; padding: 0.75rem; margin-bottom: 1.5rem; }
.filter-tabs { display: flex; gap: 0.25rem; overflow-x: auto; }
.filter-tab { padding: 0.4rem 0.85rem; border-radius: 0.75rem; font-size: 0.875rem; border: none; background: transparent; color: #94a3b8; cursor: pointer; transition: all 0.15s; white-space: nowrap; }
.filter-tab.active { background-color: #1e293b; color: #fff; font-weight: 600; }
.filter-tab:hover:not(.active) { color: #e2e8f0; }

.search-wrap { position: relative; min-width: 260px; }
.search-input { width: 100%; padding: 0.4rem 0.75rem 0.4rem 2.25rem; background-color: #020617; border: 1px solid #1e293b; border-radius: 0.75rem; color: #fff; font-size: 0.875rem; outline: none; }
.search-input:focus { border-color: #6366f1; }
.search-icon { position: absolute; left: 0.75rem; top: 0.6rem; width: 1rem; height: 1rem; color: #64748b; }

/* Table Container & Proportional Layout */
.card-table { background-color: #0f172a; border: 1px solid #1e293b; border-radius: 1rem; overflow: hidden; margin-bottom: 1.5rem; }
.table-responsive { overflow-x: auto; width: 100%; }

table.broker-table, table.logs-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
  table-layout: fixed;
}

thead { background-color: rgba(2, 6, 23, 0.6); border-bottom: 1px solid #1e293b; color: #94a3b8; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; }
th, td { padding: 0.75rem 0.55rem; vertical-align: middle; }
tbody tr { border-bottom: 1px solid rgba(30, 41, 59, 0.6); transition: background 0.15s; }
tbody tr:hover { background-color: rgba(30, 41, 59, 0.4); }

/* Broker Table Column Widths (Sum = 100%) */
.col-broker { width: 17%; }
.col-sales { width: 15%; }
.col-coverage { width: 15%; }
.col-assigned { width: 11%; text-align: center; }
.col-last-assigned { width: 14%; }
.col-away-window { width: 12%; }
.col-actions { width: 16%; text-align: right; }

.slider-coverage { }
input:checked + .slider-coverage { background-color: #059669; }

/* Logs Table Column Widths (Sum = 100%) */
.col-log-time { width: 16%; }
.col-log-source { width: 14%; }
.col-log-broker { width: 16%; }
.col-log-subject { width: 26%; }
.col-log-sender { width: 18%; }
.col-log-status { width: 10%; text-align: center; }

.broker-name { font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.broker-email { font-size: 0.75rem; color: #94a3b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cell-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Compact Away Window Display */
.away-stacked { display: flex; flex-direction: column; font-size: 0.75rem; line-height: 1.35; }
.away-from { color: #cbd5e1; font-weight: 500; }
.away-to { color: #94a3b8; }
.away-label { color: #64748b; font-size: 0.7rem; }

/* Badges */
.badge { display: inline-flex; align-items: center; gap: 0.375rem; padding: 0.25rem 0.625rem; border-radius: 0.5rem; font-size: 0.75rem; font-weight: 600; border: 1px solid transparent; white-space: nowrap; }
.badge-available { background-color: rgba(6, 78, 59, 0.7); color: #6ee7b7; border-color: rgba(6, 95, 70, 0.6); }
.badge-away { background-color: rgba(30, 58, 138, 0.7); color: #93c5fd; border-color: rgba(30, 64, 175, 0.6); }
.badge-unavailable { background-color: rgba(120, 53, 15, 0.7); color: #fde68a; border-color: rgba(146, 64, 14, 0.6); }
.badge-suspended { background-color: rgba(136, 19, 55, 0.7); color: #fca5a5; border-color: rgba(159, 18, 57, 0.6); }

/* Toggle Switch */
.switch { position: relative; display: inline-block; width: 42px; height: 22px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0; background-color: #334155; transition: .2s; border-radius: 22px; }
.slider:before { position: absolute; content: ""; height: 16px; width: 16px; left: 3px; bottom: 3px; background-color: white; transition: .2s; border-radius: 50%; }
input:checked + .slider { background-color: #10b981; }
input:checked + .slider:before { transform: translateX(20px); }

/* Modals */
.modal-backdrop { position: fixed; inset: 0; background-color: rgba(2, 6, 23, 0.85); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 50; padding: 1rem; }
.modal-box { background-color: #0f172a; border: 1px solid #1e293b; border-radius: 1rem; width: 100%; max-width: 32rem; padding: 1.5rem; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6); }
.modal-box-lg { max-width: 46rem; }
.modal-header { display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #1e293b; padding-bottom: 0.75rem; margin-bottom: 1rem; }
.modal-title { font-size: 1.125rem; font-weight: 700; color: #fff; }
.modal-close { background: transparent; border: none; color: #94a3b8; font-size: 1.25rem; cursor: pointer; padding: 0.25rem 0.5rem; border-radius: 0.375rem; }
.modal-close:hover { color: #fff; background-color: #1e293b; }
.modal-footer { display: flex; align-items: center; justify-content: flex-end; gap: 0.75rem; border-top: 1px solid #1e293b; padding-top: 0.75rem; margin-top: 1rem; }

.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.75rem; font-weight: 600; color: #94a3b8; margin-bottom: 0.35rem; }
.form-input { width: 100%; padding: 0.5rem 0.75rem; background-color: #020617; border: 1px solid #1e293b; border-radius: 0.75rem; color: #fff; font-size: 0.875rem; outline: none; }
.form-input:focus { border-color: #6366f1; }
.form-textarea { font-family: inherit; resize: vertical; line-height: 1.5; font-size: 0.875rem; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }

/* Preset buttons */
.preset-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.5rem; margin-bottom: 1rem; }
.btn-preset { padding: 0.4rem; background-color: #1e293b; border: 1px solid #334155; border-radius: 0.5rem; color: #cbd5e1; font-size: 0.75rem; cursor: pointer; }
.btn-preset:hover { background-color: #334155; color: #fff; }

/* Template Modal Specific Styles */
.template-hint { display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem; background-color: rgba(30, 41, 59, 0.5); border: 1px solid #1e293b; border-radius: 0.5rem; padding: 0.5rem 0.75rem; font-size: 0.75rem; color: #cbd5e1; margin-bottom: 1rem; }
.template-hint code { background-color: #020617; border: 1px solid #334155; padding: 0.15rem 0.4rem; border-radius: 0.25rem; color: #a5b4fc; font-weight: 700; font-family: monospace; }
.preview-section { background-color: #020617; border: 1px solid #1e293b; border-radius: 0.75rem; padding: 0.85rem; margin-bottom: 1rem; }
.preview-section-header { display: flex; align-items: center; justify-content: space-between; font-size: 0.75rem; font-weight: 600; color: #94a3b8; margin-bottom: 0.5rem; }
.preview-rendered-box { font-size: 0.85rem; color: #e2e8f0; white-space: pre-wrap; line-height: 1.5; background: rgba(15, 23, 42, 0.7); border: 1px solid rgba(51, 65, 85, 0.5); border-radius: 0.5rem; padding: 0.75rem; max-height: 160px; overflow-y: auto; }
.btn-preview-refresh { background: transparent; border: none; color: #818cf8; font-size: 0.75rem; cursor: pointer; text-decoration: underline; }

/* Alert Banners */
.alert-banner { padding: 0.85rem 1.25rem; border-radius: 0.75rem; display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.5rem; }

/* Animations */
@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
.animate-spin { animation: spin 1s linear infinite; }

footer { margin-top: 2rem; padding: 1rem 0 2rem; border-top: 1px solid rgba(30, 41, 59, 0.6); display: flex; justify-content: space-between; font-size: 0.75rem; color: #64748b; }

/* Add Broker modal (2026-10-08) */
.req { color: #fb7185; }
.field-error { color: #fda4af; font-size: 0.75rem; margin-top: 0.3rem; min-height: 0; }
.field-error:empty { display: none; }
.field-hint { color: #94a3b8; font-size: 0.72rem; margin-top: 0.3rem; line-height: 1.4; }
.form-input.is-invalid { border-color: #fb7185; }
.add-broker-alert { border-radius: 0.75rem; padding: 0.65rem 0.85rem; font-size: 0.85rem; margin-bottom: 1rem; line-height: 1.4; }
.add-broker-alert.is-error { background: rgba(225, 29, 72, 0.12); border: 1px solid rgba(251, 113, 133, 0.45); color: #fecdd3; }
.add-broker-alert.is-success { background: rgba(16, 185, 129, 0.12); border: 1px solid rgba(52, 211, 153, 0.45); color: #a7f3d0; }
.add-broker-toggles { border: 1px solid #1e293b; border-radius: 0.75rem; padding: 0.75rem 0.85rem; margin-bottom: 1rem; display: grid; gap: 0.65rem; }
.add-broker-toggle { display: flex; align-items: center; justify-content: space-between; gap: 1rem; cursor: pointer; }
.toggle-title { display: block; font-size: 0.85rem; font-weight: 600; color: #e2e8f0; }
.toggle-sub { display: block; font-size: 0.72rem; color: #94a3b8; }
.add-broker-admin { border: 1px dashed #334155; border-radius: 0.75rem; padding: 0.75rem 0.85rem; margin-bottom: 0.5rem; }
.add-broker-admin-ok { display: flex; align-items: center; justify-content: space-between; color: #cbd5e1; font-size: 0.85rem; border-style: solid; border-color: rgba(99, 102, 241, 0.45); }
#add-broker-submit[disabled] { opacity: 0.6; cursor: progress; }
.add-broker-admin-ok .btn-signout { background: transparent; border: none; cursor: pointer; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }
