/**
 * Cozy-Dock Stylesheet - Extends gaskb_style tokens and components
 */

:root {
  --dock-bg: #0d1117;
  --dock-card-bg: #161b22;
  --dock-card-border: #30363d;
  --dock-card-hover-border: #8b949e;
  --dock-running: #2ea043;
  --dock-stopped: #8b949e;
  --dock-restarting: #d29922;
  --dock-pinned: #f0883e;
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--dock-bg);
  color: #c9d1d9;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  min-height: 100vh;
}

.dock-container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 1.5rem 1rem;
}

/* Header */
.dock-header {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--dock-card-border);
  margin-bottom: 1.5rem;
}

.dock-title-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.dock-title {
  font-size: 1.6rem;
  font-weight: 700;
  color: #f0f6fc;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dock-subtitle {
  font-size: 0.85rem;
  color: #8b949e;
  margin: 0.2rem 0 0 0;
}

/* Badges */
.badge-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.badge-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.55rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.2;
}

.badge-version-ui {
  background: rgba(30, 64, 175, 0.3);
  color: #93c5fd;
  border: 1px solid #1d4ed8;
}

.badge-version-api {
  background: rgba(6, 95, 70, 0.3);
  color: #6ee7b7;
  border: 1px solid #059669;
}

.badge-socket-ok {
  background: rgba(46, 160, 67, 0.2);
  color: #3fb950;
  border: 1px solid #2ea043;
}

.badge-socket-err {
  background: rgba(248, 81, 73, 0.2);
  color: #f85149;
  border: 1px solid #da3633;
}

/* Stats Summary */
.dock-stats-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.stat-chip {
  background: var(--dock-card-bg);
  border: 1px solid var(--dock-card-border);
  border-radius: 8px;
  padding: 0.5rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-size: 0.85rem;
}

.stat-value {
  font-weight: 700;
  font-size: 1.05rem;
  color: #f0f6fc;
}

/* Search and Filters */
.controls-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.search-wrapper {
  position: relative;
  flex: 1;
  min-width: 260px;
}

.search-input {
  width: 100%;
  background: var(--dock-card-bg);
  border: 1px solid var(--dock-card-border);
  color: #f0f6fc;
  border-radius: 8px;
  padding: 0.6rem 0.85rem 0.6rem 2.25rem;
  font-size: 0.9rem;
  box-sizing: border-box;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-input:focus {
  outline: none;
  border-color: #58a6ff;
  box-shadow: 0 0 0 3px rgba(88, 166, 255, 0.2);
}

.search-icon {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  color: #8b949e;
  pointer-events: none;
}

.filters-group {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.filter-btn {
  background: var(--dock-card-bg);
  border: 1px solid var(--dock-card-border);
  color: #c9d1d9;
  padding: 0.45rem 0.8rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn:hover {
  border-color: #8b949e;
  color: #f0f6fc;
}

.filter-btn.active {
  background: #21262d;
  border-color: #58a6ff;
  color: #58a6ff;
  font-weight: 600;
}

/* Container Cards Grid */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(370px, 1fr));
  gap: 1.25rem;
}

.container-card {
  background: var(--dock-card-bg);
  border: 1px solid var(--dock-card-border);
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  transition: border-color 0.2s, box-shadow 0.2s;
  overflow: hidden;
}

.container-card:hover {
  border-color: var(--dock-card-hover-border);
}

.container-card.is-pinned {
  border-left: 4px solid var(--dock-pinned);
}

.card-header {
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid rgba(48, 54, 61, 0.5);
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.5rem;
}

.card-title-area {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  overflow: hidden;
}

.container-name-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.container-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: #f0f6fc;
  margin: 0;
  word-break: break-all;
}

.lock-icon {
  color: var(--dock-pinned);
  font-size: 0.95rem;
  flex-shrink: 0;
}

.compose-badge {
  font-size: 0.72rem;
  background: #21262d;
  color: #8b949e;
  border: 1px solid #30363d;
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  max-width: fit-content;
}

.status-indicator {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  padding: 0.25rem 0.5rem;
  border-radius: 9999px;
  flex-shrink: 0;
}

.status-indicator.running {
  background: rgba(46, 160, 67, 0.15);
  color: #3fb950;
  border: 1px solid rgba(46, 160, 67, 0.4);
}

.status-indicator.stopped {
  background: rgba(139, 148, 158, 0.15);
  color: #8b949e;
  border: 1px solid rgba(139, 148, 158, 0.3);
}

.status-indicator.restarting {
  background: rgba(210, 153, 34, 0.15);
  color: #d29922;
  border: 1px solid rgba(210, 153, 34, 0.4);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}

.status-dot.running {
  background: #3fb950;
  box-shadow: 0 0 6px #3fb950;
}

.status-dot.stopped {
  background: #8b949e;
}

.status-dot.restarting {
  background: #d29922;
}

/* Card Body */
.card-body {
  padding: 0.85rem 1rem;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.meta-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  color: #8b949e;
  word-break: break-all;
}

.ports-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
}

.port-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: #1f2937;
  border: 1px solid #374151;
  color: #60a5fa;
  padding: 0.15rem 0.45rem;
  border-radius: 4px;
  font-size: 0.78rem;
  font-family: ui-monospace, SFMono-Regular, monospace;
  text-decoration: none;
  transition: all 0.15s;
}

.port-pill:hover {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
  text-decoration: none;
}

/* Notes Textarea */
.notes-container {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  margin-top: 0.25rem;
}

.notes-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.75rem;
  color: #8b949e;
}

.save-indicator {
  font-size: 0.72rem;
  color: #3fb950;
  transition: opacity 0.3s;
}

.notes-textarea {
  width: 100%;
  background: #0d1117;
  border: 1px solid #30363d;
  color: #c9d1d9;
  border-radius: 6px;
  padding: 0.5rem;
  font-size: 0.82rem;
  font-family: inherit;
  line-height: 1.4;
  resize: vertical;
  min-height: 52px;
  box-sizing: border-box;
  transition: border-color 0.15s;
}

.notes-textarea:focus {
  outline: none;
  border-color: #58a6ff;
}

.notes-textarea::placeholder {
  color: #484f58;
}

/* Tags */
.tags-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
}

.tag-badge {
  background: #21262d;
  border: 1px solid #30363d;
  color: #58a6ff;
  padding: 0.12rem 0.45rem;
  border-radius: 12px;
  font-size: 0.72rem;
  cursor: pointer;
}

.tag-badge:hover {
  background: #30363d;
}

/* Card Actions */
.card-actions {
  padding: 0.65rem 1rem;
  background: rgba(13, 17, 23, 0.4);
  border-top: 1px solid var(--dock-card-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
}

.action-btn-group {
  display: flex;
  gap: 0.35rem;
}

.btn-action {
  padding: 0.4rem 0.65rem;
  border-radius: 6px;
  border: 1px solid var(--dock-card-border);
  background: #21262d;
  color: #c9d1d9;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s;
  min-height: 32px;
}

.btn-action:hover:not(:disabled) {
  border-color: #8b949e;
  color: #f0f6fc;
}

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

.btn-start {
  color: #3fb950;
}
.btn-start:hover:not(:disabled) {
  background: rgba(46, 160, 67, 0.15);
  border-color: #2ea043;
}

.btn-stop {
  color: #f85149;
}
.btn-stop:hover:not(:disabled) {
  background: rgba(248, 81, 73, 0.15);
  border-color: #da3633;
}

.btn-restart {
  color: #d29922;
}
.btn-restart:hover:not(:disabled) {
  background: rgba(210, 153, 34, 0.15);
  border-color: #d29922;
}

.btn-pin {
  color: #8b949e;
}
.btn-pin.pinned {
  color: var(--dock-pinned);
  border-color: rgba(240, 136, 62, 0.4);
  background: rgba(240, 136, 62, 0.1);
}

/* View Switcher */
.view-switch-group {
  display: flex;
  background: #161b22;
  border: 1px solid var(--dock-card-border);
  border-radius: 6px;
  overflow: hidden;
}

.view-switch-btn {
  background: transparent;
  border: none;
  color: #8b949e;
  padding: 0.45rem 0.75rem;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  transition: all 0.15s;
}

.view-switch-btn:hover {
  color: #f0f6fc;
}

.view-switch-btn.active {
  background: #21262d;
  color: #58a6ff;
  font-weight: 600;
}

/* Sort Selector */
.sort-select-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: var(--dock-card-bg);
  border: 1px solid var(--dock-card-border);
  padding: 0.15rem 0.6rem;
  border-radius: 6px;
}

.sort-label {
  font-size: 0.8rem;
  color: #8b949e;
  font-weight: 500;
  user-select: none;
}

.sort-select {
  background: transparent;
  color: #f0f6fc;
  border: none;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  outline: none;
  padding: 0.25rem 0.2rem;
}

.sort-select option {
  background: #161b22;
  color: #f0f6fc;
}

/* List View (Single service per row) */
.list-container {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  width: 100%;
}

.list-row {
  background: var(--dock-card-bg);
  border: 1px solid var(--dock-card-border);
  border-radius: 8px;
  padding: 0.85rem 1.15rem;
  display: grid;
  grid-template-columns: 140px 240px 180px 140px 1fr 170px;
  align-items: center;
  gap: 1rem;
  transition: border-color 0.15s, background-color 0.15s;
}

.list-row:hover {
  border-color: var(--dock-card-hover-border);
  background-color: #1c2128;
}

.list-row.is-pinned {
  border-left: 4px solid var(--dock-pinned);
}

.list-col-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.list-col-name {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  overflow: hidden;
}

.list-name-row {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.list-name-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: #f0f6fc;
  margin: 0;
  text-overflow: ellipsis;
  overflow: hidden;
  white-space: nowrap;
}

.list-col-stats {
  font-size: 0.8rem;
  color: #8b949e;
}

.list-col-ports {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.list-col-notes {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 0;
}

.list-notes-input {
  width: 100%;
  background: #0d1117;
  border: 1px solid #30363d;
  color: #c9d1d9;
  border-radius: 4px;
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  font-family: inherit;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.list-notes-input:focus {
  outline: none;
  border-color: #58a6ff;
}

.list-col-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.35rem;
}

.url-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: #58a6ff;
  text-decoration: none;
  max-width: fit-content;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.url-badge:hover {
  text-decoration: underline;
}

@media (max-width: 1100px) {
  .list-row {
    grid-template-columns: 1fr;
    gap: 0.6rem;
  }
  .list-col-actions {
    justify-content: flex-start;
  }
}

/* Modal */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}

.modal-dialog {
  background: var(--dock-card-bg);
  border: 1px solid var(--dock-card-border);
  border-radius: 12px;
  width: 100%;
  max-width: 460px;
  padding: 1.5rem;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.modal-title {
  color: #f0f6fc;
  font-size: 1.2rem;
  margin-top: 0;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.modal-body {
  color: #8b949e;
  font-size: 0.9rem;
  line-height: 1.5;
  margin-bottom: 1.25rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.6rem;
}

.btn-danger {
  background: #da3633;
  color: #ffffff;
  border: 1px solid #f85149;
}
.btn-danger:hover {
  background: #b62324;
}

/* Toast */
.toast-container {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  z-index: 10000;
}

.toast {
  background: #21262d;
  color: #f0f6fc;
  border: 1px solid #30363d;
  padding: 0.75rem 1rem;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  animation: slideIn 0.2s ease-out;
}

.toast.error {
  border-color: #da3633;
  color: #ff7b72;
}

@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@media (max-width: 768px) {
  .cards-grid {
    grid-template-columns: 1fr;
  }
  .controls-bar {
    flex-direction: column;
    align-items: stretch;
  }
}
