/**
 * Prérequis Admin - Styles
 */

:root {
  --bg: #0f1419;
  --panel: #1a1f2e;
  --border: #2d3548;
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --accent: #3b82f6;
  --accent-hover: #2563eb;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --purple: #8b5cf6;
  --teal: #3a9d93;
  --header-height: 56px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  min-height: 100vh;
}

/* ============================================
   Main Content
   ============================================ */
.main-content {
  max-width: 960px;
  margin: 0 auto;
  padding: calc(var(--header-height) + 2rem) 1.5rem 6rem;
}

/* ============================================
   Page Header
   ============================================ */
.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

.page-header-left h1 {
  font-size: 1.375rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.page-header-left h1 i {
  color: var(--teal);
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

/* ============================================
   Buttons
   ============================================ */
.btn-action {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.875rem;
  font-size: 0.8125rem;
  font-weight: 500;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid transparent;
}

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

.btn-secondary {
  background: var(--panel);
  color: var(--text);
  border-color: var(--border);
}

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

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

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

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

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

/* ============================================
   Loading
   ============================================ */
.prereq-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 3rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.prereq-loading i {
  font-size: 1.25rem;
  color: var(--accent);
}

/* ============================================
   OS Table Sections
   ============================================ */
.os-table-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 1.5rem;
  overflow: hidden;
}

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

.os-table-header h2 {
  font-size: 1.05rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: 0;
}

.os-table-header h2 i {
  font-size: 0.95rem;
}

.os-table-header h2 .os-icon-linux { color: #f59e0b; }
.os-table-header h2 .os-icon-windows { color: #3b82f6; }
.os-table-header h2 .os-icon-sunos { color: #f97316; }

.os-table-header .btn-add-row {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.7rem;
  font-size: 0.75rem;
  font-weight: 500;
  border-radius: 5px;
  cursor: pointer;
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
  border: 1px solid rgba(59, 130, 246, 0.25);
  transition: all 0.2s;
}

.os-table-header .btn-add-row:hover {
  background: rgba(59, 130, 246, 0.25);
}

/* Table */
.os-table {
  width: 100%;
  border-collapse: collapse;
}

.os-table thead th {
  padding: 0.6rem 0.75rem;
  text-align: left;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  background: rgba(45, 53, 72, 0.4);
  border-bottom: 1px solid var(--border);
}

.os-table thead th:last-child {
  width: 50px;
  text-align: center;
}

.os-table tbody tr {
  border-bottom: 1px solid rgba(45, 53, 72, 0.5);
  transition: background 0.15s;
}

.os-table tbody tr:last-child {
  border-bottom: none;
}

.os-table tbody tr:hover {
  background: rgba(59, 130, 246, 0.04);
}

.os-table tbody td {
  padding: 0.4rem 0.5rem;
}

.os-table tbody td input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  font-size: 0.8125rem;
  background: rgba(15, 20, 25, 0.5);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  transition: border-color 0.2s;
}

.os-table tbody td input:focus {
  outline: none;
  border-color: var(--accent);
}

.os-table tbody td input::placeholder {
  color: rgba(148, 163, 184, 0.4);
}

/* Select for Communication Splunk */
.os-table tbody td select {
  width: 100%;
  padding: 0.4rem 0.6rem;
  font-size: 0.8125rem;
  background: rgba(15, 20, 25, 0.5);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
  cursor: pointer;
  transition: border-color 0.2s;
}

.os-table tbody td select:focus {
  outline: none;
  border-color: var(--accent);
}

.os-table tbody td select option {
  background: var(--panel);
  color: var(--text);
}

/* Delete row button */
.btn-delete-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 5px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.75rem;
}

.btn-delete-row:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

/* Empty table message */
.os-table-empty {
  padding: 1.5rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  font-style: italic;
}

/* ============================================
   Rich Text Sections
   ============================================ */
.richtext-config {
  margin-top: 0.5rem;
}

.richtext-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.richtext-section h2 {
  font-size: 1.05rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 1rem 1.25rem;
  margin: 0;
  border-bottom: 1px solid var(--border);
}

.richtext-section h2 i {
  color: var(--teal);
  font-size: 0.95rem;
}

/* Quill dark theme overrides */
.richtext-section .ql-toolbar.ql-snow {
  background: rgba(45, 53, 72, 0.4);
  border: none;
  border-bottom: 1px solid var(--border);
  padding: 8px 12px;
}

.richtext-section .ql-toolbar .ql-stroke {
  stroke: var(--text-muted);
}

.richtext-section .ql-toolbar .ql-fill {
  fill: var(--text-muted);
}

.richtext-section .ql-toolbar .ql-picker-label {
  color: var(--text-muted);
}

.richtext-section .ql-toolbar button:hover .ql-stroke,
.richtext-section .ql-toolbar .ql-picker-label:hover .ql-stroke {
  stroke: var(--text);
}

.richtext-section .ql-toolbar button:hover .ql-fill,
.richtext-section .ql-toolbar .ql-picker-label:hover .ql-fill {
  fill: var(--text);
}

.richtext-section .ql-toolbar button.ql-active .ql-stroke {
  stroke: var(--accent);
}

.richtext-section .ql-toolbar button.ql-active .ql-fill {
  fill: var(--accent);
}

.richtext-section .ql-toolbar .ql-picker-options {
  background: var(--panel);
  border-color: var(--border);
}

.richtext-section .ql-container.ql-snow {
  border: none;
  font-size: 0.875rem;
}

.richtext-section .ql-editor {
  background: rgba(15, 20, 25, 0.3);
  color: var(--text);
  min-height: 200px;
  max-height: 400px;
  overflow-y: auto;
  padding: 1rem 1.25rem;
}

.richtext-section .ql-editor.ql-blank::before {
  color: rgba(148, 163, 184, 0.4);
  font-style: italic;
}

.richtext-section .ql-editor a {
  color: var(--accent);
}

.richtext-section .ql-editor code,
.richtext-section .ql-editor pre {
  background: rgba(45, 53, 72, 0.6);
  border-radius: 4px;
  color: #e2e8f0;
}

.richtext-section .ql-editor pre {
  padding: 0.75rem 1rem;
  margin: 0.5rem 0;
}

/* ============================================
   HTML Source Editor (textarea toggle)
   ============================================ */
.html-source-editor {
  width: 100%;
  min-height: 200px;
  max-height: 400px;
  padding: 1rem 1.25rem;
  background: rgba(15, 20, 25, 0.5);
  color: #a5d6ff;
  border: none;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;
  font-size: 0.8125rem;
  line-height: 1.6;
  resize: vertical;
  outline: none;
  tab-size: 2;
}

.html-source-editor:focus {
  background: rgba(15, 20, 25, 0.6);
}

/* Active state for html-source button */
.richtext-section .ql-toolbar .ql-html-source.ql-active i {
  color: var(--accent) !important;
}

/* ============================================
   Quill Table Styles (inside editor)
   ============================================ */
.richtext-section .ql-editor table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.75rem 0;
}

.richtext-section .ql-editor table td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.6rem;
  min-width: 60px;
  font-size: 0.8125rem;
  vertical-align: top;
}

.richtext-section .ql-editor table td:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* ============================================
   Table Grid Picker (insert)
   ============================================ */
.table-grid-picker {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.table-grid-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-align: center;
  margin-bottom: 0.4rem;
  font-weight: 500;
}

.table-grid {
  display: grid;
  gap: 3px;
}

.table-grid-cell {
  width: 22px;
  height: 22px;
  border: 1px solid var(--border);
  border-radius: 3px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
  background: rgba(15, 20, 25, 0.5);
}

.table-grid-cell:hover,
.table-grid-cell.highlight {
  background: rgba(59, 130, 246, 0.25);
  border-color: var(--accent);
}

/* ============================================
   Floating Table Toolbar
   ============================================ */
.table-float-toolbar {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 2px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  z-index: 150;
  white-space: nowrap;
}

.table-float-toolbar.hidden {
  display: none;
}

.table-float-toolbar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 4px;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.7rem;
  transition: all 0.15s;
}

.table-float-toolbar button:hover {
  background: rgba(59, 130, 246, 0.15);
  color: var(--accent);
}

.table-float-toolbar button.table-float-danger:hover {
  background: rgba(239, 68, 68, 0.15);
  color: var(--danger);
}

.table-float-sep {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 2px;
}

/* Color button highlight */
.table-float-color-btn:hover {
  background: rgba(139, 92, 246, 0.15) !important;
  color: var(--purple) !important;
}

/* Cell Color Palette */
.cell-color-palette {
  position: absolute;
  top: 100%;
  left: 0;
  margin-top: 4px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 200;
}

.cell-color-palette.hidden {
  display: none;
}

.cell-color-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
}

.cell-color-swatch {
  width: 26px;
  height: 26px;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.1s, border-color 0.15s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  color: var(--text-muted);
  padding: 0;
}

.cell-color-swatch:hover {
  transform: scale(1.15);
  border-color: var(--text);
}

.cell-color-none {
  background: transparent;
}

/* ============================================
   Actions Bar (fixed bottom)
   ============================================ */
.prereq-actions-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.5rem;
  background: var(--panel);
  border-top: 1px solid var(--border);
  z-index: 100;
}

.prereq-actions-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.prereq-actions-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.status-message {
  font-size: 0.8125rem;
  color: var(--text-muted);
  transition: color 0.3s;
}

.status-message.success { color: var(--success); }
.status-message.error { color: var(--danger); }
.status-message.warning { color: var(--warning); }

/* ============================================
   Modal
   ============================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
}

.modal-overlay.hidden { display: none; }

.modal-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 90%;
  max-width: 420px;
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  font-size: 1rem;
}

.modal-header.modal-warning {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning);
}

.modal-header.modal-danger {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger);
}

.modal-body {
  padding: 1rem 1.25rem;
  color: var(--text-muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.75rem 1.25rem;
  border-top: 1px solid var(--border);
}

/* ============================================
   Toast
   ============================================ */
.toast {
  position: fixed;
  bottom: 5rem;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  padding: 0.625rem 1.25rem;
  border-radius: 8px;
  font-size: 0.8125rem;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s;
  z-index: 2000;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}

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

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 640px) {
  .main-content {
    padding: calc(var(--header-height) + 1rem) 0.75rem 5rem;
  }

  .page-header {
    flex-direction: column;
    gap: 0.75rem;
  }

  .os-table tbody td input,
  .os-table tbody td select {
    font-size: 0.75rem;
    padding: 0.3rem 0.4rem;
  }

  .prereq-actions-bar {
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
  }
}
