/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.8125rem;
  transition: all 0.2s var(--ease-out);
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.4;
}

.btn-sm { padding: 6px 12px; font-size: 0.75rem; }
.btn-lg { padding: 12px 24px; font-size: 0.875rem; }

.btn-primary {
  background: var(--primary);
  color: var(--text-inverse);
  border-color: var(--primary);
}
.btn-primary:hover {
  background: var(--primary-500);
  box-shadow: 0 4px 12px rgba(10,22,40,0.25);
  transform: translateY(-1px);
}

.btn-accent {
  background: var(--accent);
  color: white;
  border-color: var(--accent);
}
.btn-accent:hover {
  background: var(--accent-600);
  box-shadow: 0 4px 12px rgba(0,212,170,0.35);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--danger);
  color: white;
  border-color: var(--danger);
}
.btn-danger:hover {
  background: #dc2626;
  box-shadow: 0 4px 12px rgba(239,68,68,0.25);
}

.btn-outline {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text-secondary);
}
.btn-outline:hover {
  background: var(--surface-2);
  border-color: var(--gray-300);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border-color: transparent;
}
.btn-ghost:hover { background: var(--surface-3); }

.btn-icon {
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: var(--radius);
  background: transparent;
  border: 1px solid transparent;
  color: var(--gray-400);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  transition: all 0.15s;
  cursor: pointer;
}
.btn-icon:hover { background: var(--surface-3); color: var(--gray-600); }
.btn-icon.danger:hover { background: var(--danger-bg); color: var(--danger); }

.btn:disabled, .btn[disabled] {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
}

/* ===== OAUTH BUTTONS (Google + Apple) ===== */
.btn-oauth {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 11px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.875rem;
  transition: all 0.15s;
  border: 1px solid var(--border);
  cursor: pointer;
  background: var(--surface);
}

.btn-oauth:hover {
  border-color: var(--gray-300);
  background: var(--surface-2);
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

.btn-oauth svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.btn-oauth-apple {
  background: #000;
  color: white;
  border-color: #000;
}
.btn-oauth-apple:hover {
  background: #1a1a1a;
  border-color: #1a1a1a;
}

/* ===== CARDS ===== */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
  animation: fadeIn 0.4s var(--ease-out) both;
}

.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border-light);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.card-header-title {
  font-weight: 700;
  font-size: 0.9375rem;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: 8px;
}

.card-body { padding: 24px; }

.card-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-light);
  background: var(--surface-2);
}

/* ===== FORMS ===== */
.form-group { margin-bottom: 18px; }

.form-group label {
  display: block;
  margin-bottom: 6px;
  font-weight: 600;
  font-size: 0.8125rem;
  color: var(--gray-700);
}

.form-group label .required { color: var(--danger); }

.form-input,
.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 9px 13px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text);
  background: var(--surface);
  transition: all 0.15s;
  line-height: 1.5;
}

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

.form-input:focus,
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,212,170,0.12);
}

.form-input::placeholder,
.form-group input::placeholder {
  color: var(--gray-400);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

@media (max-width: 560px) {
  .form-row { grid-template-columns: 1fr; }
}

.form-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  padding-top: 8px;
}

/* ===== TABLES ===== */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

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

th, td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border-light);
  font-size: 0.8125rem;
}

th {
  background: var(--surface-2);
  font-weight: 600;
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  position: sticky;
  top: 0;
  white-space: nowrap;
}

td { color: var(--text-secondary); }
tr:hover td { background: var(--gray-50); }

td .name-cell {
  font-weight: 600;
  color: var(--gray-800);
}

.table-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.table-actions .btn-icon { width: 32px; height: 32px; font-size: 0.875rem; }

/* ===== MODAL ===== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(10,22,40,0.55);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 16px;
}

.modal.hidden { display: none !important; }

.modal-content {
  background: var(--surface);
  border-radius: var(--radius-xl);
  max-width: 560px;
  width: 100%;
  max-height: calc(100vh - 32px);
  overflow-y: auto;
  box-shadow: var(--shadow-xl);
  animation: fadeInScale 0.3s var(--ease-out) both;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-light);
}

.modal-header h3 {
  font-size: 1.0625rem;
  font-weight: 700;
}

.modal-close:not(.btn) {
  width: 32px;
  height: 32px;
  background: var(--surface-2);
  border: none;
  border-radius: var(--radius);
  font-size: 1.125rem;
  color: var(--gray-400);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  cursor: pointer;
}
.modal-close:not(.btn):hover {
  background: var(--danger-bg);
  color: var(--danger);
}

.modal-body { padding: 24px; }

.modal-footer {
  padding: 16px 24px 20px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ===== BADGES ===== */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.5;
}

.badge-success { background: var(--success-bg); color: var(--success-text); }
.badge-warning { background: var(--warning-bg); color: var(--warning-text); }
.badge-danger { background: var(--danger-bg); color: var(--danger-text); }
.badge-info { background: var(--info-bg); color: var(--info-text); }
.badge-neutral { background: var(--surface-3); color: var(--text-secondary); }
.badge-primary { background: var(--primary-50); color: var(--primary); }

/* ===== SEARCH BAR ===== */
.search-bar {
  margin-bottom: 20px;
  position: relative;
}

.search-bar input {
  width: 100%;
  padding: 10px 14px 10px 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  background: var(--surface);
  transition: all 0.15s;
}

.search-bar input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(0,212,170,0.1);
}

.search-bar::before {
  content: '🔍';
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 0.875rem;
  pointer-events: none;
}

/* ===== PAGINATION ===== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  margin-top: 20px;
  padding: 12px 0;
}

.pagination button {
  padding: 6px 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius);
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all 0.15s;
  cursor: pointer;
}

.pagination button:hover {
  border-color: var(--gray-300);
  background: var(--surface-2);
}

.pagination button.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

/* ===== TOAST ===== */
.toast {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  padding: 12px 18px;
  border-radius: var(--radius-md);
  font-size: 0.8125rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow-lg);
  animation: slideDown 0.35s var(--ease-out) both;
  max-width: 380px;
}

.toast-success { background: var(--success); color: white; }
.toast-error { background: var(--danger); color: white; }
.toast-warning { background: var(--warning); color: var(--warning-text); }
.toast-info { background: var(--info); color: white; }

/* ===== EMPTY STATE ===== */
.empty-state {
  padding: 48px 24px;
  text-align: center;
}

.empty-state-icon {
  font-size: 2.5rem;
  margin-bottom: 12px;
  opacity: 0.4;
}

.empty-state-text {
  font-size: 0.9375rem;
  color: var(--text-muted);
  margin-bottom: 16px;
}

/* ===== LOGIN PAGE — EPIC REDESIGN ===== */
.login-page {
  min-height: 100vh;
  display: flex;
  position: relative;
  overflow: hidden;
  background: var(--primary);
}

/* Left panel — brand showcase */
.login-brand-panel {
  flex: 1;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-500) 100%);
  color: white;
  padding: 60px 50px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

.login-brand-panel::before {
  content: '';
  position: absolute;
  top: -10%;
  right: -10%;
  width: 500px;
  height: 500px;
  background: radial-gradient(circle, rgba(0,212,170,0.25) 0%, transparent 70%);
  border-radius: 50%;
  animation: float 8s ease-in-out infinite;
}

.login-brand-panel::after {
  content: '';
  position: absolute;
  bottom: -20%;
  left: -15%;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(124,111,240,0.15) 0%, transparent 70%);
  border-radius: 50%;
  animation: float 10s ease-in-out infinite reverse;
}

.login-brand-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  z-index: 2;
}

.login-brand-logo-mark {
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-600) 100%);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(0,212,170,0.4);
  animation: glowPulse 3s ease-in-out infinite;
}

.login-brand-logo-text {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.75rem;
  letter-spacing: -0.04em;
}

.login-brand-hero {
  position: relative;
  z-index: 2;
  max-width: 440px;
}

.login-brand-hero h1 {
  font-family: var(--font-display);
  font-size: 2.75rem;
  font-weight: 700;
  letter-spacing: -0.04em;
  line-height: 1.1;
  color: white;
  margin-bottom: 16px;
}

.login-brand-hero h1 .gradient {
  background: linear-gradient(135deg, var(--accent-300) 0%, var(--accent) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.login-brand-hero p {
  font-size: 1.0625rem;
  color: rgba(255,255,255,0.75);
  line-height: 1.6;
  margin-bottom: 32px;
}

.login-brand-features {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.login-feature {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.875rem;
  color: rgba(255,255,255,0.85);
}

.login-feature-icon {
  width: 24px;
  height: 24px;
  background: rgba(0,212,170,0.2);
  border: 1px solid rgba(0,212,170,0.4);
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: var(--accent-300);
}

.login-brand-footer {
  position: relative;
  z-index: 2;
  font-size: 0.75rem;
  color: rgba(255,255,255,0.4);
}

/* Right panel — form */
.login-form-panel {
  width: 480px;
  background: var(--surface);
  padding: 60px 48px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow-y: auto;
}

.login-form-inner {
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  animation: fadeInScale 0.5s var(--ease-out) both;
}

.login-form-inner h2 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--gray-900);
}

.login-form-inner > p {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 28px;
}

.login-oauth-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 20px;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: var(--text-muted);
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border);
}

.login-switch {
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-muted);
  margin-top: 20px;
}

.login-switch a {
  color: var(--accent-600);
  font-weight: 600;
  cursor: pointer;
}

.login-switch a:hover { text-decoration: underline; }

.login-terms {
  text-align: center;
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 20px;
  line-height: 1.6;
}

.login-terms a {
  color: var(--accent-600);
  text-decoration: underline;
}

@media (max-width: 900px) {
  .login-brand-panel { display: none; }
  .login-form-panel { width: 100%; padding: 40px 24px; }
}

/* ===== CONFIRM DIALOG ===== */
.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,22,40,0.55);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
}

.confirm-box {
  background: var(--surface);
  border-radius: var(--radius-xl);
  padding: 28px;
  max-width: 400px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-xl);
  animation: fadeInScale 0.25s var(--ease-out) both;
}

.confirm-box h3 { margin-bottom: 8px; }
.confirm-box p { font-size: 0.875rem; margin-bottom: 20px; }

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* ===== LIST ITEMS ===== */
.list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  transition: background 0.1s;
}
.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--gray-50); }

.list-item-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  background: var(--primary-50);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8125rem;
  flex-shrink: 0;
}

.list-item-content { flex: 1; min-width: 0; }
.list-item-title { font-weight: 600; font-size: 0.875rem; color: var(--gray-800); }
.list-item-sub { font-size: 0.75rem; color: var(--text-muted); margin-top: 2px; }

/* ===== NCF POOL ===== */
.ncf-stock-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
  margin: 16px 0 20px;
}
.ncf-card {
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  transition: all 0.2s;
}
.ncf-card.ok { border-color: var(--accent-200); }
.ncf-card.warning { border-color: #f59e0b; background: #fffbeb; }
.ncf-card.critical {
  border-color: var(--danger);
  background: var(--danger-bg);
  animation: ncf-pulse 2s infinite;
}
@keyframes ncf-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}
.ncf-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}
.ncf-tipo {
  font-weight: 800;
  color: var(--primary);
  font-size: 0.9375rem;
  letter-spacing: 0.02em;
}
.ncf-icon { font-size: 1.125rem; }
.ncf-count strong {
  font-size: 1.75rem;
  color: var(--primary);
  display: block;
  line-height: 1;
  font-weight: 800;
}
.ncf-count span {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 4px;
  display: block;
}
.ncf-alert {
  margin-top: 10px;
  padding: 6px 10px;
  border-radius: var(--radius);
  background: rgba(239,68,68,0.12);
  color: #b91c1c;
  font-size: 0.75rem;
  font-weight: 600;
  text-align: center;
}
.ncf-card.warning .ncf-alert {
  background: rgba(245,158,11,0.15);
  color: #b45309;
}
.ncf-form {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr auto;
  gap: 10px;
  align-items: end;
  margin-top: 12px;
}
.ncf-form .form-group { margin-bottom: 0; }
@media (max-width: 700px) {
  .ncf-form { grid-template-columns: 1fr; }
}
.ncf-hint {
  display: block;
  margin-top: 10px;
  color: var(--text-muted);
  font-size: 0.75rem;
}
.ncf-list-used {
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 8px;
  margin-top: 8px;
  font-family: monospace;
  font-size: 0.75rem;
  background: var(--surface-2);
}

/* ===== NOTIFICATION TOAST (Messenger-style) ===== */
.klinvex-notif-toast {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--primary);
  color: white;
  padding: 14px 18px;
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 40px rgba(10,22,40,0.35);
  display: flex;
  gap: 14px;
  align-items: center;
  min-width: 280px;
  max-width: 380px;
  z-index: 10000;
  transform: translateX(120%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  border-left: 4px solid var(--accent);
  cursor: pointer;
}
.klinvex-notif-toast.show { transform: translateX(0); }
.klinvex-notif-toast:hover {
  transform: translateX(0) scale(1.02);
}
.klinvex-notif-icon {
  font-size: 1.75rem;
  flex-shrink: 0;
  animation: notif-bounce 0.6s ease-out;
}
@keyframes notif-bounce {
  0% { transform: scale(0); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}
.klinvex-notif-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}
.klinvex-notif-title {
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--accent);
}
.klinvex-notif-msg {
  font-size: 0.8125rem;
  color: rgba(255,255,255,0.85);
  overflow: hidden;
  text-overflow: ellipsis;
}
@media (max-width: 560px) {
  .klinvex-notif-toast {
    top: 10px;
    right: 10px;
    left: 10px;
    min-width: 0;
    max-width: none;
  }
}

/* ===== ROLE SECTION ===== */
.role-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.role-badge.doctor { background: var(--primary-50); color: var(--primary); }
.role-badge.secretaria { background: var(--accent-50); color: var(--accent-600); }

.sound-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: var(--surface-2);
  border-radius: var(--radius);
  margin-top: 12px;
}
.sound-toggle input[type="checkbox"] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}
.sound-toggle label {
  font-size: 0.8125rem;
  color: var(--text-secondary);
  cursor: pointer;
  margin: 0;
}
.btn-test-sound {
  margin-left: auto;
  font-size: 0.6875rem;
  padding: 4px 10px;
}

/* ===== STAFF CARDS (team management) ===== */
.staff-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 10px;
  transition: all 0.2s;
}
.staff-card:hover {
  border-color: var(--primary-200);
  background: var(--surface);
}
.staff-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.125rem;
  flex-shrink: 0;
}
.staff-info {
  flex: 1;
  min-width: 0;
}
.staff-name {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--gray-900);
}
.staff-email {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 2px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.staff-actions {
  display: flex;
  gap: 4px;
}
