/* Shared Component Styles — Dribbble-refined */

/* === PAGE CONTENT ANIMATION === */
.app-content > * {
  animation: pageContentIn 0.3s ease-out;
}

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

/* === BUTTONS === */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: var(--touch-min);
  padding: var(--space-3) var(--space-6);
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  cursor: pointer;
  border: 2px solid transparent;
  text-decoration: none;
  white-space: nowrap;
}

.btn:focus-visible { box-shadow: var(--shadow-focus); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:active:not(:disabled) { transform: scale(0.97); transition-duration: 80ms; }

.btn-primary {
  background: var(--color-primary);
  color: white;
  box-shadow: 0 2px 4px rgba(27, 122, 74, 0.2);
}
.btn-primary:hover:not(:disabled) { background: var(--color-primary-dark); box-shadow: 0 4px 12px rgba(27, 122, 74, 0.3); transform: translateY(-1px); }

.btn-secondary {
  background: var(--color-surface);
  color: var(--color-primary);
  border-color: var(--color-primary);
}
.btn-secondary:hover:not(:disabled) { background: var(--color-primary-50); transform: translateY(-1px); }

.btn-danger {
  background: var(--color-error);
  color: white;
  box-shadow: 0 2px 4px rgba(220, 38, 38, 0.2);
}
.btn-danger:hover:not(:disabled) { background: var(--color-error-dark); box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3); }

.btn-success {
  background: var(--color-success);
  color: white;
  box-shadow: 0 2px 4px rgba(22, 163, 74, 0.2);
}
.btn-success:hover:not(:disabled) { background: #15803d; box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3); }

.btn-ghost {
  background: transparent;
  color: var(--color-neutral-700);
}
.btn-ghost:hover:not(:disabled) { background: var(--color-neutral-200); }

.btn-sm { min-height: 36px; padding: var(--space-1) var(--space-3); font-size: var(--text-sm); }
.btn-lg { min-height: var(--touch-field); padding: var(--space-4) var(--space-8); font-size: var(--text-md); }
.btn-icon { padding: var(--space-2); min-width: var(--touch-min); }
.btn-block { width: 100%; }
.btn-pill { border-radius: var(--radius-pill); }

/* === CARDS === */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-neutral-300);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-base), transform var(--transition-base), border-color var(--transition-base);
}
.card-clickable { cursor: pointer; }
.card-clickable:hover {
  box-shadow: var(--shadow-card-hover);
  transform: translateY(-2px);
  border-color: var(--color-neutral-400);
}
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: var(--space-4); }
.card-title { font-size: var(--text-md); font-weight: var(--font-semibold); }
.card-body { }
.card-footer { margin-top: var(--space-4); padding-top: var(--space-4); border-top: 1px solid var(--color-neutral-300); }
.card-flat { box-shadow: none; border: 1px solid var(--color-neutral-300); }
.card-flat:hover { box-shadow: none; transform: none; }

/* === KPI CARD (Enhanced with accent border + hover) === */
.kpi-card {
  background: var(--color-surface);
  border: 1px solid var(--color-neutral-300);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  box-shadow: var(--shadow-sm);
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}
.kpi-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--color-primary);
  opacity: 0;
  transition: opacity var(--transition-base);
}
.kpi-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.kpi-card:hover::before { opacity: 1; }
/* When the KPI card is a link (anchor), give it a stronger affordance */
a.kpi-card,
.kpi-card--link {
  cursor: pointer;
  text-decoration: none;
  color: inherit;
  display: flex;
}
a.kpi-card:hover,
.kpi-card--link:hover {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-md), 0 0 0 1px var(--color-primary-50);
}
.kpi-card .kpi-label { font-size: var(--text-xs); color: var(--color-neutral-600); font-weight: var(--font-semibold); text-transform: uppercase; letter-spacing: 0.06em; }
.kpi-card .kpi-value { font-size: var(--text-2xl); font-weight: var(--font-bold); color: var(--color-neutral-900); line-height: var(--leading-tight); }
.kpi-card .kpi-trend { font-size: var(--text-sm); display: flex; align-items: center; gap: var(--space-1); }
.kpi-trend.up { color: var(--color-success); }
.kpi-trend.down { color: var(--color-error); }
.kpi-trend.neutral { color: var(--color-neutral-600); }
.kpi-card .kpi-sparkline { height: 32px; margin-top: var(--space-2); }

/* === FORMS === */
.form-group { margin-bottom: var(--space-5); }
.form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-neutral-700);
  margin-bottom: var(--space-2);
}
.form-required::after { content: ' *'; color: var(--color-error); }

.form-input, .form-select, .form-textarea {
  width: 100%;
  min-height: var(--touch-min);
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-base);
  background: var(--color-surface);
  border: 1.5px solid var(--color-neutral-400);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-base), box-shadow var(--transition-base), background var(--transition-base);
}
.form-input:hover, .form-select:hover, .form-textarea:hover {
  border-color: var(--color-neutral-600);
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
  border-color: var(--color-primary);
  box-shadow: var(--shadow-focus);
  background: white;
  outline: none;
}
.form-input.error, .form-select.error, .form-textarea.error {
  border-color: var(--color-error);
}
.form-input.error:focus { box-shadow: var(--shadow-error-focus); }
.form-textarea { min-height: 100px; resize: vertical; }
.form-hint { font-size: var(--text-xs); color: var(--color-neutral-600); margin-top: var(--space-1); }
.form-error { font-size: var(--text-xs); color: var(--color-error); margin-top: var(--space-1); }

.form-row { display: flex; gap: var(--space-4); }
.form-row > * { flex: 1; }

.form-checkbox, .form-radio {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--touch-min);
  cursor: pointer;
}
.form-checkbox input, .form-radio input { width: 20px; height: 20px; accent-color: var(--color-primary); }

/* === BADGES (Enhanced with subtle border) === */
.badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 3px var(--space-3);
  font-size: var(--text-xs);
  font-weight: var(--font-semibold);
  border-radius: var(--radius-pill);
  white-space: nowrap;
  letter-spacing: 0.01em;
}
.badge-primary { background: var(--color-primary-100); color: var(--color-primary-dark); border: 1px solid var(--color-primary-200); }
.badge-success { background: var(--severity-green-bg); color: var(--color-success); border: 1px solid #bbf7d0; }
.badge-warning { background: var(--severity-orange-bg); color: var(--color-accent-dark); border: 1px solid #fde68a; }
.badge-danger { background: var(--severity-red-bg); color: var(--color-error); border: 1px solid #fecaca; }
.badge-info { background: var(--color-info-light); color: var(--color-secondary); border: 1px solid #bfdbfe; }
.badge-neutral { background: var(--color-neutral-200); color: var(--color-neutral-700); border: 1px solid var(--color-neutral-300); }
.badge-lg { padding: var(--space-2) var(--space-4); font-size: var(--text-sm); }

/* === SEVERITY INDICATORS === */
.severity-dot { width: 12px; height: 12px; border-radius: var(--radius-circle); display: inline-block; }
.severity-green { background: var(--severity-green); }
.severity-orange { background: var(--severity-orange); }
.severity-red { background: var(--severity-red); }

.severity-badge { padding: var(--space-2) var(--space-4); border-radius: var(--radius-pill); font-weight: var(--font-bold); font-size: var(--text-sm); display: inline-flex; align-items: center; gap: var(--space-2); }
.severity-badge.green { background: var(--severity-green-bg); color: var(--severity-green); }
.severity-badge.orange { background: var(--severity-orange-bg); color: var(--severity-orange); }
.severity-badge.red { background: var(--severity-red-bg); color: var(--severity-red); }

/* === TABLES === */
.table { width: 100%; border-collapse: collapse; }
.table th, .table td { padding: var(--space-3) var(--space-4); text-align: left; border-bottom: 1px solid var(--color-neutral-300); }
.table th { font-size: var(--text-xs); font-weight: var(--font-semibold); color: var(--color-neutral-600); background: var(--color-neutral-100); text-transform: uppercase; letter-spacing: 0.04em; }
.table tbody tr { transition: background var(--transition-fast); }
.table tbody tr:hover { background: var(--color-neutral-100); }

/* === TABS (Enhanced with smooth indicator) === */
.tabs { display: flex; border-bottom: 2px solid var(--color-neutral-300); gap: var(--space-1); overflow-x: auto; }
.tab {
  padding: var(--space-3) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  color: var(--color-neutral-600);
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  white-space: nowrap;
  min-height: var(--touch-min);
  display: flex;
  align-items: center;
  transition: color var(--transition-base), border-color var(--transition-base), background var(--transition-base);
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.tab:hover { color: var(--color-primary); background: var(--color-primary-50); }
.tab.active { color: var(--color-primary); border-bottom-color: var(--color-primary); font-weight: var(--font-semibold); background: var(--color-primary-50); }

/* === AVATAR (Enhanced with ring) === */
.avatar {
  width: 40px; height: 40px;
  border-radius: var(--radius-circle);
  background: linear-gradient(135deg, var(--color-primary-100), var(--color-primary-200));
  color: var(--color-primary-dark);
  display: flex; align-items: center; justify-content: center;
  font-weight: var(--font-bold);
  font-size: var(--text-sm);
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: 0 0 0 2px var(--color-surface), 0 0 0 3px var(--color-primary-200);
}
.avatar-sm { width: 32px; height: 32px; font-size: var(--text-xs); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--text-md); }

/* === EMPTY STATE (Enhanced with subtle bg) === */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-16) var(--space-4);
  text-align: center;
  color: var(--color-neutral-600);
  background: var(--color-neutral-100);
  border-radius: var(--radius-lg);
  border: 1px dashed var(--color-neutral-400);
}
.empty-state svg, .empty-state i { width: 56px; height: 56px; margin-bottom: var(--space-4); opacity: 0.35; color: var(--color-primary); }
.empty-state h3 { margin-bottom: var(--space-2); color: var(--color-neutral-700); font-size: var(--text-md); }
.empty-state p { max-width: 280px; line-height: var(--leading-relaxed); }

/* === DIVIDER === */
.divider { border: none; border-top: 1px solid var(--color-neutral-300); margin: var(--space-6) 0; }

/* === SEARCH === */
.search-box {
  position: relative;
  width: 100%;
}
.search-box input {
  width: 100%;
  padding-left: var(--space-10);
}
.search-box svg {
  position: absolute;
  left: var(--space-3);
  top: 50%;
  transform: translateY(-50%);
  color: var(--color-neutral-500);
  width: 20px;
  height: 20px;
  transition: color var(--transition-fast);
}
.search-box input:focus + svg,
.search-box:focus-within svg { color: var(--color-primary); }

/* === SYNC STATUS === */
.sync-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
  font-weight: var(--font-medium);
  transition: background var(--transition-base);
}
.sync-bar.online { background: var(--color-success-light); color: var(--color-success); }
.sync-bar.offline { background: var(--color-error-light, #FEE2E2); color: var(--color-error, #DC2626); }
.sync-bar.syncing { background: var(--color-warning-light); color: var(--color-accent-dark); }
.sync-dot { width: 8px; height: 8px; border-radius: var(--radius-circle); }
.sync-dot.online { background: var(--color-success); }
.sync-dot.offline { background: var(--color-error, #DC2626); }
.sync-dot.syncing { background: var(--color-accent); animation: pulse 1.5s infinite; }

/* Enriched sync bar — sticky at top of app shell, shows pending + last sync + conn type */
.sync-bar.enriched {
  position: sticky; top: 0; z-index: 50;
  justify-content: center;
  gap: var(--space-2);
  min-height: 26px;
  padding: var(--space-1) var(--space-3);
  font-weight: var(--font-semibold);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  user-select: none;
}
.sync-bar.enriched:hover { filter: brightness(0.97); }
.sync-bar-text { display: inline-flex; gap: var(--space-2); flex-wrap: wrap; align-items: center; }
.sync-bar-sep { opacity: 0.5; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* === LOADING === */
.spinner {
  width: 24px; height: 24px;
  border: 3px solid var(--color-neutral-300);
  border-top-color: var(--color-primary);
  border-radius: var(--radius-circle);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.skeleton {
  background: linear-gradient(90deg, var(--color-neutral-200) 25%, var(--color-neutral-100) 50%, var(--color-neutral-200) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-md);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* === FAB (Floating Action Button) === */
.fab {
  position: fixed;
  bottom: calc(var(--bottom-nav-height) + var(--space-4));
  right: var(--space-4);
  width: var(--touch-field);
  height: var(--touch-field);
  border-radius: var(--radius-circle);
  background: var(--color-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  border: none;
  z-index: var(--z-dropdown);
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.fab:hover { transform: scale(1.08); box-shadow: var(--shadow-xl); }
.fab:active { transform: scale(0.95); }
.fab svg { width: 24px; height: 24px; }

@media (min-width: 1025px) {
  .fab { bottom: var(--space-8); right: var(--space-8); }
}

/* === PROGRESS BAR === */
.progress-bar {
  height: 8px;
  background: var(--color-neutral-200);
  border-radius: var(--radius-pill);
  overflow: hidden;
}
.progress-bar .progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-primary-light));
  border-radius: var(--radius-pill);
  transition: width var(--transition-base);
}

/* === TOAST (Enhanced with backdrop blur) === */
.toast-container {
  position: fixed;
  top: var(--space-4);
  right: var(--space-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 400px;
}
.toast {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--color-primary);
  animation: slideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}
.toast.success { border-left-color: var(--color-success); }
.toast.error { border-left-color: var(--color-error); }
.toast.warning { border-left-color: var(--color-accent); }
.toast.info { border-left-color: var(--color-secondary); }
.toast .toast-close { margin-left: auto; cursor: pointer; color: var(--color-neutral-500); transition: color var(--transition-fast); }
.toast .toast-close:hover { color: var(--color-neutral-900); }

@keyframes slideIn {
  from { transform: translateX(100%) translateY(-8px); opacity: 0; }
  to { transform: translateX(0) translateY(0); opacity: 1; }
}

/* === MODAL (Enhanced animations) === */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: var(--z-modal-backdrop);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fadeIn 0.2s ease;
}
.modal {
  background: var(--color-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 560px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-5) var(--space-6);
  border-bottom: 1px solid var(--color-neutral-300);
}
.modal-header h2 { font-size: var(--text-md); margin: 0; }
.modal-body { padding: var(--space-6); }
.modal-footer { padding: var(--space-4) var(--space-6); border-top: 1px solid var(--color-neutral-300); display: flex; justify-content: flex-end; gap: var(--space-3); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes modalIn {
  from { transform: scale(0.95) translateY(8px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}

/* === WELCOME BANNER (Dashboard) === */
.welcome-banner {
  background: linear-gradient(135deg, var(--color-primary), var(--color-primary-dark));
  color: white;
  border-radius: var(--radius-lg);
  padding: var(--space-6) var(--space-8);
  margin-bottom: var(--space-6);
  position: relative;
  overflow: hidden;
}
.welcome-banner::after {
  content: '';
  position: absolute;
  top: -30%;
  right: -5%;
  width: 200px;
  height: 200px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-circle);
}
.welcome-banner h2 { font-size: var(--text-xl); margin-bottom: var(--space-2); }
.welcome-banner p { opacity: 0.85; font-size: var(--text-sm); }

/* === STATUS DOT (on avatars/cards) === */
.status-dot {
  width: 10px;
  height: 10px;
  border-radius: var(--radius-circle);
  border: 2px solid var(--color-surface);
  position: absolute;
  bottom: 0;
  right: 0;
}
.status-dot.active { background: var(--color-success); }
.status-dot.away { background: var(--color-accent); }
.status-dot.busy { background: var(--color-error); }

/* === SECTION HEADER === */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-4);
}
.section-header h3 {
  font-size: var(--text-md);
  font-weight: var(--font-semibold);
  color: var(--color-neutral-900);
}
.section-header .section-action {
  font-size: var(--text-sm);
  color: var(--color-primary);
  font-weight: var(--font-medium);
  cursor: pointer;
  text-decoration: none;
}
.section-header .section-action:hover { text-decoration: underline; }

/* === LIST ITEM (Generic) === */
.list-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  transition: background var(--transition-fast);
  cursor: pointer;
}
.list-item:hover { background: var(--color-neutral-100); }
.list-item + .list-item { border-top: 1px solid var(--color-neutral-200); }

/* === TEASER OVERLAY (Freemium) === */
.teaser-container { position: relative; border-radius: var(--radius-lg); }
.teaser-blurred { filter: blur(4px); pointer-events: none; user-select: none; opacity: 0.6; min-height: 180px; }
.teaser-overlay {
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  min-height: 100%;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(2px);
  z-index: 2;
  border-radius: var(--radius-lg);
  overflow: visible;
}
.teaser-content { text-align: center; padding: var(--space-6); }
.teaser-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--color-neutral-100); color: var(--color-neutral-600);
  margin-bottom: var(--space-3);
}
.teaser-title { font-size: var(--text-lg); font-weight: var(--font-bold); margin-bottom: var(--space-2); }
.teaser-desc { font-size: var(--text-sm); color: var(--color-neutral-600); margin-bottom: var(--space-4); max-width: 280px; margin-left: auto; margin-right: auto; }
.teaser-btn { font-size: var(--text-sm); }
.teaser-compact .teaser-content { padding: var(--space-4); }
.teaser-compact .teaser-icon { width: 40px; height: 40px; margin-bottom: var(--space-2); }

/* === NOTIFICATION DROPDOWN === */
.notif-dropdown {
  position: absolute; top: 100%; right: 0; margin-top: var(--space-2);
  width: 360px; max-height: 420px; overflow-y: auto;
  background: white; border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg, 0 10px 25px rgba(0,0,0,0.15));
  border: 1px solid var(--color-neutral-200);
  z-index: 100;
}
.notif-dropdown.hidden { display: none; }
.notif-item {
  display: flex; align-items: flex-start; gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--color-neutral-100);
  text-decoration: none; color: inherit; cursor: pointer;
  transition: background 0.15s;
}
.notif-item:hover { background: var(--color-neutral-50); }
.notif-item.unread { background: var(--color-primary-50, #f0fdf4); }
.notif-item-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: transparent; flex-shrink: 0; margin-top: 6px;
}
.notif-item-dot.active { background: var(--color-primary); }

@media (max-width: 480px) {
  .notif-dropdown { width: calc(100vw - 32px); right: -8px; }
}

/* === TIER BADGES === */
.tier-badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 10px; border-radius: var(--radius-full);
  font-size: var(--text-xs); font-weight: var(--font-semibold);
}
.tier-badge.free { background: var(--color-neutral-200); color: var(--color-neutral-700); }
.tier-badge.premium {
  background: linear-gradient(135deg, #F59E0B, #D97706);
  color: white;
}

/* === SPINNER SM === */
.spinner-sm {
  display: inline-block; width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,0.3); border-top-color: white;
  border-radius: 50%; animation: spin 0.6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
