/* ============================================================
   AGENCY OS — Base Styles
   Reset, global styles, typography, utilities
   ============================================================ */

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  font-size: var(--text-base);
  font-weight: var(--weight-regular);
  line-height: var(--leading-normal);
  color: var(--text-primary);
  background-color: var(--bg-app);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-x: hidden;
  min-height: 100vh;
}

/* ── Typography ── */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-heading);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  color: var(--text-primary);
  margin: 0;
}

h1 { font-size: var(--text-3xl); }
h2 { font-size: var(--text-2xl); }
h3 { font-size: var(--text-xl); }
h4 { font-size: var(--text-lg); }
h5 { font-size: var(--text-md); }
h6 { font-size: var(--text-base); }

p {
  margin: 0;
  color: var(--text-secondary);
}

a {
  color: var(--text-link);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover { color: var(--brand-primary-dark); }

strong { font-weight: var(--weight-semibold); }

small { font-size: var(--text-sm); }

/* ── Lists ── */
ul, ol { list-style: none; }

/* ── Images ── */
img, svg {
  display: block;
  max-width: 100%;
}

/* ── Buttons Reset ── */
button {
  font-family: inherit;
  font-size: inherit;
  cursor: pointer;
  border: none;
  background: none;
  outline: none;
  color: inherit;
}

/* ── Inputs Reset ── */
input, select, textarea {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
  outline: none;
}

input::placeholder, textarea::placeholder {
  color: var(--text-tertiary);
}

/* ── Table Reset ── */
table {
  border-collapse: collapse;
  width: 100%;
}

/* ── Scrollbar ── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--text-tertiary);
  border-radius: var(--radius-full);
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* ── Selection ── */
::selection {
  background: var(--brand-primary);
  color: var(--text-inverse);
}

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

.app-main {
  flex: 1;
  margin-left: var(--sidebar-width);
  transition: margin-left var(--transition-base);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.sidebar-collapsed .app-main {
  margin-left: var(--sidebar-collapsed-width);
}

.app-content {
  flex: 1;
  padding: var(--space-6);
  max-width: var(--content-max-width);
  width: 100%;
  margin: 0 auto;
}

/* ── Page Header ── */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
  gap: var(--space-4);
}

.page-header__left {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.page-header__title {
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
}

.page-header__subtitle {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.page-header__actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ── Page Sections ── */
.page-section {
  display: none;
}
.page-section.active {
  display: block;
}

/* ── Breadcrumb ── */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  margin-bottom: var(--space-4);
}
.breadcrumb a { color: var(--text-secondary); }
.breadcrumb a:hover { color: var(--brand-primary); }
.breadcrumb__separator { color: var(--text-tertiary); }
.breadcrumb__current { color: var(--text-primary); font-weight: var(--weight-medium); }

/* ── Status Pills ── */
.pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  line-height: 1.4;
}

.pill--active, .pill--completed, .pill--success {
  background: var(--brand-success-light);
  color: #0E7A6C;
}
.pill--pending, .pill--overdue, .pill--danger {
  background: var(--brand-danger-light);
  color: #B23E2C;
}
.pill--in-progress, .pill--warning {
  background: var(--brand-warning-light);
  color: #9A6600;
}
.pill--blocked, .pill--purple {
  background: var(--brand-purple-light);
  color: #5B3FA0;
}
.pill--new, .pill--info {
  background: var(--brand-info-light);
  color: #1D4ED8;
}
.pill--default {
  background: var(--bg-surface-hover);
  color: var(--text-secondary);
}

/* ── Priority Dots ── */
.priority-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  display: inline-block;
}
.priority-dot--high { background: var(--brand-danger); }
.priority-dot--medium { background: var(--brand-warning); }
.priority-dot--low { background: var(--brand-success); }

/* ── Progress Bar ── */
.progress-bar {
  background: var(--border-default);
  border-radius: var(--radius-full);
  height: 8px;
  width: 100%;
  overflow: hidden;
}

.progress-bar__fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--brand-primary), var(--brand-primary-light));
  transition: width var(--transition-slow);
  position: relative;
}

.progress-bar__fill::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
  animation: shimmer 2s infinite;
}

/* ── Avatar ── */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: linear-gradient(135deg, var(--brand-primary), var(--brand-primary-dark));
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--weight-semibold);
  font-size: var(--text-sm);
  flex-shrink: 0;
}
.avatar--sm { width: 28px; height: 28px; font-size: var(--text-xs); }
.avatar--lg { width: 48px; height: 48px; font-size: var(--text-md); }
.avatar--xl { width: 64px; height: 64px; font-size: var(--text-xl); }

/* ── Badge ── */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: var(--radius-full);
  font-size: 10px;
  font-weight: var(--weight-bold);
  background: var(--brand-danger);
  color: #fff;
}

/* ── Empty State ── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-6);
  text-align: center;
}
.empty-state__icon {
  font-size: 3rem;
  color: var(--text-tertiary);
  margin-bottom: var(--space-4);
  opacity: 0.5;
}
.empty-state__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  margin-bottom: var(--space-2);
}
.empty-state__text {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  max-width: 360px;
  margin-bottom: var(--space-6);
}

/* ── Divider ── */
.divider {
  height: 1px;
  background: var(--border-default);
  margin: var(--space-4) 0;
}

/* ── Grid Utilities ── */
.grid { display: grid; gap: var(--space-4); }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-auto { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }

/* ── Flex Utilities ── */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.justify-end { justify-content: flex-end; }
.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

/* ── Spacing Utilities ── */
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }

/* ── Text Utilities ── */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-sm { font-size: var(--text-sm); }
.text-xs { font-size: var(--text-xs); }
.text-muted { color: var(--text-secondary); }
.text-success { color: var(--brand-success); }
.text-danger { color: var(--brand-danger); }
.text-warning { color: var(--brand-warning); }
.text-primary-brand { color: var(--brand-primary); }
.font-semibold { font-weight: var(--weight-semibold); }
.font-bold { font-weight: var(--weight-bold); }
.truncate {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Visibility ── */
.hidden { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
