/**
 * Websy Outreach V1 - Modern SaaS Dashboard Stylesheet
 * Incorporates dashboard-design principles and modern web standards.
 */

:root {
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --border-subtle: #f1f5f9;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #64748b;
  
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  
  --sidebar-w: 240px;
  --card-radius: 10px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-card: 0 1px 3px 0 rgba(15, 23, 42, 0.04), 0 1px 2px -1px rgba(15, 23, 42, 0.03);
}

body {
  font-family: var(--font-sans);
  background-color: var(--bg-page);
  color: var(--text-primary);
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

/* Tabular figures for all statistics and financial/date columns */
.tabular-nums, .kpi-value, .table td, .table th, .badge {
  font-variant-numeric: tabular-nums;
}

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

/* Persistent Sidebar */
.app-sidebar {
  width: var(--sidebar-w);
  background-color: #ffffff;
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: 1020;
  transition: transform 0.2s ease-in-out;
}

.sidebar-brand {
  height: 64px;
  display: flex;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid var(--border-subtle);
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--text-primary);
  text-decoration: none;
  gap: 10px;
}

.brand-icon {
  width: 32px;
  height: 32px;
  background-color: var(--primary);
  color: #ffffff;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
}

.sidebar-nav {
  flex: 1;
  padding: 16px 12px;
  overflow-y: auto;
  list-style: none;
  margin: 0;
}

.nav-item {
  margin-bottom: 3px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: 8px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 500;
  text-decoration: none;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.nav-link:hover {
  background-color: var(--border-subtle);
  color: var(--text-primary);
}

.nav-link.active {
  background-color: var(--primary-light);
  color: var(--primary);
  font-weight: 600;
}

.nav-link svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-subtle);
}

/* Main Content Area */
.app-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.app-topbar {
  height: 64px;
  background-color: #ffffff;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  position: sticky;
  top: 0;
  z-index: 1010;
}

.app-content {
  flex: 1;
  padding: 28px;
}

/* Mobile Sidebar Drawer */
@media (max-width: 991.98px) {
  .app-sidebar {
    transform: translateX(-100%);
  }
  .app-sidebar.show {
    transform: translateX(0);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  }
  .app-main {
    margin-left: 0;
  }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 1019;
  }
  .sidebar-backdrop.show {
    display: block;
  }
}

/* Modern Card Design */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--card-radius);
  box-shadow: var(--shadow-card);
  margin-bottom: 24px;
}

.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  padding: 20px;
}

/* KPI Cards */
.kpi-card {
  padding: 20px;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.kpi-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.kpi-title {
  font-size: 0.8125rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin: 0;
}

.kpi-icon-box {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.kpi-icon-box svg {
  width: 18px;
  height: 18px;
}

.kpi-value {
  font-size: 1.875rem;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  margin: 0 0 4px 0;
}

.kpi-context {
  font-size: 0.8125rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

/* Progress bar inside KPI (goal tracker) */
.kpi-progress {
  height: 4px;
  background-color: var(--border-subtle);
  border-radius: 2px;
  margin-top: 10px;
  overflow: hidden;
}

.kpi-progress-bar {
  height: 100%;
  background-color: var(--primary);
  border-radius: 2px;
}

/* Soft Badges */
.badge-soft {
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.badge-soft-primary { background-color: var(--primary-light); color: var(--primary); }
.badge-soft-success { background-color: var(--success-light); color: var(--success); }
.badge-soft-warning { background-color: var(--warning-light); color: var(--warning); }
.badge-soft-danger  { background-color: var(--danger-light); color: var(--danger); }
.badge-soft-neutral { background-color: var(--border-subtle); color: var(--text-secondary); }

/* Tables */
.table-responsive {
  border-radius: var(--card-radius);
  overflow-x: auto;
}

.table-custom {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin: 0;
}

.table-custom th {
  background-color: #f8fafc;
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.table-custom td {
  padding: 14px 16px;
  font-size: 0.875rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.table-custom tr:last-child td {
  border-bottom: none;
}

.table-custom tbody tr:hover td {
  background-color: #fafbfc;
}

/* Buttons */
.btn-primary {
  background-color: var(--primary);
  border-color: var(--primary);
  font-weight: 500;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  border-color: var(--primary-hover);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 0.8125rem;
  border-radius: 6px;
}

/* Forms */
.form-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.form-control, .form-select {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 0.875rem;
  padding: 9px 12px;
  color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-text {
  font-size: 0.775rem;
  color: var(--text-muted);
}
