/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    background: #1e1e2e;
    color: #cdd6f4;
    font-family: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', Consolas, monospace;
}

/* Terminal page layout */
.terminal-page {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

.terminal-container {
    flex: 1;
    overflow: hidden;
}

.terminals-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.terminal-instance {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Status bar at bottom */
.status-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 12px;
    background: #181825;
    border-top: 1px solid #313244;
    font-size: 12px;
    color: #a6adc8;
    height: 28px;
    flex-shrink: 0;
}

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

.status-indicator.connected {
    background: #a6e3a1;
    box-shadow: 0 0 4px #a6e3a1;
}

.status-indicator.working {
    background: #f9e2af;
    box-shadow: 0 0 4px #f9e2af;
    animation: pulse 1.5s ease-in-out infinite;
}

.status-indicator.connecting {
    background: #f9e2af;
    animation: pulse 1s ease-in-out infinite;
}

.status-indicator.disconnected {
    background: #f38ba8;
}

.status-indicator.error {
    background: #f38ba8;
    box-shadow: 0 0 4px #f38ba8;
}

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

.status-text {
    flex: 1;
}

.status-right {
    font-size: 11px;
    color: #585b70;
    display: flex;
    gap: 12px;
}

.status-version {
    color: #45475a;
    font-family: 'JetBrains Mono', monospace;
}

/* Loading state */
.loading-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: #1e1e2e;
}

.loading-progress {
    width: 80px;
    height: 80px;
}

.loading-progress circle {
    fill: none;
    stroke: #585b70;
    stroke-width: 3;
}

.loading-progress circle:nth-child(2) {
    stroke: #89b4fa;
    stroke-dasharray: 251;
    stroke-dashoffset: 251;
    animation: loading-dash 1.5s ease-in-out infinite;
}

@keyframes loading-dash {
    0% { stroke-dashoffset: 251; }
    50% { stroke-dashoffset: 0; }
    100% { stroke-dashoffset: -251; }
}

/* Tab bar */
.tab-bar {
    display: flex;
    align-items: stretch;
    background: #181825;
    border-bottom: 1px solid #313244;
    height: 36px;
    flex-shrink: 0;
    overflow-x: auto;
    scrollbar-width: none;
}

.tab-bar::-webkit-scrollbar { display: none; }

.tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0 14px;
    font-size: 12px;
    color: #a6adc8;
    cursor: pointer;
    border-right: 1px solid #313244;
    white-space: nowrap;
    transition: background 0.1s;
}

.tab:hover { background: #313244; }

.tab.active {
    background: #1e1e2e;
    color: #cdd6f4;
    border-bottom: 2px solid #89b4fa;
}

.tab .bi-terminal {
    font-size: 11px;
    color: #585b70;
}

.tab.active .bi-terminal {
    color: #89b4fa;
}

.tab.exited {
    opacity: 0.5;
}

.tab.exited .bi-terminal-x {
    color: #f38ba8;
}

.tab-label {
    font-family: 'JetBrains Mono', monospace;
}

.tab-close {
    background: none;
    border: none;
    color: #585b70;
    font-size: 10px;
    cursor: pointer;
    padding: 0 2px;
    line-height: 1;
}

.tab-close:hover { color: #f38ba8; }

.tab-new {
    background: none;
    border: none;
    border-right: 1px solid #313244;
    color: #a6adc8;
    font-size: 18px;
    padding: 0 14px;
    cursor: pointer;
    font-family: inherit;
}

.tab-new:hover { background: #313244; color: #a6e3a1; }
.tab-new:disabled { opacity: 0.3; cursor: not-allowed; }

/* Dashboard */
.dashboard {
    max-width: 700px;
    margin: 0 auto;
    padding: 40px 20px;
}

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

.dashboard-header h1 {
    font-size: 24px;
    font-weight: 600;
    color: #cdd6f4;
}

.btn-new {
    background: #89b4fa;
    color: #1e1e2e;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}

.btn-new:hover { background: #b4d0fb; }
.btn-new:disabled { opacity: 0.5; cursor: not-allowed; }

.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 20px;
    color: #a6adc8;
}

.session-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.session-card {
    background: #313244;
    border: 1px solid #45475a;
    border-radius: 8px;
    padding: 16px 20px;
    cursor: pointer;
    transition: border-color 0.15s;
}

.session-card:hover { border-color: #89b4fa; }
.session-card.stopped { opacity: 0.6; }

.session-id {
    font-size: 16px;
    font-weight: 600;
    color: #cdd6f4;
    margin-bottom: 6px;
    font-family: 'JetBrains Mono', monospace;
}

.session-meta {
    display: flex;
    gap: 16px;
    font-size: 12px;
    color: #a6adc8;
}

.dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
    vertical-align: middle;
}

.dot.green { background: #a6e3a1; }
.dot.red { background: #f38ba8; }

.session-viewer {
    color: #f9e2af;
}

.loading { color: #a6adc8; text-align: center; padding: 40px; }

/* Terminal toolbar */
.terminal-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 6px 12px;
    background: #181825;
    border-bottom: 1px solid #313244;
    height: 36px;
    flex-shrink: 0;
}

.btn-back {
    background: #313244;
    color: #cdd6f4;
    border: 1px solid #45475a;
    padding: 4px 12px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
}

.btn-back:hover { border-color: #89b4fa; }

.session-label {
    font-size: 12px;
    color: #a6adc8;
    font-family: 'JetBrains Mono', monospace;
}

/* Kicked overlay */
.kicked-overlay {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1e1e2e;
}

.kicked-content {
    text-align: center;
    padding: 40px;
}

.kicked-content h3 {
    color: #cdd6f4;
    margin: 16px 0 8px;
    font-size: 18px;
}

.kicked-content p {
    color: #a6adc8;
    margin-bottom: 24px;
    font-size: 13px;
}

.kicked-content .modal-btn {
    font-size: 14px;
    padding: 10px 24px;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-dialog {
    background: #313244;
    border: 1px solid #45475a;
    border-radius: 10px;
    width: 400px;
    max-width: 90vw;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px 20px;
    border-bottom: 1px solid #45475a;
    font-size: 15px;
    font-weight: 600;
    color: #cdd6f4;
}

.modal-header .bi {
    color: #f9e2af;
    font-size: 18px;
}

.modal-body {
    padding: 16px 20px;
    font-size: 13px;
    color: #a6adc8;
    line-height: 1.5;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    padding: 12px 20px;
    border-top: 1px solid #45475a;
}

.modal-btn {
    padding: 6px 16px;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    font-family: inherit;
}

.modal-btn.cancel {
    background: #45475a;
    color: #cdd6f4;
}

.modal-btn.cancel:hover {
    background: #585b70;
}

.modal-btn.confirm {
    background: #f38ba8;
    color: #1e1e2e;
}

.modal-btn.confirm:hover {
    background: #f5a0b8;
}

/* Blazor error UI */
#blazor-error-ui {
    background: #f38ba8;
    color: #1e1e2e;
    padding: 8px 16px;
    position: fixed;
    bottom: 0;
    width: 100%;
    z-index: 1000;
    display: none;
}

#blazor-error-ui .reload {
    color: #1e1e2e;
    text-decoration: underline;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    float: right;
}
