/* ==========================================================================
   KALLISTO OS - REUSABLE UI COMPONENT LIBRARY
   Minimal, Accessible, Distraction-Free Business Controls
   ========================================================================== */

/* 1. Base Reset & Typography Helpers */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body.os-body {
  font-family: var(--font-sans);
  background-color: var(--surface-bg);
  color: var(--text-primary);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
}

/* 2. Layout Structure (Sidebar + Main Content) */
.os-layout {
  display: flex;
  width: 100vw;
  min-height: 100vh;
}

.os-sidebar {
  width: var(--sidebar-width);
  background-color: var(--surface-sidebar);
  color: var(--text-inverse);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 40;
  transition: width 0.2s ease;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
}

.os-sidebar-header {
  height: var(--header-height);
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.os-brand-badge {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: #ffffff;
}

.os-brand-logo {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--brand-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  font-weight: 800;
  font-family: var(--font-display);
  font-size: 0.875rem;
}

.os-sidebar-nav {
  flex: 1;
  padding: 1rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow-y: auto;
}

.os-nav-section-title {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-inverse-muted);
  padding: 0.75rem 0.5rem 0.25rem;
}

.os-nav-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-md);
  color: var(--text-inverse-muted);
  text-decoration: none;
  font-size: 0.875rem;
  font-weight: 500;
  transition: all 0.15s ease;
}

.os-nav-item:hover {
  background-color: var(--surface-sidebar-hover);
  color: #ffffff;
}

.os-nav-item.active {
  background-color: var(--brand-primary);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.os-nav-item .material-symbols-outlined {
  font-size: 1.25rem;
}

.os-sidebar-footer {
  padding: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.os-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background-color: var(--surface-bg);
}

.os-topbar {
  height: var(--header-height);
  background-color: var(--surface-card);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1.75rem;
  position: sticky;
  top: 0;
  z-index: 30;
}

.os-page-content {
  flex: 1;
  padding: 1.75rem;
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
}

/* 3. Cards & Surfaces */
.os-card {
  background-color: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 1.5rem;
  position: relative;
}

.os-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
}

.os-card-title {
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.os-card-desc {
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 0.125rem;
}

/* 4. Stat & Metric Widgets */
.os-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(220px, 100%), 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.os-stat-card {
  background-color: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.os-stat-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.os-stat-value {
  font-family: var(--font-display);
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text-primary);
  letter-spacing: -0.02em;
  margin: 0.35rem 0;
}

.os-stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  font-weight: 600;
}

.os-stat-trend.positive { color: var(--status-success); }
.os-stat-trend.negative { color: var(--status-danger); }
.os-stat-trend.neutral { color: var(--text-muted); }

/* 5. Minimal Buttons */
.os-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.625rem 1.25rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.15s ease;
  line-height: 1;
  white-space: nowrap;
}

.os-btn-primary {
  background-color: var(--brand-primary);
  color: #ffffff;
  box-shadow: var(--shadow-xs);
}

.os-btn-primary:hover {
  background-color: var(--brand-primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.os-btn-secondary {
  background-color: #ffffff;
  color: var(--text-secondary);
  border: 1px solid var(--border-medium);
}

.os-btn-secondary:hover {
  background-color: var(--surface-bg);
  color: var(--text-primary);
}

.os-btn-sm {
  padding: 0.45rem 0.85rem;
  font-size: 0.75rem;
  border-radius: var(--radius-sm);
}

.os-btn-danger {
  background-color: var(--status-danger-bg);
  color: var(--status-danger-text);
  border-color: rgba(239, 68, 68, 0.2);
}

.os-btn-danger:hover {
  background-color: var(--status-danger);
  color: #ffffff;
}

/* 6. Form Controls */
.os-form-group {
  margin-bottom: 1rem;
}

.os-label {
  display: block;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.375rem;
}

.os-input, .os-select, .os-textarea {
  width: 100%;
  font-family: var(--font-sans);
  font-size: 0.875rem;
  color: var(--text-primary);
  background-color: #ffffff;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  padding: 0.625rem 0.875rem;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
  outline: none;
}

.os-input:focus, .os-select:focus, .os-textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--brand-primary-light);
}

/* 7. Data Tables */
.os-table-wrapper {
  overflow-x: auto;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background-color: #ffffff;
}

.os-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.os-table th {
  background-color: #f8fafc;
  padding: 0.75rem 1rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.os-table td {
  padding: 0.875rem 1rem;
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-subtle);
  vertical-align: middle;
}

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

.os-table tr:hover td {
  background-color: var(--surface-bg);
}

/* 8. Status Badges & Pills */
.os-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 600;
  padding: 0.25rem 0.625rem;
  border-radius: var(--radius-full);
}

.os-badge-success { background: var(--status-success-bg); color: var(--status-success-text); }
.os-badge-warning { background: var(--status-warning-bg); color: var(--status-warning-text); }
.os-badge-danger { background: var(--status-danger-bg); color: var(--status-danger-text); }
.os-badge-info { background: var(--status-info-bg); color: var(--status-info-text); }

/* 9. Live Autonomous Pulse Dot */
.os-pulse-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: var(--status-success);
  display: inline-block;
  position: relative;
}

.os-pulse-dot::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  background-color: var(--status-success);
  opacity: 0.4;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0% { transform: scale(1); opacity: 0.5; }
  70% { transform: scale(2.2); opacity: 0; }
  100% { transform: scale(1); opacity: 0; }
}

/* 10. Responsive Breakpoints */
@media (max-width: 900px) {
  .os-sidebar {
    position: fixed;
    transform: translateX(-100%);
    box-shadow: var(--shadow-xl);
  }
  .os-sidebar.open {
    transform: translateX(0);
  }
}
