/* =====================
   Variables & Reset
   ===================== */
:root {
  --primary:    #1a73e8;
  --primary-dk: #1557b0;
  --success:    #2e7d32;
  --danger:     #c62828;
  --warning:    #f57f17;
  --info:       #0277bd;
  --bg:         #f0f2f5;
  --sidebar-w:  240px;
  --sidebar-bg: #1e2a3b;
  --sidebar-txt:#c8d6e5;
  --card-bg:    #ffffff;
  --text:       #202124;
  --text-muted: #6b7280;
  --border:     #e0e0e0;
  --radius:     10px;
  --shadow:     0 2px 12px rgba(0,0,0,.08);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* =====================
   Login
   ===================== */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1e2a3b 0%, #2d3e55 100%);
}
.login-container { width: 100%; max-width: 420px; padding: 20px; }
.login-card {
  background: var(--card-bg);
  border-radius: 16px;
  padding: 40px 36px;
  box-shadow: 0 8px 32px rgba(0,0,0,.25);
}
.login-logo { text-align: center; margin-bottom: 28px; }
.logo-icon {
  width: 64px; height: 64px;
  background: var(--primary);
  color: #fff;
  font-size: 32px; font-weight: 700;
  border-radius: 16px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 12px;
}
.login-logo h1 { font-size: 20px; color: var(--text); }
.login-logo p  { color: var(--text-muted); font-size: 13px; }

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

/* Sidebar */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  color: var(--sidebar-txt);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  transition: transform .25s ease;
}
.sidebar-header {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}
.sidebar-logo {
  width: 38px; height: 38px;
  background: var(--primary);
  color: #fff; font-weight: 700; font-size: 20px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.sidebar-title { font-weight: 700; font-size: 18px; color: #fff; }

.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 11px 18px;
  color: var(--sidebar-txt);
  text-decoration: none;
  font-size: 14px;
  border-left: 3px solid transparent;
  transition: background .15s, color .15s;
}
.nav-item:hover  { background: rgba(255,255,255,.07); color: #fff; }
.nav-item.active { background: rgba(26,115,232,.25); color: #fff; border-left-color: var(--primary); }
.nav-icon { font-size: 16px; width: 20px; text-align: center; }

.sidebar-footer {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px;
  border-top: 1px solid rgba(255,255,255,.08);
}
.user-info { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #adb5bd; }
.user-avatar {
  width: 32px; height: 32px;
  background: var(--primary);
  color: #fff; font-weight: 700;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
}
.logout-btn { color: #adb5bd; text-decoration: none; font-size: 18px; }
.logout-btn:hover { color: #fff; }

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

.top-bar {
  height: 56px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky; top: 0; z-index: 50;
}
.menu-toggle { background: none; border: none; font-size: 22px; cursor: pointer; display: none; }
.page-title  { font-size: 16px; font-weight: 600; flex: 1; }
.top-bar-right { display: flex; align-items: center; gap: 12px; }
.badge-user {
  background: #e8f0fe; color: var(--primary);
  padding: 4px 12px; border-radius: 20px; font-size: 13px; font-weight: 500;
}

.content-area { padding: 24px; flex: 1; }

/* =====================
   Cards
   ===================== */
.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.card-header h3 { font-size: 15px; font-weight: 600; }
.card-body { padding: 20px; }
.card-body.p-0 { padding: 0; }
.mt-2 { margin-top: 20px; }

/* =====================
   Metrics
   ===================== */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}
.metric-card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  display: flex; align-items: center; gap: 16px;
  padding: 20px;
}
.metric-icon {
  width: 50px; height: 50px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.metric-icon.blue   { background: #e8f0fe; }
.metric-icon.green  { background: #e8f5e9; }
.metric-icon.purple { background: #f3e5f5; }
.metric-icon.orange { background: #fff3e0; }
.metric-icon.red    { background: #fce4ec; }
.metric-value { font-size: 26px; font-weight: 700; line-height: 1; }
.metric-label { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* =====================
   Layout helpers
   ===================== */
.row-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 20px;
}

/* =====================
   Tables
   ===================== */
.table-responsive { overflow-x: auto; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table thead tr { background: #f8f9fa; }
.table th { padding: 10px 14px; text-align: left; font-weight: 600; color: var(--text-muted); white-space: nowrap; border-bottom: 2px solid var(--border); }
.table td { padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover { background: #f8f9ff; }
.table tbody tr:last-child td { border-bottom: none; }
.msg-cell { max-width: 300px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* =====================
   Forms
   ===================== */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 13px; }
.form-control {
  width: 100%; padding: 9px 12px;
  border: 1px solid var(--border); border-radius: 7px;
  font-size: 14px; color: var(--text);
  transition: border-color .15s, box-shadow .15s;
  background: #fff;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(26,115,232,.12);
}
textarea.form-control { resize: vertical; }

.filter-form {
  display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end;
  margin-bottom: 4px;
}
.filter-form .form-control { flex: 1; min-width: 140px; margin-bottom: 0; }

/* =====================
   Buttons
   ===================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 18px;
  border: none; border-radius: 7px;
  font-size: 14px; font-weight: 500; cursor: pointer;
  text-decoration: none;
  transition: background .15s, opacity .15s, box-shadow .15s;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary  { background: var(--primary); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--primary-dk); }
.btn-success  { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #1b5e20; }
.btn-outline  { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover:not(:disabled) { background: #e8f0fe; }
.btn-sm       { padding: 6px 12px; font-size: 13px; }
.btn-block    { width: 100%; }
.mt-2         { margin-top: 12px; }

/* =====================
   Badges
   ===================== */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 12px;
  font-size: 11px; font-weight: 600; white-space: nowrap;
}
.badge-success { background: #e8f5e9; color: #2e7d32; }
.badge-danger  { background: #fce4ec; color: #c62828; }
.badge-warning { background: #fff8e1; color: #f57f17; }
.badge-info    { background: #e3f2fd; color: #0277bd; }

/* =====================
   Alerts
   ===================== */
.alert {
  padding: 12px 16px; border-radius: 8px; margin-bottom: 16px; font-size: 13px;
}
.alert-info    { background: #e3f2fd; color: #0277bd; border: 1px solid #90caf9; }
.alert-success { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.alert-warning { background: #fff8e1; color: #f57f17; border: 1px solid #ffe082; }
.alert-danger  { background: #fce4ec; color: #c62828; border: 1px solid #f48fb1; }

/* =====================
   Status row (dashboard)
   ===================== */
.status-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 13px;
}
.status-row:last-of-type { border-bottom: none; }

/* =====================
   Automation
   ===================== */
.msg-preview {
  background: #f0f4ff; border: 1px solid #c5cae9;
  border-radius: 8px; padding: 12px 14px;
  font-size: 13px; color: #283593; white-space: pre-wrap; min-height: 60px;
}
.progress-wrap { margin-top: 12px; }
.progress-bar  { height: 8px; background: #e0e0e0; border-radius: 4px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--primary); border-radius: 4px; transition: width .4s ease; width: 0; }
#progressText  { font-size: 12px; color: var(--text-muted); margin-top: 4px; display: block; }

/* =====================
   Settings tabs
   ===================== */
.settings-tabs { display: flex; gap: 4px; margin-bottom: 20px; flex-wrap: wrap; }
.tab-btn {
  padding: 9px 18px; border-radius: 7px; font-size: 14px; font-weight: 500;
  color: var(--text-muted); text-decoration: none;
  background: var(--card-bg); border: 1px solid var(--border);
  transition: background .15s, color .15s;
}
.tab-btn:hover  { background: #e8f0fe; color: var(--primary); }
.tab-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

.provider-section { animation: fadeIn .2s ease; }
@keyframes fadeIn { from { opacity:0; transform:translateY(4px); } to { opacity:1; transform:none; } }

/* =====================
   Pagination
   ===================== */
.pagination-wrap { display: flex; gap: 6px; flex-wrap: wrap; }

/* =====================
   Misc
   ===================== */
.text-center { text-align: center; }
.text-muted  { color: var(--text-muted); }
code {
  background: #f0f0f0; padding: 1px 5px; border-radius: 4px;
  font-family: monospace; font-size: 12px;
}

/* =====================
   Responsive
   ===================== */
@media (max-width: 900px) {
  .row-2col { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .menu-toggle { display: block; }
  .metrics-grid { grid-template-columns: 1fr 1fr; }
  .content-area { padding: 16px; }
}
@media (max-width: 480px) {
  .metrics-grid { grid-template-columns: 1fr; }
  .filter-form { flex-direction: column; }
  .filter-form .form-control { min-width: 100%; }
}
