/* ===========================================================
   Connecta — Modern Theme
   =========================================================== */

:root {
  /* Brand palette */
  --color-primary: #6366f1;
  --color-primary-light: #818cf8;
  --color-primary-dark: #4f46e5;
  --color-accent: #06b6d4;
  --color-accent-light: #22d3ee;

  /* Surfaces */
  --surface: #ffffff;
  --surface-hover: #f8fafc;
  --surface-raised: #f1f5f9;
  --bg-root: #f1f5f9;
  --bg-root-dark: #0f172a;

  /* Text */
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --text-inverse: #ffffff;

  /* Borders */
  --border: #e2e8f0;
  --border-light: #f1f5f9;

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,.04);
  --shadow-sm: 0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,.04), 0 2px 4px rgba(0,0,0,.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,.06), 0 4px 10px rgba(0,0,0,.04);
  --shadow-xl: 0 20px 50px rgba(0,0,0,.08), 0 8px 20px rgba(0,0,0,.04);

  /* Radii */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* Transitions */
  --transition-fast: 150ms cubic-bezier(.4,0,.2,1);
  --transition: 200ms cubic-bezier(.4,0,.2,1);
  --transition-slow: 300ms cubic-bezier(.4,0,.2,1);

  /* Sidebar */
  --sidebar-bg: linear-gradient(180deg, #1e1b4b 0%, #0f172a 100%);
  --sidebar-width: 260px;

  /* Nav */
  --nav-height: 56px;
  --nav-bg: linear-gradient(135deg, #4f46e5 0%, #7c3aed 60%, #a855f7 100%);

  /* Status colors */
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --info: #3b82f6;
  --info-bg: #eff6ff;
}

/* -----------------------------------------------------------
   Base
   ----------------------------------------------------------- */
* { box-sizing: border-box; }

body {
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  color: var(--text-primary);
  background: var(--bg-root);
}

/* Scrollbar */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
.dark ::-webkit-scrollbar-thumb { background: #334155; }

/* -----------------------------------------------------------
   Typography
   ----------------------------------------------------------- */
.page-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.01em;
}

.section-label {
  font-size: .7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
}

/* -----------------------------------------------------------
   Buttons
   ----------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  border: none;
  font-weight: 600;
  font-size: .8125rem;
  line-height: 1;
  padding: .625rem 1.125rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  letter-spacing: .01em;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(99,102,241,.25);
}
.btn-primary:hover:not(:disabled) {
  box-shadow: 0 4px 16px rgba(99,102,241,.35);
  transform: translateY(-1px);
}
.btn-primary:active:not(:disabled) { transform: translateY(0) scale(.97); }

.btn-secondary {
  background: var(--surface);
  color: var(--text-secondary);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: #cbd5e1;
  color: var(--text-primary);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--surface-raised);
  color: var(--text-primary);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(239,68,68,.25);
}
.btn-danger:hover:not(:disabled) {
  box-shadow: 0 4px 16px rgba(239,68,68,.35);
  transform: translateY(-1px);
}

.btn-success {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: #fff;
  box-shadow: 0 2px 8px rgba(16,185,129,.25);
}
.btn-success:hover:not(:disabled) {
  box-shadow: 0 4px 16px rgba(16,185,129,.35);
  transform: translateY(-1px);
}

.btn-sm { padding: .4375rem .875rem; font-size: .75rem; }
.btn-lg { padding: .75rem 1.5rem; font-size: .875rem; }

/* -----------------------------------------------------------
   Cards
   ----------------------------------------------------------- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
  overflow: hidden;
}
.card:hover { box-shadow: var(--shadow-md); }
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-light);
}
.card-header h3 {
  font-size: .875rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}
.card-body { padding: 1.25rem; }
.card-footer {
  padding: .875rem 1.25rem;
  border-top: 1px solid var(--border-light);
  background: var(--surface-hover);
}

/* Glass card variant */
.card-glass {
  background: rgba(255,255,255,.8);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,.3);
}

/* -----------------------------------------------------------
   Tables
   ----------------------------------------------------------- */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--surface);
}

table.modern {
  width: 100%;
  border-collapse: collapse;
  font-size: .8125rem;
}
table.modern thead th {
  padding: .75rem 1rem;
  text-align: left;
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  background: var(--surface-raised);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
table.modern tbody td {
  padding: .75rem 1rem;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}
table.modern tbody tr:last-child td { border-bottom: none; }
table.modern tbody tr {
  transition: background var(--transition-fast);
}
table.modern tbody tr:hover {
  background: #eef2ff;
}
table.modern tbody tr:nth-child(even) {
  background: #fafbfd;
}
table.modern tbody tr:nth-child(even):hover {
  background: #eef2ff;
}
.dark table.modern tbody tr:hover { background: rgba(99,102,241,.08); }
.dark table.modern tbody tr:nth-child(even) { background: rgba(15,23,42,.3); }

/* -----------------------------------------------------------
   Forms
   ----------------------------------------------------------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: .375rem;
  margin-bottom: 1rem;
}
.form-label {
  font-size: .8125rem;
  font-weight: 600;
  color: var(--text-primary);
}
.form-label .required { color: #ef4444; margin-left: 2px; }
.form-input {
  width: 100%;
  padding: .625rem .875rem;
  font-size: .8125rem;
  color: var(--text-primary);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  outline: none;
}
.form-input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}
.form-input::placeholder { color: var(--text-muted); }
.form-input:disabled {
  opacity: .55;
  background: var(--surface-raised);
  cursor: not-allowed;
}
.form-select {
  width: 100%;
  padding: .625rem .875rem;
  font-size: .8125rem;
  color: var(--text-primary);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
  outline: none;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .75rem center;
  padding-right: 2.5rem;
}
.form-select:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}

textarea.form-input {
  resize: vertical;
  min-height: 80px;
  line-height: 1.5;
}

.form-error {
  font-size: .75rem;
  color: #ef4444;
  min-height: 1rem;
}

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

/* -----------------------------------------------------------
   Badges / Pills
   ----------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  padding: .2rem .625rem;
  font-size: .6875rem;
  font-weight: 600;
  border-radius: 9999px;
  letter-spacing: .02em;
  white-space: nowrap;
}
.badge-success { background: var(--success-bg); color: #065f46; }
.badge-warning { background: var(--warning-bg); color: #92400e; }
.badge-danger  { background: var(--danger-bg);  color: #991b1b; }
.badge-info    { background: var(--info-bg);    color: #1e40af; }
.badge-neutral { background: #f1f5f9;           color: #475569; }
.badge-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  margin-right: 4px;
}

/* -----------------------------------------------------------
   Empty state
   ----------------------------------------------------------- */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
}
.empty-state-icon {
  width: 56px; height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-raised);
  border-radius: 50%;
  margin-bottom: 1rem;
  font-size: 1.5rem;
  color: var(--text-muted);
}
.empty-state h4 {
  font-size: .9375rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 .25rem;
}
.empty-state p {
  font-size: .8125rem;
  color: var(--text-muted);
  margin: 0 0 .5rem;
}

/* -----------------------------------------------------------
   Loading skeleton
   ----------------------------------------------------------- */
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
.skeleton {
  background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius-sm);
}
.skeleton-row { height: 2.5rem; margin-bottom: .5rem; border-radius: var(--radius-sm); }
.skeleton-cell { height: 1rem; border-radius: 4px; margin-bottom: .375rem; }
.skeleton-circle { border-radius: 50%; }

/* -----------------------------------------------------------
   Toast / Alert
   ----------------------------------------------------------- */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: .625rem;
  padding: .75rem 1rem;
  background: var(--surface);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  border-left: 3px solid var(--color-primary);
  font-size: .8125rem;
  font-weight: 500;
  color: var(--text-primary);
  min-width: 280px;
  max-width: 420px;
  pointer-events: auto;
  animation: toastIn .3s cubic-bezier(.4,0,.2,1);
}
.toast-success { border-left-color: var(--success); }
.toast-error   { border-left-color: var(--danger);  }
.toast-warning { border-left-color: var(--warning); }
.toast-info    { border-left-color: var(--info);    }

@keyframes toastIn {
  0%   { opacity: 0; transform: translateX(100%) scale(.95); }
  100% { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes toastOut {
  0%   { opacity: 1; transform: translateX(0) scale(1); }
  100% { opacity: 0; transform: translateX(100%) scale(.95); }
}

.alert-inline {
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  font-size: .8125rem;
  font-weight: 500;
  margin-bottom: 1rem;
  display: none;
}
.alert-inline.visible { display: block; }
.alert-inline-success { background: var(--success-bg); color: #065f46; border: 1px solid #a7f3d0; }
.alert-inline-error   { background: var(--danger-bg);  color: #991b1b; border: 1px solid #fecaca; }

/* -----------------------------------------------------------
   Drop-area (file upload)
   ----------------------------------------------------------- */
.drop-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  border: 2px dashed var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-hover);
  cursor: pointer;
  transition: all var(--transition-fast);
  text-align: center;
  gap: .5rem;
}
.drop-area:hover, .drop-area.drag-over {
  border-color: var(--color-primary);
  background: #eef2ff;
}
.drop-area-icon { font-size: 1.75rem; color: var(--text-muted); }
.drop-area-text { font-size: .8125rem; color: var(--text-secondary); }
.drop-area-hint { font-size: .6875rem; color: var(--text-muted); }

/* -----------------------------------------------------------
   Switch / Toggle
   ----------------------------------------------------------- */
.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;
  font-size: .8125rem;
  color: var(--text-secondary);
}
.toggle input { display: none; }
.toggle-track {
  width: 36px; height: 20px;
  background: var(--border);
  border-radius: 10px;
  position: relative;
  transition: background var(--transition-fast);
  flex-shrink: 0;
}
.toggle input:checked + .toggle-track { background: var(--color-primary); }
.toggle-track::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--transition-fast);
  box-shadow: var(--shadow-xs);
}
.toggle input:checked + .toggle-track::after { transform: translateX(16px); }

/* -----------------------------------------------------------
   Page fade-in
   ----------------------------------------------------------- */
@keyframes pageIn {
  0%   { opacity: 0; transform: translateY(6px); }
  100% { opacity: 1; transform: translateY(0); }
}
.page-animate-in {
  animation: pageIn .3s cubic-bezier(.4,0,.2,1);
}

/* -----------------------------------------------------------
   Logo text
   ----------------------------------------------------------- */
.logo-text {
  font-weight: 800;
  font-size: 1.25rem;
  letter-spacing: -.02em;
  background: linear-gradient(135deg, #fff 0%, #c7d2fe 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* -----------------------------------------------------------
   Dark mode overrides (when body has .dark or system)
   ----------------------------------------------------------- */
.dark {
  --surface: #1e293b;
  --surface-hover: #334155;
  --surface-raised: #0f172a;
  --border: #334155;
  --border-light: #1e293b;
  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  color-scheme: dark;
}

/* -----------------------------------------------------------
   Link actions in table rows
   ----------------------------------------------------------- */
.action-link {
  font-size: .8125rem;
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: color var(--transition-fast);
  background: none;
  border: none;
  padding: 0;
  margin-right: .75rem;
}
.action-link:hover { text-decoration: underline; }
.action-edit   { color: #6366f1; }
.action-delete { color: #ef4444; }
.action-view   { color: #06b6d4; }

/* -----------------------------------------------------------
   Toolbar area
   ----------------------------------------------------------- */
.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.toolbar-left {
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-wrap: wrap;
}
.toolbar-search {
  width: 240px;
  padding: .5625rem .8125rem;
  font-size: .8125rem;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-primary);
  outline: none;
  transition: all var(--transition-fast);
}
.toolbar-search:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(99,102,241,.1);
}
.toolbar-search::placeholder { color: var(--text-muted); }

/* -----------------------------------------------------------
   Pagination
   ----------------------------------------------------------- */
.pagination {
  display: flex;
  align-items: center;
  gap: .5rem;
  font-size: .8125rem;
  color: var(--text-muted);
}
.pagination button {
  padding: .375rem .75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: .75rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition-fast);
}
.pagination button:hover:not(:disabled) {
  background: var(--surface-hover);
  border-color: #cbd5e1;
}
.pagination button:disabled {
  opacity: .4;
  cursor: not-allowed;
}

/* -----------------------------------------------------------
   Divider with label
   ----------------------------------------------------------- */
.divider-label {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin: 1.25rem 0;
}
.divider-label::before,
.divider-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}
.divider-label span {
  font-size: .6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .1em;
  color: var(--text-muted);
  white-space: nowrap;
}

/* -----------------------------------------------------------
   Confirm dialog (modal)
   ----------------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(15,23,42,.5);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.modal-overlay.open { display: flex; }
.modal-dialog {
  background: var(--surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  max-width: 440px;
  width: calc(100% - 2rem);
  overflow: hidden;
  animation: toastIn .25s cubic-bezier(.4,0,.2,1);
}
.modal-body { padding: 1.5rem; }
.modal-body h3 {
  margin: 0 0 .5rem;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
}
.modal-body p {
  margin: 0;
  font-size: .8125rem;
  color: var(--text-secondary);
  line-height: 1.5;
}
.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: .5rem;
  padding: 1rem 1.5rem;
  background: var(--surface-hover);
  border-top: 1px solid var(--border-light);
}
