@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root {
  --bg: #f5f7fb;
  --surface: #ffffff;
  --border: #e6e8ef;
  --card-shadow: 0 12px 40px rgba(15, 23, 42, 0.08);
  --primary: #2563eb;
  --primary-strong: #1d4ed8;
  --text: #0f172a;
  --muted: #6b7280;
  --success: #16a34a;
  --error: #dc2626;
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Space Grotesk', 'Segoe UI', sans-serif;
  margin: 0;
  color: var(--text);
  background: radial-gradient(circle at 20% 20%, #e8edff, #f5f7fb 25%),
    radial-gradient(circle at 80% 0%, #e7f7ff, #f5f7fb 28%),
    var(--bg);
  min-height: 100vh;
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  color: var(--primary-strong);
}

.navbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 32px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 6px 24px rgba(15, 23, 42, 0.06);
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.brand-badge {
  padding: 2px 8px;
  background: #e0e7ff;
  color: var(--primary-strong);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 16px;
}

.nav-toggle {
  display: none !important;
  padding: 10px 12px;
}

.navbar-user {
  color: var(--muted);
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 12px;
  background: #f3f6fb;
}

.container {
  max-width: 1180px;
  margin: 32px auto 48px;
  padding: 0 24px;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 24px;
  box-shadow: var(--card-shadow);
}

.layout-two-col {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 18px;
  align-items: start;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 18px;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 12px;
  color: var(--muted);
  margin: 0 0 4px 0;
}

h1 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.02em;
}

h3 {
  margin-top: 24px;
  margin-bottom: 12px;
}

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

.table th,
.table td {
  padding: 12px 10px;
  border-bottom: 1px solid var(--border);
}

.table th {
  text-align: left;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.table tr:hover td {
  background: #f8fafc;
}

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

.table-responsive {
  width: 100%;
  overflow-x: auto;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f8fafc;
  color: var(--text);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn.sm {
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 14px;
}

.btn.primary {
  background: linear-gradient(90deg, #2563eb, #1d4ed8);
  color: #ffffff;
  border: 1px solid #1d4ed8;
  box-shadow: 0 10px 25px rgba(37, 99, 235, 0.22);
}

.btn.neutral {
  background: #eef2ff;
  color: #1e293b;
  border: 1px solid #e2e8f0;
}

.btn.danger {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.btn.ghost.sm {
  padding: 8px 12px;
}

.btn.primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 28px rgba(37, 99, 235, 0.26);
}

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}

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

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 12px;
}

input[type="text"],
input[type="email"],
input[type="number"],
input[type="password"],
textarea,
select {
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f8fafc;
  font-size: 15px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

input:focus,
textarea:focus,
select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
  background: #ffffff;
}

textarea {
  resize: vertical;
  min-height: 120px;
}

.quill-wrapper {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f8fafc;
  overflow: hidden;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.quill-wrapper:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
  background: #ffffff;
}

.quill-wrapper .ql-toolbar {
  border: none;
  border-bottom: 1px solid var(--border);
  background: #eef2ff;
  padding: 8px 10px;
}

.quill-wrapper .ql-container {
  border: none;
  background: transparent;
}

.quill-wrapper .ql-editor {
  min-height: 140px;
  padding: 12px;
  line-height: 1.6;
  color: var(--text);
}

.quill-wrapper .ql-editor.ql-blank::before {
  color: var(--muted);
}

.form {
  display: grid;
  gap: 6px;
}

.section-mode {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: -4px 0 8px;
}

.inline-option {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
}

.help-text {
  color: var(--muted);
  font-size: 14px;
  margin-top: 6px;
}

.flashes {
  list-style: none;
  padding: 0;
  margin: 0 0 16px 0;
  display: grid;
  gap: 8px;
}

.flash {
  padding: 12px 14px;
  border-radius: 12px;
  font-weight: 600;
  border: 1px solid var(--border);
}

.flash-success {
  background: #ecfdf3;
  color: #166534;
  border-color: #bbf7d0;
}

.flash-error {
  background: #fef2f2;
  color: #b91c1c;
  border-color: #fecaca;
}

.flash-info {
  background: #eef2ff;
  color: #4338ca;
  border-color: #c7d2fe;
}

.proposal-body {
  white-space: pre-wrap;
  line-height: 1.6;
  color: var(--text);
}

.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #eef2ff;
  color: #4338ca;
  font-weight: 600;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 16px;
}

.inline-form {
  display: inline;
}

.preview-card {
  position: sticky;
  top: 96px;
}

.preview-body {
  white-space: pre-wrap;
  line-height: 1.6;
  color: var(--text);
  min-height: 240px;
}

hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 20px 0;
}

.template-name-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: #f8fafc;
  font-weight: 600;
}

.template-name-input[readonly] {
  background: #f8fafc;
  color: var(--text);
}

.rename-form {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.responsive-table th,
.responsive-table td {
  vertical-align: top;
}

.actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-start;
}

@media (max-width: 768px) {
  .navbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
  }

  .nav-toggle {
    display: inline-flex !important;
  }

  .nav-links {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 10px 0 0 0;
    display: none;
  }

  .nav-links.open {
    display: flex;
  }

  .nav-links a,
  .nav-links .navbar-user,
  .nav-links .btn {
    width: 100%;
  }

  .container {
    margin: 24px auto 32px;
    padding: 0 16px;
  }

  .card {
    padding: 20px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .page-header .btn {
    width: 100%;
    justify-content: center;
  }

  .grid,
  .layout-two-col {
    grid-template-columns: 1fr;
  }

  .table-responsive {
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
  }

  .responsive-table thead {
    display: none;
  }

  .responsive-table tr {
    display: block;
    border-bottom: 1px solid var(--border);
    padding: 12px;
  }

  .responsive-table td {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: 8px;
    padding: 8px 0;
    border: 0;
  }

  .responsive-table td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 12px;
  }

  .table .actions {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  .actions {
    width: 100%;
  }

  .table .actions .inline-form,
  .table .actions a {
    width: 100%;
  }

  .table .actions .btn,
  .table .actions a.btn {
    width: 100%;
    justify-content: center;
  }

  .rename-form {
    width: 100%;
  }

  .rename-form .btn,
  .rename-form .btn.ghost {
    width: 100%;
    justify-content: center;
  }

  .template-name-input {
    width: 100%;
  }

  .preview-card {
    position: static;
  }
}

/* === Acciones en tablas: versión profesional === */

.actions-cell {
  text-align: right;
  white-space: nowrap;
}

/* Contenedor de acciones */
.actions-group {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  padding: 4px 0;
}

/* El form no debe romper el layout */
.actions-group .inline-form {
  display: inline-block;
  margin: 0;
}

/* Estilo base de los botones de acción dentro de la tabla */
.actions-group .btn {
  padding: 6px 12px;
  font-size: 13px;
  font-weight: 500;
  border-radius: 999px;
  box-shadow: none;
  border-width: 1px;
}

/* Link suave para "Ver propuestas" */
.actions-group .action-link {
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  padding-left: 0;
}

.actions-group .action-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* CTA principal "Nueva propuesta" */
.actions-group .action-main {
  background: linear-gradient(90deg, var(--primary), var(--primary-strong));
  border-color: var(--primary-strong);
  color: #fff;
}

/* Botón neutro "Editar" */
.actions-group .action-secondary {
  background: #f3f4ff;
  border-color: #e5e7eb;
  color: #111827;
}

/* Botón "Eliminar" discreto pero claro */
.actions-group .action-danger {
  background: #fef2f2;
  border-color: #fecaca;
  color: #b91c1c;
}

/* Hover sutil en todos menos el link */
.actions-group .btn:not(.action-link):hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
}

/* --- Responsive: en móvil se apilan bonito --- */
@media (max-width: 768px) {
  .actions-cell {
    text-align: left;
    white-space: normal;
  }

  .actions-group {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: 100%;
  }

  .actions-group .btn,
  .actions-group .inline-form,
  .actions-group .inline-form .btn {
    width: 100%;
    justify-content: center;
  }

  .actions-group .action-link {
    padding-left: 0;
    justify-content: flex-start;
    width: 100%;
  }
}
