/* Rails Map Styles */
/* Import common styles */
@import url('/common.css');

/* Rails Map specific variables */
:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #6e7681;
  --border-color: #30363d;
  --accent-blue: #58a6ff;
  --accent-green: #3fb950;
  --accent-purple: #a371f7;
  --accent-orange: #d29922;
  --accent-red: #f85149;
  --accent-pink: #db61a2;
}

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

/* Header - matching common.css exactly */
header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 0 20px;
  height: 54px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
  line-height: 1;
}

header h1 {
  font-size: 18px;
  font-weight: 600;
  height: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Stats Bar */
.stats-bar {
  display: flex;
  gap: 24px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 6px 12px;
  border-radius: 6px;
  transition: background 0.2s;
}

.stat:hover {
  background: var(--bg-tertiary);
}
.stat.active {
  background: var(--bg-tertiary);
  box-shadow: inset 0 0 0 1px var(--accent-blue);
}

.stat-value {
  font-size: 18px;
  font-weight: 600;
}
.stat-label {
  color: var(--text-secondary);
  font-size: 12px;
}

/* Container Layout */
.container {
  display: grid;
  grid-template-columns: 280px 1fr 350px;
  height: calc(100vh - 54px);
}

/* Sidebar */
.sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.sidebar-section {
  padding: 12px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.sidebar-section.namespaces {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-section.namespaces .namespace-list {
  flex: 1;
  overflow-y: auto;
}

.sidebar-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

/* Search */
.search-box {
  width: 100%;
  padding: 8px 12px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-primary);
  font-size: 13px;
}

.search-box:focus {
  outline: none;
  border-color: var(--accent-blue);
}

/* Header Nav */
.header-nav {
  display: flex;
  gap: 4px;
}

.header-nav .nav-link {
  padding: 6px 12px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  border-radius: 4px;
  transition: all 0.15s;
}

.header-nav .nav-link:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.header-nav .nav-link.active {
  background: var(--accent-blue);
  color: white;
}

/* Namespace List */
.namespace-list {
  max-height: none;
  overflow-y: auto;
}

/* Panel Count */
.panel-count {
  font-size: 13px;
  color: var(--text-secondary);
  font-weight: 500;
}

/* Show More */
.show-more-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px;
  border-top: 1px solid var(--border-color);
  margin-top: 8px;
}

.show-more-btn {
  background: var(--accent-blue);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.2s;
}

.show-more-btn:hover {
  background: #4c8fe6;
}

.show-more-count {
  color: var(--text-secondary);
  font-size: 12px;
}

.namespace-item {
  padding: 6px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.namespace-item:hover {
  background: var(--bg-tertiary);
}
.namespace-item.active {
  background: var(--accent-blue);
  color: white;
}

.namespace-count {
  background: var(--bg-tertiary);
  padding: 2px 6px;
  border-radius: 10px;
  font-size: 11px;
  color: var(--text-secondary);
}

/* Main Panel */
.main-panel {
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.panel-title {
  font-size: 16px;
  font-weight: 600;
}

.diagram-action-btn {
  padding: 6px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  font-size: 12px;
  line-height: 1;
}
.diagram-action-btn:hover {
  background: var(--bg-tertiary);
}

.diagram-action-btn.icon {
  width: 34px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.diagram-action-btn.icon.subtle {
  background: #666;
  border-color: #666;
  color: #fff;
}
.diagram-action-btn.icon.subtle:hover {
  filter: brightness(1.05);
}
.diagram-action-btn.icon.primary {
  background: #3b82f6;
  border-color: #3b82f6;
  color: #fff;
}
.diagram-action-btn.icon.primary:hover {
  filter: brightness(1.05);
}
.diagram-action-btn.is-ok {
  background: #22c55e;
  border-color: #22c55e;
  color: white;
}
.diagram-action-btn.is-fail {
  background: #ef4444;
  border-color: #ef4444;
  color: white;
}

/* View Toggle */
.view-toggle {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  padding: 4px;
  border-radius: 6px;
}

.view-btn {
  padding: 6px 12px;
  border: none;
  background: none;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 4px;
  font-size: 13px;
}

.view-btn.active {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* Routes Table */
.routes-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.routes-table th,
.routes-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  overflow: hidden;
  text-overflow: ellipsis;
}

.routes-table th:nth-child(1),
.routes-table td:nth-child(1) {
  width: 120px;
}
.routes-table th:nth-child(2),
.routes-table td:nth-child(2) {
  width: 45%;
}
.routes-table th:nth-child(3),
.routes-table td:nth-child(3) {
  width: auto;
}

.routes-table th {
  background: var(--bg-secondary);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  position: sticky;
  top: 0;
}

.routes-table tr {
  cursor: pointer;
}
.routes-table tr:hover {
  background: var(--bg-secondary);
}

/* Method Badges */
.method-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
}

.method-GET {
  background: #238636;
  color: white;
}
.method-POST {
  background: #1f6feb;
  color: white;
}
.method-PUT,
.method-PATCH {
  background: #9e6a03;
  color: white;
}
.method-DELETE {
  background: #da3633;
  color: white;
}
.method-ALL {
  background: #6e7681;
  color: white;
}

/* Path Text */
.path-text {
  font-family: 'SF Mono', Monaco, monospace;
  font-size: 13px;
}
.param {
  color: var(--accent-orange);
}
.controller-text {
  color: var(--text-secondary);
  font-size: 13px;
}

/* Detail Panel */
.detail-panel {
  background: var(--bg-secondary);
  border-left: 1px solid var(--border-color);
  overflow-y: auto;
}

.detail-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.detail-title {
  font-size: 14px;
  font-weight: 600;
}

.close-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-size: 18px;
}

.detail-content {
  padding: 16px;
}

.detail-section {
  margin-bottom: 20px;
}

.detail-section-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.detail-item {
  background: var(--bg-tertiary);
  padding: 8px 12px;
  border-radius: 4px;
  margin-bottom: 6px;
  font-size: 13px;
  display: flex;
  align-items: flex-start;
  gap: 8px;
  word-break: break-word;
}

.detail-item .tag {
  flex-shrink: 0;
}

/* Tags */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
  margin-right: 6px;
}

.tag-blue {
  background: rgba(88, 166, 255, 0.2);
  color: var(--accent-blue);
}
.tag-green {
  background: rgba(63, 185, 80, 0.2);
  color: var(--accent-green);
}
.tag-purple {
  background: rgba(163, 113, 247, 0.2);
  color: var(--accent-purple);
}
.tag-orange {
  background: rgba(210, 153, 34, 0.2);
  color: var(--accent-orange);
}
.tag-pink {
  background: rgba(219, 97, 162, 0.2);
  color: var(--accent-pink);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
}

/* Model Card */
.model-card-grid {
  display: grid;
  gap: 12px;
}

.model-card-grid .model-card {
  margin-bottom: 0;
}

.model-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  cursor: pointer;
  transition: border-color 0.2s;
}

.model-card:hover {
  border-color: var(--accent-blue);
}

.model-name {
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.model-stats {
  display: flex;
  gap: 16px;
  font-size: 12px;
  color: var(--text-secondary);
}

/* Controller Card */
.controller-card {
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
}

.controller-header {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.controller-card:not(.expanded) .controller-header {
  border-bottom: none;
}

.controller-header:hover {
  background: var(--bg-tertiary);
}
.controller-name {
  font-weight: 600;
  font-size: 14px;
}
.controller-namespace {
  color: var(--text-secondary);
  font-size: 12px;
}

.controller-actions {
  padding: 8px;
  display: none;
}
.controller-card.expanded .controller-actions {
  display: block;
}

.action-item {
  padding: 6px 12px;
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.action-visibility {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.visibility-public {
  background: var(--accent-green);
}
.visibility-private {
  background: var(--accent-red);
}
.visibility-protected {
  background: var(--accent-orange);
}

/* Mermaid Container */
.mermaid-container {
  background: var(--bg-secondary);
  border-radius: 8px;
  padding: 20px;
  overflow: hidden;
  position: relative;
  min-height: 300px;
  cursor: grab;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mermaid-container:active {
  cursor: grabbing;
}

.diagram-controls button {
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 4px;
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.diagram-controls button:hover {
  background: var(--accent);
}

/* Fullscreen mode */
.mermaid-container:fullscreen {
  background: var(--bg-primary);
  padding: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mermaid-container:fullscreen svg {
  max-width: none;
  max-height: none;
  cursor: pointer;
}

.mermaid-container:fullscreen .diagram-controls {
  position: fixed;
  top: 16px;
  right: 16px;
}

/* Detail panel in fullscreen - overlay style */
.mermaid-container:fullscreen ~ .detail-panel,
body:has(.mermaid-container:fullscreen) .detail-panel.open {
  position: fixed;
  right: 0;
  top: 0;
  height: 100vh;
  z-index: 10001;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.5);
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--bg-primary);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}
