/* CSS Variables */
:root {
    --bg-dark: #0a0a0f;
    --card-bg: #1a1a2e;
    --card-border: #2a2a4e;
    --accent-cyan: #00d4ff;
    --status-green: #00ff88;
    --status-yellow: #ffcc00;
    --status-red: #ff4444;
    --text-primary: #ffffff;
    --text-secondary: #8888aa;
    --font-mono: 'Courier New', Courier, monospace;
    --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
}

/* Dashboard Layout */
.dashboard {
    max-width: 480px;
    margin: 0 auto;
    padding: 15px;
}

.header {
    text-align: center;
    padding: 15px 0 20px;
    border-bottom: 1px solid var(--card-border);
    margin-bottom: 8px;
}

.header h1 {
    font-family: var(--font-mono);
    font-size: 1.5rem;
    letter-spacing: 3px;
    color: var(--accent-cyan);
    text-shadow: 0 0 20px rgba(0, 212, 255, 0.3);
}

.repo-links {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 12px;
}

.repo-link {
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-decoration: none;
    padding: 4px 10px;
    border: 1px solid var(--card-border);
    border-radius: 4px;
    transition: all 0.2s ease;
}

.repo-link:hover {
    color: var(--accent-cyan);
    border-color: var(--accent-cyan);
}

.github-icon {
    flex-shrink: 0;
}

/* Cards */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 8px;
}

.card:last-child,
.info-card {
    margin-bottom: 0;
}

.card h2 {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.card-header-with-branch {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.card-header-with-branch h2 {
    margin-bottom: 0;
}

.branch-badge {
    display: flex;
    align-items: center;
    gap: 5px;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--accent-cyan);
    background-color: rgba(0, 212, 255, 0.1);
    padding: 3px 8px;
    border-radius: 4px;
    border: 1px solid rgba(0, 212, 255, 0.3);
}

.branch-icon {
    flex-shrink: 0;
}

/* Top Row - Health & Version */
.top-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 8px;
}

.top-row .card {
    margin-bottom: 0;
}

/* Gauge */
.gauge-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 5px 0;
}

.gauge {
    width: 140px;
    height: 85px;
}

.gauge-bg {
    fill: none;
    stroke: var(--card-border);
    stroke-width: 8;
    stroke-linecap: round;
}

.gauge-fill {
    fill: none;
    stroke: var(--text-secondary);
    stroke-width: 8;
    stroke-linecap: round;
    stroke-dasharray: 126;
    stroke-dashoffset: 126;
    transition: stroke-dashoffset 0.5s ease, stroke 0.3s ease;
}

.gauge-fill.healthy {
    stroke: var(--status-green);
    stroke-dashoffset: 0;
}

.gauge-fill.building {
    stroke: var(--status-yellow);
    stroke-dashoffset: 42;
    animation: pulse 1.5s ease-in-out infinite;
}

.gauge-fill.failed {
    stroke: var(--status-red);
    stroke-dashoffset: 84;
}

.gauge-fill.unknown {
    stroke: var(--text-secondary);
    stroke-dashoffset: 100;
}

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

.gauge-label {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    margin-top: 5px;
    letter-spacing: 2px;
}

.gauge-label.healthy { color: var(--status-green); }
.gauge-label.building { color: var(--status-yellow); }
.gauge-label.failed { color: var(--status-red); }
.gauge-label.unknown { color: var(--text-secondary); }

/* Version Display */
.version-display {
    font-family: var(--font-mono);
    font-size: 2rem;
    text-align: center;
    color: var(--accent-cyan);
    padding: 10px 0;
}

.version-details {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    text-align: center;
    color: var(--text-secondary);
}

/* Pipeline Stages - Left sidebar panel */
.stages-card {
    padding: 0;
    overflow: hidden;
    position: fixed;
    right: calc(50% + 248px);
    top: 125px;
    width: 320px;
    bottom: 15px;
    z-index: 100;
}

.stages-card .card-header-with-branch {
    padding: 12px 15px;
    margin-bottom: 0;
}

.stages-card .card-header-with-branch h2 {
    padding: 0;
}

.stages-container {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    padding: 10px 15px;
    overflow-y: auto;
    height: calc(100% - 45px);
}

.stage {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stage-box {
    background-color: var(--bg-dark);
    border: 2px solid var(--card-border);
    border-radius: 6px;
    padding: 10px 8px;
    text-align: center;
    width: 260px;
    height: 60px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

@media (max-width: 1100px) {
    .stage-box {
        width: 80px;
        height: 75px;
    }
}

.stage-box.success {
    border-color: var(--status-green);
    box-shadow: 0 0 10px rgba(0, 255, 136, 0.2);
}

.stage-box.running {
    border-color: var(--status-yellow);
    box-shadow: 0 0 10px rgba(255, 204, 0, 0.2);
    animation: stage-pulse 1.5s ease-in-out infinite;
}

.stage-box.failed {
    border-color: var(--status-red);
    box-shadow: 0 0 10px rgba(255, 68, 68, 0.2);
}

.stage-box.pending {
    border-color: var(--card-border);
    opacity: 0.6;
}

@keyframes stage-pulse {
    0%, 100% { box-shadow: 0 0 10px rgba(255, 204, 0, 0.2); }
    50% { box-shadow: 0 0 20px rgba(255, 204, 0, 0.4); }
}

.stage-name {
    font-family: var(--font-mono);
    font-size: 0.65rem;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.2;
}

.stage-icon {
    font-size: 1.1rem;
    margin-bottom: 3px;
}

.stage-duration {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.stage-arrow {
    font-size: 1.2rem;
    color: var(--accent-cyan);
    margin: 6px 0;
    transform: rotate(90deg);
    text-shadow: 0 0 8px rgba(0, 212, 255, 0.5);
}

.stage-placeholder {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    color: var(--text-secondary);
    padding: 30px;
}

/* System Signals */
.signals-container {
    display: flex;
    justify-content: space-around;
    gap: 10px;
    flex-wrap: wrap;
    padding: 10px 0;
}

.signal {
    display: flex;
    align-items: center;
    gap: 10px;
}

.signal-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--text-secondary);
    transition: background-color 0.3s ease, box-shadow 0.3s ease;
    flex-shrink: 0;
}

.signal.healthy .signal-dot {
    background-color: var(--status-green);
    box-shadow: 0 0 10px var(--status-green);
}

.signal.unhealthy .signal-dot {
    background-color: var(--status-red);
    box-shadow: 0 0 10px var(--status-red);
}

.signal-name {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-primary);
}

.signal-status {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    background-color: var(--bg-dark);
}

.signal.healthy .signal-status {
    color: var(--status-green);
}

.signal.unhealthy .signal-status {
    color: var(--status-red);
}

/* Trigger Button */
.trigger-card {
    text-align: center;
    padding: 15px;
}

.trigger-btn {
    font-family: var(--font-mono);
    font-size: 1rem;
    letter-spacing: 1px;
    padding: 14px 25px;
    background: transparent;
    border: 2px solid var(--accent-cyan);
    color: var(--accent-cyan);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
}

.trigger-btn:hover {
    background-color: var(--accent-cyan);
    color: var(--bg-dark);
    box-shadow: 0 0 20px rgba(0, 212, 255, 0.4);
}

.trigger-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.trigger-btn:disabled:hover {
    background: transparent;
    color: var(--accent-cyan);
    box-shadow: none;
}

.trigger-status {
    font-family: var(--font-mono);
    font-size: 0.9rem;
    margin-top: 15px;
    min-height: 20px;
}

.trigger-status.success {
    color: var(--status-green);
}

.trigger-status.error {
    color: var(--status-red);
}

.trigger-status.waiting {
    color: var(--status-yellow);
    animation: flash 1s ease-in-out infinite;
}

@keyframes flash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* Pending Deployment */
.deployment-card {
    padding: 12px 15px;
    border: 2px solid var(--status-yellow);
    animation: pulse-border 2s ease-in-out infinite;
}

@keyframes pulse-border {
    0%, 100% { border-color: var(--status-yellow); }
    50% { border-color: var(--card-border); }
}

.deployment-card h2 {
    color: var(--status-yellow);
}

.deployment-container {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.deployment-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--card-border);
}

.deployment-version {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
}

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

.deployment-actions {
    display: flex;
    gap: 10px;
}

.deployment-btn {
    flex: 1;
    padding: 12px 20px;
    font-family: var(--font-mono);
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.deployment-btn.approve {
    background: var(--status-green);
    color: var(--bg-primary);
}

.deployment-btn.approve:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.deployment-btn.reject {
    background: transparent;
    color: var(--status-red);
    border: 2px solid var(--status-red);
}

.deployment-btn.reject:hover {
    background: var(--status-red);
    color: var(--bg-primary);
}

.deployment-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Build History */
.history-card {
    padding: 12px 15px;
}

.history-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.history-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 6px 10px;
    background-color: var(--bg-dark);
    border-radius: 4px;
    font-family: var(--font-mono);
    font-size: 0.75rem;
}

.history-item-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.history-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.history-status.success {
    background-color: var(--status-green);
    box-shadow: 0 0 6px var(--status-green);
}

.history-status.failed {
    background-color: var(--status-red);
    box-shadow: 0 0 6px var(--status-red);
}

.history-number {
    color: var(--text-primary);
}

.history-item-right {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
}

.history-duration {
    min-width: 45px;
    text-align: right;
}

.history-time {
    min-width: 60px;
    text-align: right;
}

.history-placeholder {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-secondary);
    text-align: center;
    padding: 10px;
}

/* Info/How It Works Section */
.info-card {
    padding: 0;
    overflow: hidden;
}

.info-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 15px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.info-toggle:hover {
    background-color: rgba(0, 212, 255, 0.05);
}

.info-toggle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 22px;
    height: 22px;
    border: 1px solid var(--accent-cyan);
    border-radius: 50%;
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--accent-cyan);
}

.info-toggle-text {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
    letter-spacing: 2px;
}

.info-toggle-arrow {
    font-size: 0.7rem;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
}

.info-toggle-arrow.expanded {
    transform: rotate(180deg);
}

.info-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease, padding 0.4s ease;
    padding: 0 15px;
}

.info-content.expanded {
    max-height: 1200px;
    padding: 0 15px 20px;
}

.info-section {
    margin-bottom: 18px;
    padding-bottom: 18px;
    border-bottom: 1px solid var(--card-border);
}

.info-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.info-section h3 {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--accent-cyan);
    letter-spacing: 2px;
    margin-bottom: 10px;
}

.info-section p {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.info-flow {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 6px;
    margin-bottom: 12px;
    padding: 10px 0;
}

.info-flow-item {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    color: var(--text-primary);
    padding: 6px 10px;
    background-color: var(--bg-dark);
    border: 1px solid var(--card-border);
    border-radius: 4px;
}

.info-flow-arrow {
    color: var(--accent-cyan);
    font-size: 0.9rem;
}

.info-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.info-list li {
    font-family: var(--font-sans);
    font-size: 0.85rem;
    color: var(--text-secondary);
    padding: 6px 0;
    padding-left: 15px;
    position: relative;
}

.info-list li::before {
    content: '›';
    position: absolute;
    left: 0;
    color: var(--accent-cyan);
}

.info-list li strong {
    font-family: var(--font-mono);
    color: var(--text-primary);
    font-weight: normal;
}

/* Build Logs Panel - Right sidebar panel */
.logs-card {
    padding: 0;
    overflow: hidden;
    position: fixed;
    left: calc(50% + 248px);
    top: 125px;
    width: 320px;
    bottom: 15px;
    z-index: 100;
}

.logs-header {
    display: flex;
    align-items: center;
    padding: 12px 15px;
}

.logs-header h2 {
    margin-bottom: 0;
}

.logs-content {
    overflow: hidden;
    height: calc(100% - 45px);
}

.logs-output {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    line-height: 1.4;
    color: var(--text-secondary);
    background-color: var(--bg-dark);
    margin: 0 10px 10px;
    padding: 10px;
    border-radius: 4px;
    overflow-y: auto;
    height: calc(100% - 10px);
    white-space: pre-wrap;
    word-break: break-all;
}

/* Mobile: revert to inline stacked layout */
@media (max-width: 1100px) {
    .stages-card {
        position: static;
        width: 100%;
        right: auto;
        top: auto;
        bottom: auto;
    }

    .stages-card h2 {
        padding: 0;
        margin-bottom: 10px;
    }

    .stages-container {
        flex-direction: row;
        flex-wrap: wrap;
        height: auto;
        padding: 10px 0;
    }

    .stage-arrow {
        transform: none;
        margin: 0 4px;
    }

    .logs-card {
        position: static;
        width: 100%;
        height: auto;
        left: auto;
        top: auto;
        bottom: auto;
    }

    .logs-content {
        height: 250px;
    }
}
