/**
 * ARIA Design System v2 — Components
 * Clean, minimal components inspired by BizLink CRM
 */

/* ============================================
   APP LAYOUT — Sidebar + Content
   ============================================ */

.app-layout {
  display: flex;
  min-height: 100vh;
}

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
  width: var(--sidebar-width);
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: var(--z-sidebar);
  transition: width var(--transition-slow);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  padding: var(--space-6) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.sidebar-logo {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
}

.sidebar-logo-icon {
  width: 32px;
  height: 32px;
  background: var(--color-black);
  border-radius: var(--radius-lg);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-white);
  font-weight: var(--font-bold);
  font-size: var(--text-sm);
  flex-shrink: 0;
}

.sidebar-nav {
  padding: var(--space-2) var(--space-3);
  flex: 1;
}

.sidebar-section {
  margin-bottom: var(--space-6);
}

.sidebar-section-label {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  padding: var(--space-2) var(--space-3);
  margin-bottom: var(--space-1);
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-lg);
  color: var(--text-secondary);
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  transition: all var(--transition-fast);
  cursor: pointer;
  text-decoration: none;
  position: relative;
}

.sidebar-link:hover {
  background: var(--color-gray-100);
  color: var(--text-primary);
  text-decoration: none;
}

.sidebar-link.active {
  background: var(--color-gray-100);
  color: var(--text-primary);
  font-weight: var(--font-semibold);
}

.sidebar-link-icon {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-link-badge {
  margin-left: auto;
  background: var(--color-gray-200);
  color: var(--text-secondary);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  min-width: 22px;
  text-align: center;
}

/* Sidebar footer — members / user info */
.sidebar-footer {
  padding: var(--space-4) var(--space-3);
  border-top: 1px solid var(--border-color);
}

.sidebar-footer-label {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  padding: var(--space-1) var(--space-3);
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background var(--transition-fast);
}

.sidebar-user:hover {
  background: var(--color-gray-100);
}

.sidebar-user-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background: var(--color-gray-200);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-semibold);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  flex-shrink: 0;
  overflow: hidden;
}

.sidebar-user-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

/* Sidebar: icon-only mode (collapsed, no text) */
.sidebar.sidebar-icon-only {
  width: var(--sidebar-collapsed-width);
}
.sidebar.sidebar-icon-only .sidebar-link span:not(.sidebar-link-icon) {
  display: none;
}
.sidebar.sidebar-icon-only .sidebar-link {
  justify-content: center;
  padding: 12px;
}
.sidebar.sidebar-icon-only .sidebar-link .sidebar-link-icon {
  margin: 0;
}
.sidebar.sidebar-icon-only .sidebar-section-label {
  display: none;
}
.sidebar.sidebar-icon-only .sidebar-user span,
.sidebar.sidebar-icon-only .sidebar-user div:not(:first-child) {
  display: none;
}
.sidebar.sidebar-icon-only .sidebar-user {
  justify-content: center;
}
.sidebar.sidebar-icon-only ~ .main-content,
.sidebar-icon-only ~ .main-content {
  margin-left: var(--sidebar-collapsed-width);
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  min-height: 100vh;
}

.content-header {
  padding: var(--space-5) var(--space-8);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-section);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

.content-body {
  padding: var(--space-6) var(--space-8);
}

/* ============================================
   SEARCH BAR
   ============================================ */

.search-bar {
  position: relative;
  width: 100%;
  max-width: 400px;
}

.search-bar-icon {
  position: absolute;
  left: var(--space-4);
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  width: 16px;
  height: 16px;
}

.search-bar input {
  width: 100%;
  padding: var(--space-2-5, 10px) var(--space-4) var(--space-2-5, 10px) var(--space-10);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  font-family: var(--font-family);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-input);
  transition: all var(--transition-fast);
  outline: none;
}

.search-bar input::placeholder {
  color: var(--text-muted);
}

.search-bar input:focus {
  border-color: var(--border-color-focus);
  box-shadow: 0 0 0 3px rgba(31, 31, 31, 0.06);
}

/* ============================================
   BUTTONS
   ============================================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-2-5, 10px) var(--space-4);
  border: 1px solid transparent;
  border-radius: var(--radius-lg);
  font-family: var(--font-family);
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  line-height: var(--leading-none);
  text-decoration: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  outline: none;
}

.btn:focus-visible {
  box-shadow: 0 0 0 2px var(--bg-body), 0 0 0 4px var(--color-black);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Primary — solid dark */
.btn-primary {
  background: var(--color-black);
  color: var(--color-white);
  border-color: var(--color-black);
}

.btn-primary:hover:not(:disabled) {
  background: var(--color-accent-hover);
}

/* Secondary — outline */
.btn-secondary {
  background: var(--color-white);
  color: var(--text-primary);
  border-color: var(--border-color);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--color-gray-50);
  border-color: var(--border-color-hover);
}

/* Ghost — no border */
.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}

.btn-ghost:hover:not(:disabled) {
  background: var(--color-gray-100);
  color: var(--text-primary);
}

/* Danger */
.btn-danger {
  background: var(--color-danger);
  color: var(--color-white);
  border-color: var(--color-danger);
}

.btn-danger:hover:not(:disabled) {
  background: #dc2626;
}

/* Success */
.btn-success {
  background: var(--color-success);
  color: var(--color-white);
  border-color: var(--color-success);
}

.btn-success:hover:not(:disabled) {
  background: #16a34a;
}

/* Button sizes */
.btn-xs {
  padding: var(--space-1) var(--space-2);
  font-size: var(--text-xs);
  border-radius: var(--radius-md);
}

.btn-sm {
  padding: var(--space-1-5) var(--space-3);
  font-size: var(--text-sm);
}

.btn-lg {
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-lg);
}

.btn-block {
  width: 100%;
}

/* Icon-only button */
.btn-icon {
  padding: var(--space-2);
  width: 36px;
  height: 36px;
}

.btn-icon.btn-sm {
  width: 28px;
  height: 28px;
  padding: var(--space-1);
}

/* Loading state */
.btn.loading {
  pointer-events: none;
  position: relative;
  color: transparent;
}

.btn.loading::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

.btn-primary.loading::after {
  border-color: var(--color-white);
  border-right-color: transparent;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ============================================
   CARDS
   ============================================ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  transition: all var(--transition-fast);
}

.card:hover {
  border-color: var(--border-color-hover);
}

.card-interactive:hover {
  box-shadow: var(--shadow-card-hover);
  cursor: pointer;
}

.card-header {
  padding-bottom: var(--space-4);
  margin-bottom: var(--space-4);
  border-bottom: 1px solid var(--border-color-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin: 0;
}

.card-body {
  flex: 1;
}

.card-footer {
  padding-top: var(--space-4);
  margin-top: var(--space-4);
  border-top: 1px solid var(--border-color-subtle);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

/* Card dark variant — highlighted item */
.card-dark {
  background: var(--color-black);
  border-color: var(--color-black);
  color: var(--color-white);
}

.card-dark .card-title,
.card-dark .text-primary {
  color: var(--color-white);
}

.card-dark .text-secondary,
.card-dark .text-muted {
  color: var(--color-gray-400);
}

/* ============================================
   STAT CARDS
   ============================================ */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--space-4);
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.stat-card-label {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
}

.stat-card-value {
  font-size: var(--text-3xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-none);
}

.stat-card-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-sm);
}

.stat-card-change {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-weight: var(--font-medium);
}

.stat-card-change.positive { color: var(--color-success); }
.stat-card-change.negative { color: var(--color-danger); }

.stat-card-link {
  margin-left: auto;
  color: var(--text-muted);
  cursor: pointer;
  transition: color var(--transition-fast);
}

.stat-card-link:hover {
  color: var(--text-primary);
}

/* ============================================
   STATS BAR (Inline horizontal stats)
   ============================================ */

.stats-bar {
  display: flex;
  align-items: stretch;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.stats-bar-item {
  flex: 1;
  padding: var(--space-5) var(--space-6);
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  border-right: 1px solid var(--border-color-subtle);
  position: relative;
}

.stats-bar-item:last-child {
  border-right: none;
}

.stats-bar-item-label {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  font-weight: var(--font-medium);
}

.stats-bar-item-value {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
}

/* ============================================
   KANBAN BOARD
   ============================================ */

.kanban-board {
  display: flex;
  gap: var(--space-4);
  overflow-x: auto;
  padding-bottom: var(--space-4);
}

.kanban-column {
  flex: 1;
  min-width: 280px;
}

.kanban-column-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) 0;
  margin-bottom: var(--space-3);
}

.kanban-column-title {
  font-size: var(--text-lg);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.kanban-column-count {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
}

.kanban-cards {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.kanban-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-4);
  transition: all var(--transition-fast);
  cursor: pointer;
}

.kanban-card:hover {
  border-color: var(--border-color-hover);
  box-shadow: var(--shadow-card-hover);
}

.kanban-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.kanban-card-title {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.kanban-card-desc {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  margin-bottom: var(--space-3);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.kanban-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.kanban-card-date {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  padding: var(--space-1) var(--space-2);
  background: var(--color-gray-100);
  border-radius: var(--radius-md);
}

.kanban-card-meta {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.kanban-card-meta-item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

/* Dark kanban card (highlighted) */
.kanban-card-dark {
  background: var(--color-black);
  border-color: var(--color-black);
}

.kanban-card-dark .kanban-card-title { color: var(--color-white); }
.kanban-card-dark .kanban-card-desc { color: var(--color-gray-400); }
.kanban-card-dark .kanban-card-date {
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-gray-300);
}
.kanban-card-dark .kanban-card-meta { color: var(--color-gray-400); }

/* ============================================
   TABLE
   ============================================ */

.table-container {
  overflow-x: auto;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  background: var(--bg-card);
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead th {
  padding: var(--space-3) var(--space-4);
  text-align: left;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  background: var(--color-gray-50);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

tbody td {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  color: var(--text-primary);
  border-bottom: 1px solid var(--border-color-subtle);
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--color-gray-50);
}

/* ============================================
   FORMS
   ============================================ */

.form-group {
  margin-bottom: var(--space-5);
}

.form-group.full-width {
  grid-column: 1 / -1;
}

.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-primary);
  margin-bottom: var(--space-1-5);
}

.form-hint {
  display: block;
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-top: var(--space-1);
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: var(--space-2-5, 10px) var(--space-3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  font-family: var(--font-family);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: var(--bg-input);
  transition: all var(--transition-fast);
  outline: none;
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--text-muted);
}

.form-input:hover,
.form-select:hover,
.form-textarea:hover {
  border-color: var(--border-color-hover);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  border-color: var(--border-color-focus);
  box-shadow: 0 0 0 3px rgba(31, 31, 31, 0.06);
}

.form-input:disabled,
.form-select:disabled,
.form-textarea:disabled {
  background: var(--color-gray-100);
  cursor: not-allowed;
  opacity: 0.7;
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

.form-input.error,
.form-select.error,
.form-textarea.error {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.form-error {
  font-size: var(--text-xs);
  color: var(--color-danger);
  margin-top: var(--space-1);
}

/* Form grid */
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4) var(--space-6);
}

/* ============================================
   CHECKBOX & RADIO (Custom)
   ============================================ */

.checkbox-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.radio-group {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.checkbox-label,
.radio-label {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
  font-size: var(--text-base);
  color: var(--text-primary);
}

.checkbox-label input[type="checkbox"],
.radio-label input[type="radio"] {
  appearance: none;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  position: relative;
}

.radio-label input[type="radio"] {
  border-radius: var(--radius-full);
}

.checkbox-label input[type="checkbox"]:checked,
.radio-label input[type="radio"]:checked {
  background: var(--color-black);
  border-color: var(--color-black);
}

.checkbox-label input[type="checkbox"]:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 1px;
  width: 6px;
  height: 10px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

.radio-label input[type="radio"]:checked::after {
  content: '';
  position: absolute;
  left: 4px;
  top: 4px;
  width: 6px;
  height: 6px;
  background: white;
  border-radius: var(--radius-full);
}

/* ============================================
   TOGGLE / SWITCH
   ============================================ */

.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  cursor: pointer;
}

.toggle input {
  appearance: none;
  width: 44px;
  height: 24px;
  background: var(--color-gray-300);
  border-radius: var(--radius-full);
  transition: background var(--transition-fast);
  cursor: pointer;
  position: relative;
}

.toggle input::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: white;
  border-radius: var(--radius-full);
  transition: transform var(--transition-fast);
  box-shadow: var(--shadow-sm);
}

.toggle input:checked {
  background: var(--color-black);
}

.toggle input:checked::after {
  transform: translateX(20px);
}

.toggle-label {
  font-size: var(--text-base);
  color: var(--text-primary);
}

/* ============================================
   BADGES & TAGS
   ============================================ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-0-5) var(--space-2);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  white-space: nowrap;
  line-height: var(--leading-relaxed);
}

.badge-default {
  background: var(--color-gray-100);
  color: var(--text-secondary);
}

.badge-primary {
  background: var(--color-black);
  color: var(--color-white);
}

.badge-success {
  background: var(--color-success-light);
  color: #15803d;
}

.badge-danger {
  background: var(--color-danger-light);
  color: #dc2626;
}

.badge-warning {
  background: var(--color-warning-light);
  color: #b45309;
}

.badge-info {
  background: var(--color-info-light);
  color: #2563eb;
}

/* Dot indicator */
.badge-dot::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: var(--radius-full);
  background: currentColor;
}

/* Tag (removable) */
.tag {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  background: var(--color-gray-100);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  color: var(--text-primary);
}

.tag-remove {
  display: inline-flex;
  cursor: pointer;
  color: var(--text-muted);
  transition: color var(--transition-fast);
}

.tag-remove:hover {
  color: var(--color-danger);
}

/* ============================================
   AVATAR
   ============================================ */

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  background: var(--color-gray-200);
  color: var(--text-secondary);
  font-weight: var(--font-semibold);
  flex-shrink: 0;
  overflow: hidden;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-xs { width: 24px; height: 24px; font-size: var(--text-xs); }
.avatar-sm { width: 32px; height: 32px; font-size: var(--text-sm); }
.avatar-md { width: 40px; height: 40px; font-size: var(--text-base); }
.avatar-lg { width: 48px; height: 48px; font-size: var(--text-lg); }
.avatar-xl { width: 64px; height: 64px; font-size: var(--text-2xl); }

.avatar-group {
  display: flex;
}

.avatar-group .avatar {
  border: 2px solid var(--color-white);
  margin-left: -8px;
}

.avatar-group .avatar:first-child {
  margin-left: 0;
}

/* ============================================
   MODALS
   ============================================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-base);
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: var(--bg-card);
  border-radius: var(--radius-2xl);
  padding: var(--space-6);
  width: 100%;
  max-width: 480px;
  max-height: 90vh;
  overflow-y: auto;
  transform: scale(0.95) translateY(10px);
  transition: transform var(--transition-base);
  box-shadow: var(--shadow-xl);
}

.modal-overlay.active .modal {
  transform: scale(1) translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.modal-title {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  color: var(--text-muted);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.modal-close:hover {
  background: var(--color-gray-100);
  color: var(--text-primary);
}

.modal-body {
  margin-bottom: var(--space-6);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-3);
}

/* ============================================
   ALERTS / TOAST
   ============================================ */

.alert {
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  border: 1px solid;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.alert-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.alert-content {
  flex: 1;
}

.alert-title {
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-1);
}

.alert-success {
  background: var(--color-success-light);
  border-color: #bbf7d0;
  color: #15803d;
}

.alert-danger {
  background: var(--color-danger-light);
  border-color: #fecaca;
  color: #dc2626;
}

.alert-warning {
  background: var(--color-warning-light);
  border-color: #fde68a;
  color: #b45309;
}

.alert-info {
  background: var(--color-info-light);
  border-color: #bfdbfe;
  color: #2563eb;
}

/* ============================================
   TABS
   ============================================ */

.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border-color);
  margin-bottom: var(--space-6);
}

.tab {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--transition-fast);
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--color-black);
}

/* ============================================
   DROPDOWN / SELECT MENU
   ============================================ */

.dropdown {
  position: relative;
  display: inline-block;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + var(--space-1));
  right: 0;
  min-width: 180px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-1);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: all var(--transition-fast);
}

.dropdown-menu.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-base);
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--transition-fast);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.dropdown-item:hover {
  background: var(--color-gray-100);
}

.dropdown-item.danger {
  color: var(--color-danger);
}

.dropdown-divider {
  height: 1px;
  background: var(--border-color-subtle);
  margin: var(--space-1) 0;
}

/* ============================================
   TOOLTIP
   ============================================ */

.tooltip {
  position: relative;
}

.tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  padding: var(--space-1) var(--space-2);
  background: var(--color-gray-900);
  color: var(--color-white);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  border-radius: var(--radius-md);
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.tooltip:hover::after {
  opacity: 1;
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
  text-align: center;
  padding: var(--space-10) var(--space-6);
  max-width: 520px;
  margin: 0 auto;
}

.empty-state-icon {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: var(--color-gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto var(--space-5);
}

.empty-state-icon i,
.empty-state-icon svg {
  width: 32px;
  height: 32px;
  color: var(--text-muted);
}

.empty-state h3 {
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin: 0 0 var(--space-2);
}

.empty-state p {
  font-size: var(--text-sm);
  color: var(--text-muted);
  margin: 0 0 var(--space-6);
  line-height: 1.6;
}

.empty-state-steps {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  text-align: left;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
}

.empty-state-step {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
}

.empty-state-step-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-black);
  color: white;
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: 1px;
}

.empty-state-step-text {
  font-size: var(--text-sm);
  color: var(--text-primary);
  line-height: 1.5;
}

.empty-state-step-text strong {
  font-weight: var(--font-semibold);
}

.empty-state-step-text span {
  color: var(--text-muted);
}

/* ============================================
   PROGRESS BAR
   ============================================ */

.progress {
  width: 100%;
  height: 6px;
  background: var(--color-gray-200);
  border-radius: var(--radius-full);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: var(--color-black);
  border-radius: var(--radius-full);
  transition: width var(--transition-slow);
}

.progress-bar.success { background: var(--color-success); }
.progress-bar.warning { background: var(--color-warning); }
.progress-bar.danger { background: var(--color-danger); }

/* ============================================
   COLLAPSIBLE SECTIONS
   ============================================ */

.section {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  overflow: hidden;
}

.section + .section {
  margin-top: var(--space-3);
}

.section-header {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  cursor: pointer;
  transition: background var(--transition-fast);
  user-select: none;
}

.section-header:hover {
  background: var(--color-gray-50);
}

.section-icon {
  width: 20px;
  height: 20px;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.section-title {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  flex: 1;
}

.section-toggle {
  width: 20px;
  height: 20px;
  color: var(--text-muted);
  transition: transform var(--transition-fast);
}

.section.collapsed .section-toggle {
  transform: rotate(-90deg);
}

.section-content {
  padding: 0 var(--space-5) var(--space-5);
  overflow: hidden;
  transition: max-height var(--transition-slow), padding var(--transition-slow);
}

.section.collapsed .section-content {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
}

/* ============================================
   LOADING
   ============================================ */

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid var(--border-color);
  border-top-color: var(--color-black);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.spinner-lg {
  width: 40px;
  height: 40px;
  border-width: 3px;
}

.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(250, 250, 248, 0.85);
  backdrop-filter: blur(4px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-4);
  z-index: var(--z-modal);
}

.loading-overlay p {
  color: var(--text-secondary);
  font-weight: var(--font-medium);
}

.skeleton {
  background: linear-gradient(90deg, var(--color-gray-100) 25%, var(--color-gray-50) 50%, var(--color-gray-100) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s ease-in-out infinite;
  border-radius: var(--radius-md);
}

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================
   RADIO CARDS (selectable option cards)
   ============================================ */

.radio-card {
  flex: 1;
  position: relative;
  min-width: 120px;
}

.radio-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.radio-card input[type="radio"] + span {
  display: block;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-fast);
  font-weight: var(--font-medium);
  font-size: var(--text-sm);
  background: var(--bg-card);
}

.radio-card input[type="radio"]:checked + span {
  border-color: var(--color-black);
  background: var(--color-accent-light);
  font-weight: var(--font-semibold);
}

.radio-card input[type="radio"]:hover:not(:checked) + span {
  border-color: var(--border-color-hover);
  background: var(--color-gray-50);
}

.radio-card input[type="radio"]:focus + span {
  box-shadow: 0 0 0 2px var(--bg-body), 0 0 0 4px var(--color-black);
}

/* Horizontal radio group (for radio-cards) */
.radio-group-horizontal {
  display: flex;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* ============================================
   VOICE SELECTOR
   ============================================ */

.voice-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}

.voice-card {
  position: relative;
}

.voice-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.voice-content {
  position: relative;
  padding: var(--space-3);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-fast);
  background: var(--bg-card);
}

.voice-card input[type="radio"]:checked ~ .voice-content {
  border-color: var(--color-black);
  border-width: 2px;
  background: var(--color-accent-light);
}

/* Checkmark for selected voice */
.voice-card input[type="radio"]:checked ~ .voice-content::after {
  content: '\2713';
  position: absolute;
  top: 8px;
  right: 8px;
  width: 20px;
  height: 20px;
  background: var(--color-black);
  color: var(--color-white);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: var(--font-bold);
}

.voice-card input[type="radio"]:hover:not(:checked) ~ .voice-content {
  border-color: var(--border-color-hover);
  background: var(--color-gray-50);
}

.voice-icon {
  font-size: var(--text-2xl);
  margin-bottom: var(--space-1);
}

.voice-content h4 {
  color: var(--text-primary);
  margin-bottom: 2px;
  font-size: var(--text-sm);
  font-weight: var(--font-semibold);
}

.voice-content p {
  font-size: var(--text-xs);
  color: var(--text-muted);
  margin-bottom: var(--space-1);
  line-height: var(--leading-snug);
}

.voice-language {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  font-weight: var(--font-medium);
}

/* Recommended voice badge */
.voice-card.recommended .voice-content {
  border-color: var(--color-success);
  background: var(--color-success-light);
}

.voice-card.recommended .voice-content::before {
  content: 'Recommande';
  position: absolute;
  top: -8px;
  right: 8px;
  background: var(--color-success);
  color: var(--color-white);
  font-size: 9px;
  font-weight: var(--font-bold);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
}

.voice-card.recommended input[type="radio"]:checked ~ .voice-content {
  border-color: var(--color-success);
  border-width: 2px;
  background: var(--color-success-light);
}

.voice-card.recommended input[type="radio"]:checked ~ .voice-content::after {
  background: var(--color-success);
}

/* ============================================
   CHARTS & ANALYTICS
   ============================================ */

/* Chart container — wrapper for Chart.js or any chart lib */
.chart-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
}

.chart-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}

.chart-card-title {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.chart-card-title i {
  color: var(--text-muted);
}

.chart-card-actions {
  display: flex;
  gap: var(--space-1);
}

.chart-card-body {
  position: relative;
}

/* Chart period selector (tabs-style) */
.chart-period-selector {
  display: flex;
  gap: var(--space-0-5);
  background: var(--color-gray-100);
  padding: 3px;
  border-radius: var(--radius-md);
}

.chart-period-btn {
  padding: var(--space-1) var(--space-3);
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  font-family: var(--font-family);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.chart-period-btn:hover {
  color: var(--text-primary);
}

.chart-period-btn.active {
  background: var(--color-white);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

/* Charts grid layout */
.charts-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-4);
}

.charts-grid .chart-card.full-width {
  grid-column: 1 / -1;
}

/* Chart legend — custom, cleaner than Chart.js defaults */
.chart-legend {
  display: flex;
  gap: var(--space-4);
  justify-content: center;
  padding-top: var(--space-3);
}

.chart-legend-item {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  font-size: var(--text-xs);
  color: var(--text-secondary);
  font-weight: var(--font-medium);
}

.chart-legend-dot {
  width: 8px;
  height: 8px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

/* Chart.js theme overrides — neutral palette */
/* Apply via Chart.js defaults in JS:
   Chart.defaults.font.family = 'Inter, sans-serif';
   Chart.defaults.color = '#737373';        // --text-secondary
   Chart.defaults.borderColor = '#e8e8e6';  // --border-color
*/

/* Mini sparkline — tiny inline chart */
.sparkline {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 32px;
}

.sparkline-bar {
  flex: 1;
  background: var(--color-black);
  border-radius: 2px 2px 0 0;
  min-height: 2px;
  opacity: 0.7;
  transition: opacity var(--transition-fast);
}

.sparkline-bar:last-child {
  opacity: 1;
}

.sparkline:hover .sparkline-bar {
  opacity: 0.4;
}

.sparkline:hover .sparkline-bar:hover {
  opacity: 1;
}

/* Mini donut / gauge — CSS only */
.donut {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  /* Use conic-gradient with --donut-value (0-100) in inline style */
  /* e.g. style="--donut-value: 68" */
  background: conic-gradient(
    var(--color-black) calc(var(--donut-value, 0) * 1%),
    var(--color-gray-200) calc(var(--donut-value, 0) * 1%)
  );
}

.donut-inner {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-sm);
  font-weight: var(--font-bold);
  color: var(--text-primary);
}

/* Metric card with sparkline */
.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  padding: var(--space-4) var(--space-5);
  display: flex;
  align-items: center;
  gap: var(--space-4);
}

.metric-card-data {
  flex: 1;
  min-width: 0;
}

.metric-card-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-weight: var(--font-medium);
  text-transform: uppercase;
  letter-spacing: var(--tracking-wider);
  margin-bottom: var(--space-1);
}

.metric-card-value {
  font-size: var(--text-2xl);
  font-weight: var(--font-bold);
  color: var(--text-primary);
  line-height: var(--leading-none);
  margin-bottom: var(--space-1);
}

.metric-card-change {
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  display: inline-flex;
  align-items: center;
  gap: var(--space-0-5);
}

.metric-card-change.up { color: var(--color-success); }
.metric-card-change.down { color: var(--color-danger); }
.metric-card-change.neutral { color: var(--text-muted); }

.metric-card-chart {
  width: 80px;
  flex-shrink: 0;
}

/* Chart color palette — use these as dataset colors */
/*
  --chart-1: #1f1f1f   (black — primary series)
  --chart-2: #a3a3a3   (gray — secondary series)
  --chart-3: #d4d4d4   (light gray — tertiary)
  --chart-4: #22c55e   (success green — positive)
  --chart-5: #ef4444   (danger red — negative)
  --chart-6: #f6f7ed   (cream — area fill)
  --chart-area: rgba(31, 31, 31, 0.06)  (area fill under line)
*/

/* ============================================
   HEADER CARD — Spotify-style color gradient
   ============================================ */

.header-card {
  position: relative;
  border-radius: var(--radius-2xl);
  padding: var(--space-6) var(--space-8);
  width: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-5);
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.12);
  background: var(--bg-card);
  transition: background 0.6s ease;
}

.header-card-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  opacity: 0;
  transition: opacity 0.8s ease;
}

.header-card-bg.ready {
  opacity: 1;
}

/* Noise texture overlay for depth */
.header-card-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
  background-size: 128px;
  pointer-events: none;
}

.header-card-avatar {
  position: relative;
  z-index: 1;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-xl);
  overflow: hidden;
  background: rgba(255,255,255,0.15);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-bold);
  font-size: var(--text-xl);
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.header-card-avatar img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  padding: 4px;
}

.header-card-text {
  position: relative;
  z-index: 1;
  flex: 1;
  min-width: 0;
}

.header-card-text h1 {
  font-size: var(--text-xl);
  font-weight: var(--font-bold);
  margin: 0;
  line-height: var(--leading-tight);
}

.header-card-text p {
  font-size: var(--text-sm);
  margin: var(--space-0-5) 0 0;
}

.header-card-actions {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* Dark gradient — always white text (colors are pre-darkened to ~40%) */
.header-card.dark-bg { border-color: rgba(255,255,255,0.06); }
.header-card.dark-bg .header-card-text h1 { color: #fff; }
.header-card.dark-bg .header-card-text p { color: rgba(255,255,255,0.65); }
.header-card.dark-bg .header-card-avatar {
  color: rgba(255,255,255,0.9);
  background: rgba(255,255,255,0.12);
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}
.header-card.dark-bg .header-card-actions { color: rgba(255,255,255,0.6); }

/* No logo fallback — plain card */
.header-card.no-logo {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
}
.header-card.no-logo .header-card-text h1 { color: var(--text-primary); }
.header-card.no-logo .header-card-text p { color: var(--text-secondary); opacity: 1; }
.header-card.no-logo .header-card-avatar {
  background: var(--color-cream, #f6f7ed);
  backdrop-filter: none;
  box-shadow: none;
  color: var(--color-black);
}

/* ============================================
   CLIENT LIST
   ============================================ */

.client-list-item {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  transition: all var(--transition-fast);
  cursor: pointer;
  background: var(--bg-card);
}

.client-list-item:hover {
  border-color: var(--border-color-hover);
  background: var(--color-gray-50);
}

.client-list-item + .client-list-item {
  margin-top: var(--space-2);
}

.client-list-avatar {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-xl);
  background: var(--color-cream);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-bold);
  font-size: var(--text-lg);
  color: var(--color-black);
  flex-shrink: 0;
  overflow: hidden;
}

.client-list-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.client-list-info {
  flex: 1;
  min-width: 0;
}

.client-list-name {
  font-weight: var(--font-semibold);
  font-size: var(--text-base);
  margin-bottom: var(--space-0-5);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.client-list-meta {
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

.client-list-stats {
  display: flex;
  gap: var(--space-6);
  align-items: center;
}

.client-list-stat {
  text-align: center;
}

.client-list-stat-value {
  font-size: var(--text-lg);
  font-weight: var(--font-bold);
}

.client-list-stat-label {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.client-list-actions {
  display: flex;
  gap: var(--space-1);
  align-items: center;
}

@media (max-width: 768px) {
  .client-list-item {
    flex-wrap: wrap;
    padding: var(--space-3) var(--space-4);
  }
  .client-list-stats {
    width: 100%;
    justify-content: flex-start;
    gap: var(--space-4);
  }
  .client-list-actions {
    width: 100%;
    justify-content: flex-end;
  }
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 1024px) {
  .sidebar {
    width: var(--sidebar-collapsed-width);
  }
  .sidebar .sidebar-header {
    padding: var(--space-4) var(--space-3);
    justify-content: center;
  }
  .sidebar .sidebar-header > div,
  .sidebar .sidebar-logo {
    display: none;
  }
  .sidebar .sidebar-header img {
    height: 40px !important;
    width: 40px !important;
    object-fit: contain;
  }
  .sidebar .sidebar-link span:not(.sidebar-link-icon) {
    display: none;
  }
  .sidebar .sidebar-link {
    justify-content: center;
    padding: var(--space-2) var(--space-3);
  }
  .sidebar .sidebar-section-label {
    display: none;
  }
  .sidebar .sidebar-footer {
    display: none;
  }

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

  .kanban-board {
    flex-direction: column;
  }

  .kanban-column {
    min-width: 100%;
  }

  .charts-grid {
    grid-template-columns: 1fr;
  }

  .voice-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    width: var(--sidebar-width);
  }
  /* Restore hidden elements when sidebar is fully open on mobile */
  .sidebar .sidebar-header > div,
  .sidebar .sidebar-logo,
  .sidebar .sidebar-link span:not(.sidebar-link-icon),
  .sidebar .sidebar-section-label,
  .sidebar .sidebar-footer {
    display: revert;
  }
  .sidebar .sidebar-header {
    padding: var(--space-6) var(--space-5);
    justify-content: flex-start;
  }
  .sidebar .sidebar-link {
    justify-content: flex-start;
    padding: var(--space-2) var(--space-3);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .main-content {
    margin-left: 0;
  }

  .content-header {
    padding: var(--space-4);
  }

  .content-body {
    padding: var(--space-4);
  }

  .form-grid {
    grid-template-columns: 1fr;
  }

  .stats-bar {
    flex-direction: column;
  }

  .stats-bar-item {
    border-right: none;
    border-bottom: 1px solid var(--border-color-subtle);
  }

  .stats-bar-item:last-child {
    border-bottom: none;
  }

  .voice-grid {
    grid-template-columns: 1fr;
  }

  .radio-group {
    flex-direction: column;
  }
}

/* ============================================
   LANGUAGE SWITCHER
   ============================================ */

.language-switcher {
  display: flex;
  gap: 2px;
  background: var(--color-gray-100);
  border-radius: var(--radius-lg);
  padding: 2px;
}

.lang-btn {
  padding: 4px 10px;
  border: none;
  border-radius: var(--radius-md);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  cursor: pointer;
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-family);
  transition: all var(--transition-fast);
  line-height: 1.4;
}

.lang-btn:hover {
  color: var(--text-secondary);
}

.lang-btn.active {
  background: var(--color-white);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* Login page variant (dark background) */
.language-switcher--login {
  position: absolute;
  top: var(--space-4);
  right: var(--space-4);
}

/* ============================================
   PROFILE POPOVER (Sidebar Footer)
   ============================================ */

.sidebar-profile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: background var(--transition-fast);
  position: relative;
}

.sidebar-profile:hover {
  background: var(--color-gray-50);
}

.sidebar-profile-avatar {
  width: 32px;
  height: 32px;
  background: var(--color-black);
  color: var(--color-white);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.sidebar-profile-info {
  flex: 1;
  min-width: 0;
}

.sidebar-profile-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-profile-role {
  font-size: 11px;
  color: var(--text-muted);
}

.sidebar-profile-chevron {
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  flex-shrink: 0;
  transition: transform var(--transition-fast);
}

.sidebar-profile.open .sidebar-profile-chevron {
  transform: rotate(180deg);
}

/* Popover */
.profile-popover {
  display: none;
  position: absolute;
  bottom: calc(100% + 8px);
  left: 12px;
  right: 12px;
  background: var(--color-white);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  z-index: 100;
  overflow: hidden;
  animation: popoverIn 0.15s ease;
}

.profile-popover.show {
  display: block;
}

@keyframes popoverIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.profile-popover-header {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border-color-subtle, var(--border-color));
}

.profile-popover-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
}

.profile-popover-email {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.profile-popover-section {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
}

.profile-popover-label {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

.profile-popover-divider {
  height: 1px;
  background: var(--border-color-subtle, var(--border-color));
}

.profile-popover-action {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: all var(--transition-fast);
  cursor: pointer;
}

.profile-popover-action:hover {
  background: var(--color-gray-50);
  color: var(--text-primary);
}

@media (max-width: 480px) {
  .btn {
    font-size: var(--text-sm);
  }
}

/* ============================================
   PHONE INPUT
   ============================================ */

.phone-input-wrapper {
  display: flex;
  align-items: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-input);
  transition: all var(--transition-fast);
  overflow: hidden;
  position: relative;
}

.phone-input-wrapper:hover {
  border-color: var(--border-color-hover);
}

.phone-input-wrapper.focused {
  border-color: var(--border-color-focus);
  box-shadow: 0 0 0 3px rgba(31, 31, 31, 0.06);
}

.phone-input-wrapper.valid {
  border-color: var(--color-success);
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.08);
}

.phone-input-wrapper.error {
  border-color: var(--color-danger);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.phone-input-wrapper.disabled {
  background: var(--color-gray-100);
  cursor: not-allowed;
  opacity: 0.7;
}

.country-selector {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  padding: var(--space-2-5, 10px) var(--space-3);
  background: var(--color-gray-50);
  border: none;
  border-right: 1px solid var(--border-color);
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  transition: background var(--transition-fast);
  font-family: var(--font-family);
}

.country-selector:hover {
  background: var(--color-gray-100);
}

.phone-input-wrapper.disabled .country-selector {
  cursor: not-allowed;
  pointer-events: none;
}

.country-flag {
  font-size: 18px;
  line-height: 1;
}

.country-code {
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--text-secondary);
}

.country-chevron {
  font-size: 8px;
  color: var(--text-muted);
  margin-left: 2px;
}

.country-dropdown {
  position: absolute;
  top: calc(100% + var(--space-1));
  left: 0;
  min-width: 200px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-input);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-dropdown);
  opacity: 0;
  pointer-events: none;
  transform: translateY(-4px);
  transition: all var(--transition-fast);
}

.country-dropdown.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.country-dropdown-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2-5, 10px) var(--space-3);
  cursor: pointer;
  transition: background var(--transition-fast);
  font-family: var(--font-family);
  font-size: var(--text-base);
  border-bottom: 1px solid var(--border-color-subtle);
}

.country-dropdown-item:last-child {
  border-bottom: none;
}

.country-dropdown-item:hover {
  background: var(--color-gray-100);
}

.country-dropdown-item.active {
  background: var(--color-gray-50);
  border-left: 2px solid var(--color-black);
}

.country-dropdown-item .country-item-flag {
  font-size: 18px;
  line-height: 1;
}

.country-dropdown-item .country-item-name {
  font-weight: var(--font-medium);
  color: var(--text-primary);
  flex: 1;
}

.country-dropdown-item .country-item-dial {
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.phone-number-input {
  flex: 1;
  border: none;
  outline: none;
  padding: var(--space-2-5, 10px) var(--space-3);
  font-family: var(--font-family);
  font-size: var(--text-base);
  color: var(--text-primary);
  background: transparent;
  min-width: 0;
}

.phone-number-input::placeholder {
  color: var(--text-muted);
}

.phone-input-wrapper.disabled .phone-number-input {
  cursor: not-allowed;
}

.phone-validation-icon {
  padding-right: var(--space-3);
  font-size: var(--text-base);
  flex-shrink: 0;
  font-weight: var(--font-semibold);
}

.phone-validation-icon.valid {
  color: var(--color-success);
}

.phone-validation-icon.error {
  color: var(--color-danger);
}

.phone-hint {
  font-size: var(--text-xs);
  margin-top: var(--space-1);
}

.phone-hint.text-success {
  color: var(--color-success);
}

.phone-hint.text-danger {
  color: var(--color-danger);
}
