/* Layout and shared component styles */

:root {
    --color-bg: #f1f5f9;
    --color-surface: #ffffff;
    --color-surface-hover: #e2e8f0;
    --color-border: #cbd5e1;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --color-primary: #3b82f6;
    --color-primary-hover: #2563eb;
    --color-success: #16a34a;
    --color-warning: #d97706;
    --color-danger: #dc2626;
    --color-danger-hover: #b91c1c;
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    min-height: 100vh;
}

a { color: var(--color-primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Nav */
.nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
}
.nav-brand {
    font-size: 18px;
    font-weight: 700;
    color: var(--color-text);
    text-decoration: none;
}
.nav-brand:hover { text-decoration: none; }
.nav-links { display: flex; gap: 16px; align-items: center; }
.nav-links a { color: var(--color-text-muted); font-size: 14px; }
.nav-links a:hover { color: var(--color-text); text-decoration: none; }
.nav-user { font-size: 13px; color: var(--color-text-muted); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}
.btn-primary { background: var(--color-primary); color: #fff; }
.btn-primary:hover { background: var(--color-primary-hover); }
.btn-success { background: var(--color-success); color: #fff; }
.btn-success:hover { background: #16a34a; }
.btn-danger { background: var(--color-danger); color: #fff; }
.btn-danger:hover { background: var(--color-danger-hover); }
.btn-ghost {
    background: transparent;
    color: var(--color-text-muted);
    border: 1px solid var(--color-border);
}
.btn-ghost:hover { background: var(--color-surface-hover); color: var(--color-text); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* Forms */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--color-text-muted);
    margin-bottom: 6px;
}
.form-control {
    width: 100%;
    padding: 8px 12px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text);
    font-size: 14px;
}
.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
}
select.form-control { appearance: auto; }
textarea.form-control { resize: vertical; min-height: 80px; }

.checkbox-group { display: flex; flex-wrap: wrap; gap: 8px; }
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    padding: 4px 10px;
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
}
.checkbox-label:has(input:checked) {
    border-color: var(--color-primary);
    background: rgba(59, 130, 246, 0.1);
}
.checkbox-label input { accent-color: var(--color-primary); }

.radio-group { display: flex; gap: 16px; }
.radio-label { display: flex; align-items: center; gap: 6px; font-size: 14px; cursor: pointer; }
.radio-label input { accent-color: var(--color-primary); }

/* Cards */
.card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 20px;
}
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
    gap: 16px;
    padding: 24px;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-success { background: rgba(22,163,74,0.1); color: var(--color-success); }
.badge-warning { background: rgba(217,119,6,0.1); color: var(--color-warning); }
.badge-danger { background: rgba(220,38,38,0.1); color: var(--color-danger); }
.badge-info { background: rgba(59,130,246,0.1); color: var(--color-primary); }
.badge-muted { background: rgba(100,116,139,0.1); color: var(--color-text-muted); }

.badge-critical { background: rgba(183,28,28,0.12); color: #b91c1c; }
.badge-high { background: rgba(230,81,0,0.12); color: #c2410c; }
.badge-medium { background: rgba(245,158,11,0.12); color: #b45309; }
.badge-low { background: rgba(59,130,246,0.12); color: #2563eb; }

/* Page layout */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--color-border);
}
.page-header h1 { font-size: 22px; font-weight: 700; }

.page-content { padding: 24px; }

/* Login page */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}
.login-box {
    width: 400px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 40px 32px;
}
.login-box h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
}
.login-box p {
    color: var(--color-text-muted);
    font-size: 14px;
    margin-bottom: 24px;
}
.login-error {
    background: rgba(239,68,68,0.1);
    color: var(--color-danger);
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: 13px;
    margin-bottom: 16px;
    display: none;
}

/* Modal / Overlay */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
}
.modal {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 24px;
    width: 560px;
    max-height: 80vh;
    overflow-y: auto;
}
.modal h2 { font-size: 18px; margin-bottom: 20px; }
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 20px;
}

/* Slide panel (issue detail) */
.slide-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 40vw;
    min-width: 480px;
    height: 100vh;
    background: var(--color-surface);
    border-left: 1px solid var(--color-border);
    z-index: 200;
    overflow-y: auto;
    transform: translateX(100%);
    transition: transform 0.2s ease;
}
.slide-panel.open { transform: translateX(0); }
.slide-panel-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 20px;
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    background: var(--color-surface);
    z-index: 1;
}
.panel-header-title {
    display: flex;
    align-items: baseline;
    gap: 6px;
    min-width: 0;
}
.panel-header-title h3 {
    font-size: 18px;
    font-weight: 700;
    margin: 0;
    line-height: 1.3;
    word-break: break-word;
}
.panel-issue-num {
    font-size: 16px;
    font-weight: 400;
    color: var(--color-text-muted);
    white-space: nowrap;
    text-decoration: none;
}
.panel-issue-num:hover { color: var(--color-primary); text-decoration: underline; }
.slide-panel-body { padding: 0; }
.slide-panel-close {
    background: none;
    border: none;
    color: var(--color-text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 2px 4px;
    line-height: 1;
}
.slide-panel-close:hover { color: var(--color-text); }

.panel-layout {
    display: flex;
    min-height: 0;
}
.panel-main {
    flex: 1;
    min-width: 0;
    padding: 16px 20px;
}
.panel-sidebar {
    width: 180px;
    flex-shrink: 0;
    padding: 16px;
    border-left: 1px solid var(--color-border);
}
.sidebar-field {
    padding-bottom: 14px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--color-border);
}
.sidebar-field:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.sidebar-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--color-text-muted);
    margin-bottom: 6px;
}
.panel-menu-wrap {
    position: relative;
}
.panel-menu-btn {
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--color-text-muted);
    font-size: 14px;
    cursor: pointer;
    padding: 0 6px;
    line-height: 1.2;
    letter-spacing: 2px;
}
.panel-menu-btn:hover {
    background: var(--color-surface-hover);
    border-color: var(--color-border);
    color: var(--color-text);
}
.panel-menu {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    min-width: 120px;
    z-index: 10;
    overflow: hidden;
}
.panel-menu button {
    display: block;
    width: 100%;
    text-align: left;
    padding: 8px 12px;
    background: none;
    border: none;
    font-size: 13px;
    cursor: pointer;
    color: var(--color-text);
}
.panel-menu button:hover {
    background: var(--color-bg);
}
.panel-pr-link {
    font-size: 12px;
    padding: 2px 8px;
    background: rgba(59,130,246,0.08);
    border-radius: 4px;
    color: var(--color-primary);
}
.panel-comment {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    margin-bottom: 10px;
}
.panel-comment-agent {
    border-color: rgba(139,92,246,0.2);
}
.panel-comment-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    border-radius: var(--radius) var(--radius) 0 0;
    font-size: 12px;
}
.panel-comment-agent .panel-comment-header {
    background: rgba(139,92,246,0.06);
    border-bottom-color: rgba(139,92,246,0.15);
}
.panel-comment-body {
    padding: 12px;
}
.panel-comment-user {
    font-weight: 500;
    color: var(--color-text);
}
.panel-add-comment {
    margin-top: 20px;
}
.panel-add-comment-label {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 8px;
}
.panel-add-comment textarea {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 13px;
    resize: vertical;
    min-height: 80px;
}
.panel-add-comment textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}
.panel-add-comment-action {
    display: flex;
    justify-content: flex-end;
    margin-top: 8px;
}

/* Toggle switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--color-border);
    border-radius: 11px;
    cursor: pointer;
    transition: background 0.2s;
}
.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    top: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}
.toggle input:checked + .toggle-slider { background: var(--color-success); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* Status dot */
.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}
.status-dot.running { background: var(--color-success); }
.status-dot.stopped { background: var(--color-text-muted); }
.status-dot.setting-up { background: var(--color-warning); animation: status-pulse 1.5s ease-in-out infinite; }

@keyframes status-pulse {
    0%, 100% { opacity: 0.35; }
    50% { opacity: 1; }
}
.status-dot.setup-failed { background: var(--color-danger); }

.card.card-setting-up { opacity: 0.8; }

/* Utility */
.hidden { display: none !important; }
.text-muted { color: var(--color-text-muted); }
.text-sm { font-size: 13px; }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mb-2 { margin-bottom: 8px; }
.flex { display: flex; }
.items-center { align-items: center; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 12px; }
.justify-between { justify-content: space-between; }
.flex-1 { flex: 1; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Markdown content in issue panel */
.md-content h1, .md-content h2, .md-content h3 { margin: 12px 0 6px; font-weight: 600; }
.md-content h1 { font-size: 18px; }
.md-content h2 { font-size: 16px; }
.md-content h3 { font-size: 14px; }
.md-content p { margin: 6px 0; }
.md-content ul, .md-content ol { margin: 6px 0; padding-left: 24px; }
.md-content li { margin: 2px 0; }
.md-content code {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 12px;
}
.md-content pre {
    background: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    padding: 10px 12px;
    overflow-x: auto;
    margin: 8px 0;
}
.md-content pre code {
    border: none;
    padding: 0;
    background: none;
    font-size: 12px;
}
.md-content blockquote {
    border-left: 3px solid var(--color-border);
    padding-left: 12px;
    margin: 8px 0;
    color: var(--color-text-muted);
}
.md-content a { color: var(--color-primary); }
.md-content img { max-width: 100%; border-radius: var(--radius); }
