/* ==========================================================================
   LEARNING TOLEDO - REUSABLE UI COMPONENTS
   ========================================================================== */

/* 1. BUTTONS */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.625rem 1.15rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
  text-decoration: none;
  white-space: nowrap;
}

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

.btn-primary {
  background-color: var(--color-brand-accent);
  color: #FFFFFF;
}

.btn-primary:hover:not(:disabled) {
  background-color: var(--color-brand-accent-hover);
  box-shadow: 0 4px 12px var(--color-brand-accent-glow);
}

.btn-secondary {
  background-color: var(--bg-surface);
  border-color: var(--border-color);
  color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
  background-color: var(--bg-surface-subtle);
  border-color: #CBD5E1;
}

.btn-danger {
  background-color: var(--color-danger);
  color: #FFFFFF;
}

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

.btn-sm {
  padding: 0.38rem 0.75rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

.btn-lg {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
}

.btn-icon {
  padding: 0.5rem;
  border-radius: var(--radius-md);
}

/* 2. CARDS & CONTAINERS */
.card {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--transition-fast);
}

.card-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.card-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
}

.card-body {
  padding: 1.5rem;
}

.card-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  background-color: var(--bg-surface-subtle);
}

/* 3. FORMS & INPUT CONTROLS */
.form-group {
  margin-bottom: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.form-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
}

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

.form-control {
  width: 100%;
  padding: 0.65rem 0.9rem;
  font-size: 0.9rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background-color: #FFFFFF;
  color: var(--text-primary);
  outline: none;
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--color-brand-accent-glow);
}

.form-control::placeholder {
  color: var(--text-muted);
}

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

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
}

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

/* 4. DATA TABLES */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-color);
  background: var(--bg-surface);
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

.data-table th {
  background-color: var(--bg-surface-subtle);
  color: var(--text-secondary);
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.72rem;
  letter-spacing: 0.05em;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.data-table td {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
  color: var(--text-primary);
  vertical-align: middle;
}

.data-table tr:last-child td {
  border-bottom: none;
}

.data-table tr:hover td {
  background-color: #F8FAFC;
}

/* 5. BADGES & STATUS PILLS */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.65rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-full);
}

.badge-active, .badge-published, .badge-success {
  background-color: var(--color-success-bg);
  color: var(--color-success-text);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-inactive, .badge-danger {
  background-color: var(--color-danger-bg);
  color: var(--color-danger-text);
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.badge-draft, .badge-warning {
  background-color: var(--color-warning-bg);
  color: var(--color-warning-text);
  border: 1px solid rgba(245, 158, 11, 0.2);
}

.badge-role {
  background-color: var(--color-brand-accent-light);
  color: var(--color-brand-accent);
  border: 1px solid rgba(37, 99, 235, 0.2);
}

/* 6. MODALS */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

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

.modal-container {
  background: var(--bg-surface);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  width: 100%;
  max-width: 580px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  transform: translateY(20px) scale(0.98);
  transition: transform var(--transition-normal);
  overflow: hidden;
}

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

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.modal-title {
  font-size: 1.25rem;
  font-weight: 700;
}

.modal-close-btn {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
}

.modal-close-btn:hover {
  color: var(--text-primary);
  background-color: var(--bg-surface-subtle);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  background-color: var(--bg-surface-subtle);
}

/* 7. TOAST NOTIFICATIONS */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 200;
  max-width: 380px;
  width: calc(100% - 3rem);
}

.toast {
  background: #FFFFFF;
  border-radius: var(--radius-md);
  padding: 1rem 1.25rem;
  box-shadow: var(--shadow-lg);
  border-left: 4px solid var(--color-brand-accent);
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 0.875rem;
}

.toast-success { border-left-color: var(--color-success); }
.toast-error { border-left-color: var(--color-danger); }
.toast-warning { border-left-color: var(--color-warning); }
.toast-info { border-left-color: var(--color-info); }

@keyframes toastSlideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* 8. EMPTY STATES */
.empty-state {
  text-align: center;
  padding: 3.5rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  color: var(--text-muted);
}

.empty-state-title {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
}

.empty-state-desc {
  max-width: 420px;
  margin-bottom: 1.5rem;
  font-size: 0.9rem;
}

/* 9. RICH WYSIWYG TEXT EDITOR */
.rich-editor-wrap {
  border: 1.5px solid #CBD5E1;
  border-radius: var(--radius-md);
  background: #FFFFFF;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.rich-editor-toolbar {
  background: #F8FAFC;
  border-bottom: 1.5px solid #E2E8F0;
  padding: 0.5rem 0.65rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  align-items: center;
}

.editor-btn {
  background: #FFFFFF;
  border: 1px solid #CBD5E1;
  border-radius: 4px;
  padding: 0.3rem 0.6rem;
  font-size: 0.82rem;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  transition: all var(--transition-fast);
}

.editor-btn:hover {
  background: #EFF6FF;
  border-color: #2563EB;
  color: #1D4ED8;
}

.editor-divider {
  width: 1px;
  height: 22px;
  background: #CBD5E1;
  margin: 0 0.2rem;
}

.rich-editor-area {
  padding: 1.25rem;
  min-height: 220px;
  max-height: 480px;
  overflow-y: auto;
  font-size: 0.95rem;
  line-height: 1.65;
  color: #0F172A;
  outline: none;
  background: #FFFFFF;
}

.rich-editor-area:focus {
  background: #FAFAFA;
}

.rich-editor-area h1, .rich-text-content h1 {
  font-size: 1.5rem;
  font-weight: 800;
  margin: 1rem 0 0.5rem;
  color: #0F172A;
}

.rich-editor-area h2, .rich-text-content h2 {
  font-size: 1.3rem;
  font-weight: 800;
  margin: 0.85rem 0 0.4rem;
  color: #1E293B;
}

.rich-editor-area h3, .rich-text-content h3 {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0.75rem 0 0.35rem;
  color: #334155;
}

.rich-editor-area p, .rich-text-content p {
  margin-bottom: 0.85rem;
  line-height: 1.65;
}

.rich-editor-area ul, .rich-text-content ul {
  list-style-type: disc;
  padding-left: 1.5rem;
  margin-bottom: 0.85rem;
}

.rich-editor-area ol, .rich-text-content ol {
  list-style-type: decimal;
  padding-left: 1.5rem;
  margin-bottom: 0.85rem;
}

.rich-editor-area li, .rich-text-content li {
  margin-bottom: 0.35rem;
}

.rich-editor-area blockquote, .rich-text-content blockquote {
  border-left: 4px solid #2563EB;
  padding: 0.6rem 1rem;
  background: #EFF6FF;
  margin: 0.85rem 0;
  border-radius: 0 6px 6px 0;
  color: #1E40AF;
  font-style: italic;
}

/* Responsive Modals & Notifications */
@media (max-width: 640px) {
  .modal-container {
    width: 96% !important;
    max-height: 92vh !important;
    margin: 0.5rem auto !important;
  }
  .modal-header {
    padding: 1rem 1.25rem !important;
  }
  .modal-body {
    padding: 1.25rem 1rem !important;
  }
  .modal-footer {
    padding: 0.85rem 1rem !important;
    flex-direction: column-reverse !important;
    gap: 0.5rem !important;
  }
  .modal-footer .btn {
    width: 100% !important;
    justify-content: center !important;
  }
  .toast-container {
    left: 1rem !important;
    right: 1rem !important;
    bottom: 1rem !important;
    max-width: 100% !important;
    width: auto !important;
  }
}
