/* Goldfish Project Page Styles
 * Dieter Rams inspired design - less but better
 */

:root {
    --goldfish-orange: #FF6B35;
    --goldfish-orange-light: #FF8C5A;
    --goldfish-orange-dark: #E85A24;
    --bg-primary: #FAFAFA;
    --bg-secondary: #FFFFFF;
    --text-primary: #1A1A1A;
    --text-secondary: #6B6B6B;
    --border-color: #E0E0E0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 2px 8px rgba(0, 0, 0, 0.12);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

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

/* Header */
header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 32px;
    height: 32px;
    background: var(--goldfish-orange);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 1.2rem;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 400;
    color: var(--text-primary);
}

.logo-accent { color: var(--goldfish-orange); font-weight: 500; }

.breadcrumb {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-top: 0.25rem;
}

.breadcrumb a {
    color: var(--goldfish-orange);
    text-decoration: none;
}

.breadcrumb a:hover { text-decoration: underline; }

nav[aria-label="Main navigation"] {
    display: flex;
    gap: 1.5rem;
}

nav button {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem 1rem;
    border-radius: 4px;
    transition: all 0.2s;
    font-size: 0.95rem;
}

nav button:hover {
    color: var(--text-primary);
    background: var(--bg-primary);
}

nav button.active {
    color: var(--goldfish-orange);
    font-weight: 500;
}

/* Main content */
main {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 2rem;
}

.view-title {
    margin-bottom: 1.5rem;
    font-weight: 400;
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow);
    transition: box-shadow 0.2s;
}

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

.card-title {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 1rem;
    color: var(--text-primary);
}

/* Grid layouts */
.workspace-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.workspace-card {
    background: var(--bg-secondary);
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    transition: all 0.2s;
    cursor: pointer;
    border: 2px solid transparent;
}

.workspace-card:hover,
.workspace-card:focus {
    box-shadow: var(--shadow-hover);
    border-color: var(--goldfish-orange);
    transform: translateY(-2px);
    outline: none;
}

.workspace-card:focus-visible {
    outline: 2px solid var(--goldfish-orange);
    outline-offset: 2px;
}

/* Skip link for keyboard navigation */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: var(--goldfish-orange);
    color: white;
    padding: 8px 16px;
    z-index: 1000;
    text-decoration: none;
}

.skip-link:focus {
    top: 0;
}

.workspace-card h3 {
    font-size: 1.2rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.workspace-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
}

.workspace-meta {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Status badges */
.status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-completed { background: #E8F5E9; color: #2E7D32; }
.status-running { background: #FFF3E0; color: #E65100; }
.status-pending { background: #E3F2FD; color: #1565C0; }
.status-failed { background: #FFEBEE; color: #C62828; }
.status-active { background: #FFE8DC; color: var(--goldfish-orange-dark); }
.status-mounted { background: #E8F5E9; color: #2E7D32; }
.status-hibernating { background: #E3F2FD; color: #1565C0; }

/* Graph container */
#graph-container {
    background: var(--bg-secondary);
    border-radius: 8px;
    min-height: 600px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
    overflow: hidden;
}

#graph { width: 100%; height: 600px; }

/* Loading state */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.spinner {
    border: 3px solid var(--border-color);
    border-top: 3px solid var(--goldfish-orange);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin-right: 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0;
    border-bottom: 2px solid var(--border-color);
    margin-bottom: 2rem;
}

.tab {
    padding: 1rem 1.5rem;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab:hover { color: var(--text-primary); }

.tab.active {
    color: var(--goldfish-orange);
    border-bottom-color: var(--goldfish-orange);
    font-weight: 500;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.modal.active { display: flex; }

.modal-content {
    background: var(--bg-secondary);
    border-radius: 8px;
    max-width: 800px;
    width: 100%;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    position: relative;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 1;
}

.modal-title {
    font-size: 1.3rem;
    font-weight: 500;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    line-height: 1;
    border-radius: 4px;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
}

.modal-body {
    padding: 1.5rem;
}

.detail-section {
    margin-bottom: 2rem;
}

.detail-section:last-child { margin-bottom: 0; }

.detail-section-title {
    font-size: 1.1rem;
    font-weight: 500;
    color: var(--goldfish-orange);
    margin-bottom: 1rem;
}

.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.detail-item {
    padding: 0.75rem;
    background: var(--bg-primary);
    border-radius: 4px;
}

.detail-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.detail-value {
    font-size: 1rem;
    color: var(--text-primary);
    font-weight: 500;
}

.detail-list {
    list-style: none;
}

.detail-list li {
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.detail-list li:last-child { border-bottom: none; }

/* Graph */
#graph-svg {
    width: 100%;
    height: 600px;
    background: var(--bg-secondary);
    border-radius: 8px;
    box-shadow: var(--shadow);
}

.graph-node {
    cursor: pointer;
    transition: all 0.2s;
}

.graph-node:hover {
    stroke: var(--goldfish-orange);
    stroke-width: 3px;
}

.graph-node-completed { fill: #4CAF50; }
.graph-node-running { fill: var(--goldfish-orange); }
.graph-node-failed { fill: #F44336; }
.graph-node-pending { fill: var(--text-secondary); }

.graph-link {
    stroke: var(--border-color);
    stroke-opacity: 0.6;
    stroke-width: 2px;
}

.graph-link-hover {
    stroke: var(--goldfish-orange);
    stroke-opacity: 1;
    stroke-width: 3px;
}

.graph-label {
    font-size: 10px;
    fill: var(--text-primary);
    pointer-events: none;
}

.graph-controls {
    margin-bottom: 1rem;
    display: flex;
    gap: 0.5rem;
}

.graph-control-btn {
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.graph-control-btn:hover {
    border-color: var(--goldfish-orange);
    color: var(--goldfish-orange);
}

/* Timeline */
.timeline {
    position: relative;
    padding-left: 2rem;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 2px;
    background: var(--border-color);
}

.timeline-item {
    position: relative;
    padding-bottom: 2rem;
}

.timeline-item::before {
    content: '';
    position: absolute;
    left: -2.5rem;
    top: 0.5rem;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--goldfish-orange);
    border: 3px solid var(--bg-primary);
}

.timeline-content {
    background: var(--bg-secondary);
    padding: 1rem;
    border-radius: 6px;
    box-shadow: var(--shadow);
}

.timeline-time {
    color: var(--text-secondary);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

/* Search/Filter */
.search-box {
    margin-bottom: 1.5rem;
    position: relative;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    font-size: 1rem;
    background: var(--bg-secondary);
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--goldfish-orange);
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.1);
}

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

.filter-tags {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.filter-tag {
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.filter-tag:hover {
    border-color: var(--goldfish-orange-light);
}

.filter-tag.active {
    background: var(--goldfish-orange);
    color: white;
    border-color: var(--goldfish-orange);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-secondary);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.hidden { display: none !important; }

/* View transitions with fade */
.view-loading {
    opacity: 0.5;
    pointer-events: none;
}

.view-content {
    transition: opacity 0.2s ease-in-out;
}

/* Mobile responsive styles */
@media (max-width: 768px) {
    header .header-content {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }

    header nav[aria-label="Main navigation"] {
        flex-wrap: wrap;
        justify-content: center;
    }

    main {
        padding: 0 1rem;
        margin: 1rem auto;
    }

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

    .filter-tags {
        overflow-x: auto;
        white-space: nowrap;
        padding-bottom: 0.5rem;
    }

    .tabs {
        flex-wrap: wrap;
    }

    .tab {
        flex: 1;
        text-align: center;
    }

    .graph-controls {
        flex-wrap: wrap;
    }

    #graph-svg {
        height: 400px;
    }

    .modal-content {
        margin: 1rem;
        max-height: 90vh;
    }

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

    .search-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

@media (max-width: 480px) {
    header {
        padding: 0.75rem 1rem;
    }

    .logo h1 {
        font-size: 1.2rem;
    }

    nav button {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
    }

    .workspace-card {
        padding: 1rem;
    }

    .workspace-card h3 {
        font-size: 1rem;
    }

    .timeline-content {
        padding: 0.75rem;
    }
}

/* ============================================
   Graph View Toggle and Cards
   ============================================ */

.graph-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.graph-header .view-title {
    margin: 0;
}

.graph-view-toggle {
    display: flex;
    gap: 0;
    border: 2px solid var(--border-color);
    border-radius: 6px;
    overflow: hidden;
}

.toggle-btn {
    padding: 0.5rem 1rem;
    border: none;
    background: var(--bg-secondary);
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.toggle-btn:hover {
    background: var(--bg-tertiary);
}

.toggle-btn.active {
    background: var(--goldfish-orange);
    color: white;
}

/* Cards Grid */
#graph-container-cards {
    padding: 1rem 0;
}

#cards-grid {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.lineage-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem 1.25rem;
    transition: all 0.2s;
    cursor: pointer;
    position: relative;
}

.lineage-card:hover {
    border-color: var(--goldfish-orange);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.15);
}

.lineage-card.child {
    margin-left: 2rem;
    border-left: 3px solid var(--goldfish-orange);
}

.lineage-card.child::before {
    content: '';
    position: absolute;
    left: -2rem;
    top: 50%;
    width: 2rem;
    height: 2px;
    background: var(--goldfish-orange);
    opacity: 0.5;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

.card-badge {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: var(--goldfish-orange);
    color: white;
}

.card-stats {
    display: flex;
    gap: 1.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.card-stat {
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.card-stat-value {
    color: var(--text-primary);
    font-weight: 500;
}

.card-parent {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.5rem;
}

.card-parent a {
    color: var(--goldfish-orange);
    text-decoration: none;
}

.card-parent a:hover {
    text-decoration: underline;
}

/* Version Detail Panel */
#version-detail-panel {
    position: fixed;
    right: 0;
    top: 0;
    width: 400px;
    height: 100vh;
    background: var(--bg-primary);
    border-left: 2px solid var(--border-color);
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.2);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

#version-detail-panel.visible {
    transform: translateX(0);
}

.detail-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 2px solid var(--border-color);
    background: var(--bg-secondary);
}

.detail-panel-header h3 {
    margin: 0;
    font-size: 1.1rem;
}

.detail-panel-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 0;
    line-height: 1;
}

.detail-panel-close:hover {
    color: var(--goldfish-orange);
}

#detail-panel-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.version-item {
    display: flex;
    align-items: flex-start;
    padding: 0.75rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
    background: var(--bg-secondary);
    gap: 0.75rem;
}

.version-item:hover {
    background: var(--bg-tertiary);
}

.version-node {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--goldfish-orange);
    flex-shrink: 0;
    margin-top: 4px;
}

.version-info {
    flex: 1;
    min-width: 0;
}

.version-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.25rem;
}

.version-name {
    font-weight: 600;
    color: var(--text-primary);
}

.version-sha {
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.version-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.version-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Collapsed versions indicator in timeline */
.versions-collapsed {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    background: var(--bg-tertiary);
    border-radius: 12px;
    font-size: 0.8rem;
    color: var(--text-secondary);
    cursor: pointer;
    margin: 0 0.5rem;
    transition: all 0.2s;
}

.versions-collapsed:hover {
    background: var(--goldfish-orange);
    color: white;
}

/* Timeline graph container */
#graph-container-timeline {
    width: 100%;
    height: 500px;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
}

/* ============================================
   Stage Versions View
   ============================================ */

#stages-container-timeline {
    width: 100%;
    height: 600px;
    background: var(--bg-secondary);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: var(--shadow);
}

#stages-svg {
    width: 100%;
    height: 100%;
}

#stages-container-cards {
    padding: 1rem 0;
}

#stages-cards-grid {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Workspace card in stages view */
.stages-workspace-card {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 0;
    overflow: hidden;
    border-left-width: 4px;
}

.stages-workspace-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-primary);
}

.stages-workspace-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
}

.stages-workspace-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.stages-workspace-stats span {
    padding: 0.2rem 0.5rem;
    background: var(--bg-secondary);
    border-radius: 4px;
}

.stages-list {
    padding: 0.75rem;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.75rem;
}

/* Individual stage card */
.stage-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 1rem;
    transition: all 0.2s;
}

.stage-card:hover {
    border-color: var(--goldfish-orange-light);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.stage-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.stage-name {
    font-weight: 600;
    font-size: 1rem;
    color: var(--text-primary);
}

.stage-card-stats {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
}

.stage-stat {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.stage-stat-label {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stage-stat-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

/* Version dots row */
.stage-versions-row {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border-color);
}

.stage-version-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #757575;
    cursor: help;
    transition: transform 0.2s;
}

.stage-version-dot:hover {
    transform: scale(1.3);
}

.stage-version-dot.status-completed {
    background: #4CAF50;
}

.stage-version-dot.status-running {
    background: #2196F3;
}

.stage-version-dot.status-failed {
    background: #f44336;
}

.stage-version-dot.status-canceled {
    background: #9e9e9e;
}

.stage-version-more {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: 0.25rem;
}

/* Mobile responsive for stages */
@media (max-width: 768px) {
    #stages-container-timeline {
        height: 400px;
    }

    .stages-workspace-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }

    .stages-list {
        grid-template-columns: 1fr;
    }

    .stage-card-stats {
        flex-wrap: wrap;
    }
}

/* Version Tags and Pruning */
.pruned-badge {
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.8;
}

.version-item.tagged {
    background: rgba(255, 215, 0, 0.05);
}

.version-tag {
    font-size: 0.85rem;
}

.pruned-notice {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
