/* ===== Atlantic Búsqueda/Análisis de licitaciones — Design System ===== */

:root {
  --atlantic: #10672F;
  --atlantic-light: #e8f5ed;
  --atlantic-mid: #1a8a40;
  --atlantic-dark: #0b4a21;

  --bg: #f7f8fa;
  --surface: #ffffff;
  --border: #e2e5ea;
  --border-light: #f0f1f4;

  --ink: #1a1d21;
  --ink-secondary: #5f6368;
  --ink-tertiary: #9aa0a6;

  --danger: #c5221f;
  --danger-bg: #fce8e6;
  --success: #137333;
  --success-bg: #e6f4ea;
  --warning-bg: #fef7e0;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.08);

  --transition: 150ms ease;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: var(--ink);
  background: var(--bg);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ===== Top Bar ===== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--atlantic);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.15);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px;
  height: 56px;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-logo {
  height: 32px;
  width: auto;
  filter: brightness(0) invert(1);
}

.topbar-separator {
  width: 1px;
  height: 24px;
  background: rgba(255, 255, 255, 0.3);
}

.topbar-title {
  font-weight: 600;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.9);
  letter-spacing: 0.02em;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

/* ===== Layout ===== */

.shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 24px 24px 48px;
}

/* ===== Flash ===== */

.flash {
  position: fixed;
  top: 72px;
  right: 24px;
  z-index: 240;
  max-width: min(420px, calc(100vw - 32px));
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 0.875rem;
  font-weight: 600;
  border: 1px solid var(--border);
  background: var(--surface);
  box-shadow: 0 18px 42px rgba(8, 20, 12, 0.16);
  transform: translateY(-10px) scale(0.98);
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.flash.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.flash.is-hiding {
  opacity: 0;
  transform: translateY(-8px) scale(0.98);
}

.flash.success {
  border-color: var(--success);
  background: var(--success-bg);
  color: var(--success);
}

.flash.error {
  border-color: var(--danger);
  background: var(--danger-bg);
  color: var(--danger);
}

/* ===== Status Row ===== */

.status-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.status-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition);
}

.status-card:hover {
  box-shadow: var(--shadow-md);
}

.status-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: var(--radius-sm);
  background: var(--atlantic-light);
  color: var(--atlantic);
}

.status-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.status-label {
  font-size: 0.75rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-tertiary);
}

.status-info strong {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink);
  line-height: 1.3;
  word-break: break-word;
}

/* ===== Cards ===== */

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

.card-header {
  margin-bottom: 20px;
}

.card-header h2 {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.3;
}

.card-subtitle {
  margin: 4px 0 0;
  font-size: 0.8125rem;
  color: var(--ink-secondary);
}

.card-header-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.card-note {
  margin: 16px 0 0;
  font-size: 0.8125rem;
  color: var(--ink-tertiary);
  line-height: 1.5;
}

.card-note code {
  background: var(--atlantic-light);
  color: var(--atlantic-dark);
  padding: 2px 5px;
  border-radius: 4px;
  font-size: 0.75rem;
}

/* ===== Config Grid ===== */

.config-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 24px;
}

/* ===== Toggle ===== */

.toggle-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.mailing-toggle-row {
  margin-top: 28px;
}

.toggle {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}

.toggle input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-track {
  position: relative;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--ink-tertiary);
  transition: background var(--transition);
  flex-shrink: 0;
}

.toggle-track::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: white;
  transition: transform var(--transition);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.toggle input:checked+.toggle-track {
  background: var(--atlantic);
}

.toggle input:checked+.toggle-track::after {
  transform: translateX(18px);
}

.toggle-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--ink);
}

/* ===== Fields ===== */

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-full {
  grid-column: 1 / -1;
}

.field-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-secondary);
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font: inherit;
  font-size: 0.875rem;
  transition: border-color var(--transition), box-shadow var(--transition);
}

input:focus,
textarea:focus {
  outline: none;
  border-color: var(--atlantic);
  box-shadow: 0 0 0 3px rgba(16, 103, 47, 0.15);
}

input::placeholder,
textarea::placeholder {
  color: var(--ink-tertiary);
}

textarea {
  min-height: 180px;
  resize: vertical;
  font-family: "Inter", sans-serif;
}

textarea.mailing-recipients {
  min-height: 96px;
}

.field-stack {
  margin-top: 16px;
}

/* ===== Buttons ===== */

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 8px 16px;
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition), transform var(--transition);
  white-space: nowrap;
}

.btn[disabled] {
  cursor: not-allowed;
  opacity: 0.72;
  box-shadow: none;
}

.btn:active {
  transform: scale(0.97);
}

.btn svg {
  flex-shrink: 0;
}

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

.btn-primary:hover {
  background: var(--atlantic-dark);
  box-shadow: var(--shadow-sm);
}

.btn-accent {
  color: var(--atlantic-dark);
  background: var(--atlantic-light);
  border: 1px solid rgba(16, 103, 47, 0.2);
}

.btn-accent:hover {
  background: #d4edda;
  box-shadow: var(--shadow-sm);
}

.btn-accent.is-running {
  position: relative;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(135deg, #15863f 0%, #10672f 52%, #0d5226 100%);
  border-color: rgba(16, 103, 47, 0.3);
  box-shadow: 0 10px 26px rgba(16, 103, 47, 0.22);
  animation: scheduler-button-pulse 1.8s ease-in-out infinite;
}

.btn-accent.is-running:hover {
  background: linear-gradient(135deg, #15863f 0%, #10672f 52%, #0d5226 100%);
  box-shadow: 0 10px 26px rgba(16, 103, 47, 0.22);
}

.btn-accent.is-running::before {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(110deg, transparent 0%, rgba(255, 255, 255, 0.14) 45%, transparent 72%);
  transform: translateX(-135%);
  animation: scheduler-button-sheen 1.6s ease-in-out infinite;
}

.btn-loader {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  filter: drop-shadow(0 0 8px rgba(255, 255, 255, 0.18));
}

.btn-accent.is-running .btn-loader svg {
  animation: scheduler-spin 0.72s linear infinite;
  transform-origin: center;
}

.btn-running-copy {
  position: relative;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}

.btn-running-dots {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.btn-running-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.22;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.28);
  animation: scheduler-loading-dot 0.95s ease-in-out infinite;
}

.btn-running-dots span:nth-child(2) {
  animation-delay: 0.16s;
}

.btn-running-dots span:nth-child(3) {
  animation-delay: 0.32s;
}

@keyframes scheduler-spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes scheduler-button-pulse {
  0%,
  100% {
    box-shadow: 0 10px 26px rgba(16, 103, 47, 0.22);
  }
  50% {
    box-shadow: 0 14px 34px rgba(16, 103, 47, 0.34);
  }
}

@keyframes scheduler-button-sheen {
  0% {
    transform: translateX(-135%);
  }
  100% {
    transform: translateX(135%);
  }
}

@keyframes scheduler-loading-dot {
  0%,
  80%,
  100% {
    opacity: 0.22;
    transform: translateY(0) scale(0.78);
  }
  40% {
    opacity: 1;
    transform: translateY(-2px) scale(1.18);
  }
}

.btn-ghost {
  color: var(--atlantic);
  background: transparent;
  border: 1px solid var(--border);
}

.btn-ghost:hover {
  background: var(--atlantic-light);
}

.btn-inline {
  color: var(--atlantic-dark);
  background: rgba(16, 103, 47, 0.08);
  border: 1px solid rgba(16, 103, 47, 0.16);
  padding: 6px 12px;
}

.btn-inline:hover {
  background: rgba(16, 103, 47, 0.14);
}

.btn-icon {
  color: var(--atlantic-dark);
  background: transparent;
  border: 1px solid var(--border);
  padding: 0;
  width: 32px;
  height: 32px;
  justify-content: center;
  border-radius: var(--radius-sm);
}

.btn-icon+.btn-icon {
  margin-left: 6px;
}

.btn-icon:hover {
  background: var(--atlantic-light);
  border-color: rgba(16, 103, 47, 0.3);
}

/* Topbar overrides for buttons rendered on the green background */
.topbar .btn-ghost,
.topbar .btn-icon {
  color: rgba(255, 255, 255, 0.85);
  border-color: rgba(255, 255, 255, 0.25);
  background: transparent;
}

.topbar .btn-ghost:hover,
.topbar .btn-icon:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.4);
}

/* ===== Runs Table ===== */

.runs-card {
  margin-bottom: 0;
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-light);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8125rem;
}

th,
td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: top;
}

th {
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--ink-tertiary);
  background: var(--bg);
}

tbody tr:hover {
  background: rgba(16, 103, 47, 0.02);
}

tbody tr:last-child td {
  border-bottom: none;
}

td strong {
  font-weight: 600;
}

.empty {
  text-align: center;
  color: var(--ink-tertiary);
  padding: 32px 16px;
}

.table-wrap td:last-child,
.table-wrap th:last-child {
  white-space: nowrap;
}

/* ===== Badges ===== */

.badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.badge.success {
  background: var(--success-bg);
  color: var(--success);
}

.badge.failed {
  background: var(--danger-bg);
  color: var(--danger);
}

.badge.running {
  background: var(--warning-bg);
  color: #b06000;
}

.badge.idle,
.badge.disabled {
  background: var(--bg);
  color: var(--ink-tertiary);
  border: 1px solid var(--border);
}

.run-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 0.75rem;
  color: var(--ink-secondary);
}

.run-stats-sep {
  color: var(--ink-tertiary);
}

.run-stats-warn {
  color: var(--danger);
  font-weight: 600;
}

/* ===== Report Modal ===== */

.report-modal {
  position: fixed;
  inset: 0;
  z-index: 220;
}

.report-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(9, 16, 12, 0.42);
  backdrop-filter: blur(8px);
}

.report-panel {
  position: absolute;
  top: 24px;
  right: 24px;
  bottom: 24px;
  width: min(760px, calc(100vw - 32px));
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, #fcfdfc 0%, #f4f8f5 100%);
  border: 1px solid rgba(16, 103, 47, 0.16);
  border-radius: 24px;
  box-shadow: 0 28px 80px rgba(8, 20, 12, 0.24);
  overflow: hidden;
}

.report-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 24px 24px 18px;
  border-bottom: 1px solid rgba(16, 103, 47, 0.1);
  background:
    radial-gradient(circle at top right, rgba(16, 103, 47, 0.12), transparent 36%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(246, 250, 247, 0.96));
}

.report-kicker {
  display: inline-block;
  margin-bottom: 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--atlantic-mid);
}

.report-header h2 {
  margin: 0;
  font-size: 1.45rem;
  line-height: 1.2;
}

.report-subtitle {
  margin: 6px 0 0;
  color: var(--ink-secondary);
  font-size: 0.875rem;
}

.report-close {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 999px;
  background: rgba(16, 103, 47, 0.08);
  color: var(--atlantic-dark);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}

.report-close:hover {
  background: rgba(16, 103, 47, 0.16);
}

.report-close:active {
  transform: scale(0.95);
}

.report-body {
  flex: 1;
  overflow-y: auto;
  padding: 22px 24px 24px;
}

.report-section+.report-section {
  margin-top: 18px;
}

.report-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.report-section-head h3 {
  margin: 0;
  font-size: 0.95rem;
}

.report-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(16, 103, 47, 0.08);
  color: var(--atlantic-dark);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.report-stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.report-stat {
  padding: 14px 16px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid rgba(16, 103, 47, 0.1);
  box-shadow: 0 8px 20px rgba(14, 31, 19, 0.05);
}

.report-stat-label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-tertiary);
}

.report-stat strong {
  display: block;
  margin-top: 6px;
  font-size: 1.15rem;
  line-height: 1.1;
}

.report-code {
  margin: 0;
  padding: 16px;
  border-radius: 16px;
  border: 1px solid rgba(16, 103, 47, 0.1);
  background: #fcfdfc;
  color: #10311a;
  overflow-x: auto;
  font-size: 0.78rem;
  line-height: 1.55;
}

.report-list {
  display: grid;
  gap: 10px;
}

.report-item {
  padding: 14px 16px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid rgba(16, 103, 47, 0.1);
  box-shadow: 0 6px 16px rgba(11, 28, 18, 0.04);
}

.report-item-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.report-item-title {
  margin: 0;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
}

.report-item-subtitle {
  margin: 2px 0 0;
  font-size: 0.8rem;
  color: var(--ink-secondary);
}

.report-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.report-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--ink-secondary);
  font-size: 0.74rem;
  font-weight: 600;
}

.report-summary {
  margin: 0;
  color: var(--ink-secondary);
  font-size: 0.82rem;
  line-height: 1.5;
}

.report-warning {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--danger-bg);
  color: var(--danger);
  font-size: 0.78rem;
  font-weight: 600;
}

.empty-state {
  padding: 18px;
  border-radius: 16px;
  border: 1px dashed rgba(16, 103, 47, 0.18);
  background: rgba(255, 255, 255, 0.7);
  color: var(--ink-tertiary);
  text-align: center;
}

/* ===== Responsive ===== */

@media (max-width: 1080px) {
  .status-row {
    grid-template-columns: repeat(2, 1fr);
  }

  .config-grid {
    grid-template-columns: 1fr;
  }

  .report-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .topbar-inner {
    padding: 0 16px;
  }

  .shell {
    padding: 16px 16px 40px;
  }

  .flash {
    top: 68px;
    right: 16px;
    left: 16px;
    max-width: none;
  }

  .status-row {
    grid-template-columns: 1fr;
  }

  .field-grid {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    flex-direction: column;
    gap: 4px;
  }

  .toggle-row {
    flex-direction: column;
  }

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

  .report-panel {
    top: 12px;
    right: 12px;
    left: 12px;
    bottom: 12px;
    width: auto;
  }

  .report-header,
  .report-body {
    padding-left: 16px;
    padding-right: 16px;
  }

  .report-stats {
    grid-template-columns: 1fr;
  }

  .report-item-head,
  .report-section-head {
    flex-direction: column;
    align-items: flex-start;
  }
}
