/* CSS Variables - colors are set by theme in index.html */
:root {
  /* Accent colors derived from theme fill colors */
  --accent-blue: var(--fill-color-4);
  --accent-blue-light: var(--fill-color-5);
  --accent-blue-dark: var(--fill-color-3);

  /* Shadow */
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3);
}

/* Reset and base styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  overflow-x: hidden;
}

/* Container */
.container {
  max-width: 1800px;
  margin: 0 auto;
  padding: 18px;
  min-height: 100vh;
}

/* Header */
header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 18px;
  padding: 15px;
  background: var(--bg-secondary);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

header h1 {
  font-size: 2rem;
  margin-bottom: 5px;
  color: var(--accent-blue);
  font-weight: 700;
}

.header-controls {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  justify-items: start;
  position: relative;
  min-height: 40px;
  width: 100%;
  max-width: 650px;
}

.header-skeleton {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 36px;
  background: var(--bg-tertiary);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  z-index: 1;
  display: none;
}

.desktop-skeleton {
  display: block;
}

.variant-select {
  min-width: 200px;
  width: 100%;
}

.theme-select {
  min-width: 140px;
  width: 100%;
}

.variant-select,
.theme-select {
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 1rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
  outline: none;
  transition: all 0.2s ease;
  display: inline-block;
  max-width: 100%;
  width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  height: 40px;
}

.variant-select:hover,
.theme-select:hover {
  background: var(--bg-secondary);
  border-color: var(--accent-blue);
}

.variant-select:focus,
.theme-select:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.theme-select {
  width: auto;
  min-width: 120px;
}

/* Main Content Layout */
.main-content {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 18px;
  align-items: start;
}

/* Graph Container */
.graph-container {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 18px;
  box-shadow: var(--shadow);
  position: relative;
  min-height: 700px;
}

#cy {
  width: 100%;
  height: 700px;
  border-radius: 8px;
  background: var(--bg-primary);
  cursor: grab;
}

/* Watermark */
.watermark {
  position: absolute;
  top: 25px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.75rem;
  font-weight: 600;
  color: white;
  text-shadow:
    -1px -1px 0 black,
    1px -1px 0 black,
    -1px 1px 0 black,
    1px 1px 0 black;
  z-index: 5;
}

/* Progress Gauge */
.progress-container {
  position: absolute;
  bottom: 30px;
  right: 30px;
  z-index: 10;
}

.screenshot-container {
  position: absolute;
  bottom: 30px;
  left: 30px;
  z-index: 10;
  display: flex;
  gap: 10px;
}

.progress-circle {
  width: 120px;
  height: 120px;
  position: relative;
  background: var(--bg-secondary);
  border-radius: 50%;
  padding: 10px;
  box-shadow: var(--shadow);
}

.progress-circle svg {
  transform: rotate(-90deg);
  width: 100%;
  height: 100%;
}

.progress-bg {
  fill: none;
  stroke: var(--bg-tertiary);
  stroke-width: 8;
}

.progress-bar {
  fill: none;
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 283;
  stroke-dashoffset: 283;
  transition: stroke-dashoffset 0.5s ease;
}

.progress-bar-pending {
  stroke: var(--fill-color-3);
}

.progress-bar-approved {
  stroke: var(--accent-blue);
}

.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

#progress-percentage {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent-blue);
  font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

.progress-secondary {
  display: block;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--fill-color-3);
  margin-top: -4px;
  font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

.progress-label {
  display: block;
  font-size: 0.7rem;
  color: var(--text-muted);
  margin-top: 2px;
  font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Legend Panel */
.legend-panel {
  background: var(--bg-secondary);
  border-radius: 12px;
  padding: 25px;
  box-shadow: var(--shadow);
  position: sticky;
  top: 18px;
}

.legend-panel h2 {
  font-size: 1.5rem;
  margin-bottom: 18px;
  color: var(--accent-blue);
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 10px;
}

.legend-separator {
  border: none;
  height: 1px;
  background: var(--border-color);
  margin: 10px 0;
}

.legend-items {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 30px;
}

#status-legend,
#border-legend {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.95rem;
}

.legend-item.special {
  margin-top: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border-color);
}

.legend-color {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Border color class for legend (dynamically styled) */
.legend-border {
  border: 4px solid;
  background: transparent;
  width: 40px;
  height: 40px;
  border-radius: 50%;
}

/* Skeleton loading styles */
.skeleton-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.skeleton-circle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--bg-tertiary);
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  flex-shrink: 0;
}

.skeleton-text {
  height: 16px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  flex: 1;
  max-width: 120px;
}

/* Skeleton for select elements */
.variant-select.skeleton {
  width: 100%;
}

.theme-select.skeleton {
  width: auto;
}

select.skeleton {
  background: var(--bg-tertiary);
  color: transparent;
  animation: skeleton-pulse 1.5s ease-in-out infinite;
  cursor: not-allowed;
  pointer-events: none;
  padding: 6px 12px;
}

@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

/* Controls */
.controls {
  margin-top: 30px;
  padding-top: 18px;
  border-top: 2px solid var(--border-color);
}

.controls h3 {
  font-size: 1.2rem;
  margin-bottom: 15px;
  color: var(--text-primary);
}

.control-description {
  color: var(--text-secondary);
  font-size: 0.9rem;
  margin-bottom: 8px;
  line-height: 1.5;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 15px;
}

.btn-reset,
.btn-fit,
.btn-export,
.btn-import,
.btn-screenshot {
  width: auto;
  min-width: 40px;
  height: 40px;
  padding: 0 8px;
  margin-top: 0;
  background: var(--accent-blue);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-reset svg,
.btn-fit svg,
.btn-export svg,
.btn-import svg,
.btn-screenshot svg {
  width: 18px;
  height: 18px;
}

.btn-reset:hover,
.btn-fit:hover,
.btn-export:hover,
.btn-import:hover,
.btn-screenshot:hover {
  background: var(--accent-blue-light);
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.btn-reset:active,
.btn-fit:active,
.btn-export:active,
.btn-import:active,
.btn-screenshot:active {
  transform: translateY(0);
}

.btn-export,
.btn-import {
  width: 109px;
}

.btn-reset {
  background: var(--btn-reset);
}

.btn-reset:hover {
  background: var(--btn-reset-hover);
}

.btn-fit {
  background: var(--btn-secondary);
}

.btn-fit:hover {
  background: var(--btn-secondary-hover);
}

.btn-export {
  background: var(--btn-secondary);
}

.btn-export:hover {
  background: var(--btn-secondary-hover);
}

.btn-import {
  background: var(--btn-secondary);
}

.btn-import:hover {
  background: var(--btn-secondary-hover);
}

.btn-screenshot {
  background: var(--accent-blue);
}

.btn-screenshot:hover {
  background: var(--accent-blue-light);
}

/* Responsive Design */
@media (max-width: 1200px) {
  .main-content {
    grid-template-columns: 1fr;
  }

  .legend-panel {
    position: relative;
    top: 0;
  }

  .progress-container {
    bottom: 25px;
    right: 25px;
  }

  .screenshot-container {
    bottom: 25px;
    left: 25px;
  }

  .progress-circle {
    width: 100px;
    height: 100px;
  }

  #progress-percentage {
    font-size: 1.3rem;
  }
}

@media (max-width: 768px) {
  header h1 {
    font-size: 2rem;
  }

  .header-controls {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .desktop-skeleton {
    display: none;
  }

  .mobile-skeleton {
    display: block;
  }

  .header-skeleton {
    position: static;
    margin-bottom: 8px;
  }

  .variant-select {
    font-size: 0.9rem;
    width: 100%;
    text-align: center;
  }

  .theme-select {
    width: 100%;
    text-align: center;
  }

  #cy {
    height: 500px;
  }

  .graph-container {
    min-height: 500px;
    padding: 15px;
  }

  .legend-panel {
    padding: 18px;
  }
}

/* Cytoscape tooltip (if needed) */
.cy-tooltip {
  position: absolute;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.9rem;
  pointer-events: none;
  z-index: 1000;
  box-shadow: var(--shadow);
  display: none;
}

/* GitHub Corner */
.github-corner {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 1000;
  color: var(--bg-primary);
  fill: var(--accent-blue);
}

.github-corner:hover .octo-arm {
  animation: octocat-wave 560ms ease-in-out;
}

@keyframes octocat-wave {
  0%, 100% { transform: rotate(0); }
  20%, 60% { transform: rotate(-25deg); }
  40%, 80% { transform: rotate(10deg); }
}
