/* КонтентЗавод — дашборд аналитики */
/* Базовые стили: работают даже если Tailwind CDN не загрузился */

body {
  background-color: #111827;
  color: #f3f4f6;
  min-height: 100vh;
  font-family: ui-sans-serif, system-ui, sans-serif, "Segoe UI", Roboto, sans-serif;
  margin: 0;
  line-height: 1.5;
}

#app {
  max-width: 72rem;
  margin-left: auto;
  margin-right: auto;
  padding: 1rem 0.75rem;
}
@media (min-width: 640px) {
  #app { padding: 1.5rem 1.5rem; }
}

header {
  margin-bottom: 1rem;
}
header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 0.25rem 0;
}
@media (min-width: 640px) {
  header h1 { font-size: 1.5rem; }
}
header p {
  color: #9ca3af;
  font-size: 0.875rem;
  margin: 0;
}
@media (min-width: 640px) {
  header p { font-size: 1rem; }
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  padding: 0.5rem;
  background-color: rgba(31, 41, 55, 0.5);
  border-radius: 0.5rem;
  border: 1px solid #374151;
}

.nav-channel {
  padding: 0.5rem 1rem;
  border-radius: 0.5rem;
  font-weight: 500;
  font-size: 0.875rem;
  text-decoration: none;
  transition: background-color 0.15s, color 0.15s;
}
.nav-channel:hover {
  background-color: #374151;
  color: #fff;
}
.nav-channel.bg-blue-600 {
  background-color: #2563eb;
  color: #fff;
}
.nav-channel.text-gray-300 {
  color: #d1d5db;
}

/* Переключатель проекта: одна кнопка, по клику — выбор снизу */
.project-switcher-wrap {
  position: relative;
}
.project-trigger {
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  outline: none;
}
.project-trigger-arrow {
  font-size: 0.65rem;
  opacity: 0.8;
  transition: transform 0.2s;
}
.project-trigger[aria-expanded="true"] .project-trigger-arrow {
  transform: rotate(180deg);
}
.project-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.25rem;
  min-width: 160px;
  background-color: #1f2937;
  border: 1px solid #4b5563;
  border-radius: 0.5rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4);
  z-index: 50;
  padding: 0.25rem 0;
}
.project-dropdown.hidden {
  display: none !important;
}
.project-option {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: #e5e7eb;
  background: none;
  border: none;
  cursor: pointer;
  transition: background-color 0.15s, color 0.15s;
}
.project-option:first-child {
  border-radius: 0.25rem 0.25rem 0 0;
}
.project-option:last-child {
  border-radius: 0 0 0.25rem 0.25rem;
}
.project-option:hover {
  background-color: #374151;
  color: #fff;
}

#page-main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

#summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}
@media (min-width: 640px) {
  #summary {
    grid-template-columns: repeat(4, 1fr);
    gap: 1rem;
  }
}

.card {
  background-color: #1f2937;
  border-radius: 0.5rem;
  padding: 1rem;
  border: 1px solid #374151;
}
.card > div:first-child {
  color: #9ca3af;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
@media (min-width: 640px) {
  .card > div:first-child { font-size: 0.875rem; }
}
.card .text-2xl,
.card .text-3xl {
  font-size: 1.5rem;
  font-weight: 700;
}
@media (min-width: 640px) {
  .card .text-2xl { font-size: 1.875rem; }
  .card .text-3xl { font-size: 1.875rem; }
}
.text-white { color: #fff; }
.text-green-400 { color: #4ade80; }
.text-red-400 { color: #f87171; }
.text-blue-400 { color: #60a5fa; }

h2, h3 {
  color: #fff;
  font-weight: 600;
  margin: 0 0 0.75rem 0;
}
h2 { font-size: 1.125rem; }
h3 { font-size: 1rem; font-weight: 500; }

.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-3 { margin-bottom: 0.75rem; }
.mb-6 { margin-bottom: 1.5rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }

#chart,
#channel-chart {
  background-color: #1f2937;
  border-radius: 0.5rem;
  padding: 1rem;
  border: 1px solid #374151;
  min-height: 200px;
}

.timeline-btn,
.channel-timeline-btn,
button.px-4 {
  padding: 0.375rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: background-color 0.15s;
}
.timeline-btn,
.channel-timeline-btn {
  background-color: #374151;
  color: #d1d5db;
}
.timeline-btn:hover,
.channel-timeline-btn:hover {
  background-color: #4b5563;
}
button.px-4.py-2 {
  padding: 0.5rem 1rem;
  background-color: #374151;
  color: #d1d5db;
}
button.px-4.py-2:hover {
  background-color: #4b5563;
}

#services-list {
  display: grid;
  gap: 0.75rem;
}
@media (min-width: 640px) {
  #services-list { grid-template-columns: repeat(3, 1fr); }
}
#services-items {
  grid-column: 1 / -1;
  display: grid;
  gap: 0.75rem;
  grid-template-columns: 1fr;
}
@media (min-width: 640px) {
  #services-items { grid-template-columns: repeat(3, 1fr); }
}
#services-items .rounded-lg {
  border-radius: 0.5rem;
  padding: 1rem;
  border: 1px solid #374151;
  background-color: #1f2937;
}
#services-items .border-green-800 { border-color: #166534; }
#services-items .border-red-900 { border-color: #7f1d1d; }
#services-items .bg-green-500 { background-color: #22c55e; }
#services-items .bg-red-500 { background-color: #ef4444; }

#runs-list.space-y-4 > * + * { margin-top: 1rem; }
.text-gray-500 { color: #6b7280; }
.py-8 { padding-top: 2rem; padding-bottom: 2rem; }
.text-center { text-align: center; }
.col-span-full { grid-column: 1 / -1; }
.hidden { display: none !important; }

#page-channel.hidden { display: none !important; }
#page-channel.space-y-6 > * + * { margin-top: 1.5rem; }
.channel-stats-section h3 {
  margin-bottom: 0.75rem;
}
#channel-summary {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}
#channel-summary .card .text-2xl {
  font-size: 1.5rem;
  font-weight: 700;
}
@media (min-width: 640px) {
  #channel-summary { grid-template-columns: repeat(4, 1fr); }
  #channel-summary .card .text-2xl { font-size: 1.875rem; }
}
#channel-funnel {
  background-color: #1f2937;
  border-radius: 0.5rem;
  padding: 1rem;
  border: 1px solid #374151;
}
#channel-funnel-content { color: #9ca3af; font-size: 0.875rem; }

/* Попап ошибки */
#error-panel {
  position: fixed;
  inset: 0;
  z-index: 50;
}
#error-panel .absolute.inset-0 {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.7);
}
#error-panel .absolute.bottom-0 {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 80vh;
  overflow: auto;
  background-color: #1f2937;
  border-top: 1px solid #4b5563;
  border-radius: 1rem 1rem 0 0;
  padding: 1rem;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}
@media (min-width: 640px) {
  #error-panel .absolute.bottom-0 { padding: 1.5rem; }
}
#error-panel h3.text-red-400 { color: #f87171; }
#error-panel-message {
  background-color: #111827;
  padding: 0.75rem;
  border-radius: 0.375rem;
  font-size: 0.875rem;
  color: #9ca3af;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}
.run-show-error {
  margin-top: 0.5rem;
  padding: 0.375rem 0.75rem;
  border-radius: 0.5rem;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  background-color: rgba(127, 29, 29, 0.5);
  color: #fca5a5;
}
.run-show-error:hover {
  background-color: rgba(153, 27, 27, 0.5);
}

/* ApexCharts */
#timeline-chart .apexcharts-canvas,
#channel-timeline-chart .apexcharts-canvas {
  margin: 0 auto;
}

.step-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.step-dot.completed { background-color: #22c55e; }
.step-dot.failed { background-color: #ef4444; cursor: pointer; }
.step-dot.pending,
.step-dot.skipped { background-color: #6b7280; }
.step-dot.running {
  background-color: #3b82f6;
  animation: pulse 1s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.run-card {
  background-color: #1f2937;
  border-radius: 0.5rem;
  padding: 1rem;
  border: 1px solid #374151;
  transition: background-color 0.15s;
}
.run-card:hover {
  background-color: rgba(31, 41, 55, 0.8);
}

#error-panel[aria-hidden="false"] {
  display: block;
}

.error-panel-message {
  user-select: text;
  -webkit-user-select: text;
}
