/* ========================================================================
   Components — Buttons, Forms, Modals, Badges, Chips
   ======================================================================== */

/* --- Forms --- */
.form-group {
    margin-bottom: var(--space-5);
}
.form-group label {
    display: block;
    font-family: var(--font-display);
    font-weight: 700;
    text-transform: uppercase;
    font-size: var(--text-sm);
    letter-spacing: 0.1em;
    line-height: var(--lh-snug);
    color: var(--text-muted);
    margin-bottom: var(--space-2);
}
.form-group select,
.form-group input,
.form-group textarea {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: var(--font-body);
    font-size: var(--text-base);
    background: var(--bg-raised);
    color: var(--text);
    box-sizing: border-box;
    transition: border-color var(--duration-fast) var(--ease-out),
                box-shadow var(--duration-fast) var(--ease-out);
}
.form-group select:focus,
.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px var(--ring);
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-5);
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-display);
    font-weight: 700;
    text-transform: uppercase;
    font-size: var(--text-sm);
    letter-spacing: 0.06em;
    cursor: pointer;
    transition: background var(--duration-fast) var(--ease-out),
                color var(--duration-fast) var(--ease-out),
                border-color var(--duration-fast) var(--ease-out),
                transform var(--duration-fast) var(--ease-out);
    text-decoration: none;
    line-height: 1.4;
}
.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--brand-blue);
    color: var(--text-on-brand);
}
.btn-primary:hover {
    background: var(--brand-blue-hover);
}

.btn:disabled, .btn[disabled] {
    opacity: 0.45;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-danger {
    background: var(--brand-red);
    color: var(--text-on-brand);
}
.btn-danger:hover {
    background: var(--brand-red-hover);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}
.btn-outline:hover {
    border-color: var(--text-muted);
    color: var(--text);
}

/* --- Modal --- */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: var(--bg-overlay);
    z-index: 100;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}
.modal-backdrop.active { display: flex; }

.modal {
    background: var(--bg-raised);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    padding: var(--space-7);
    min-width: 440px;
    max-width: 640px;
    box-shadow: var(--shadow-lg);
    animation: modal-in var(--duration-normal) var(--ease-out);
}
@keyframes modal-in {
    from {
        opacity: 0;
        transform: translateY(8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal h2 {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--text-xl);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: var(--lh-tight);
    margin-bottom: var(--space-6);
    color: var(--text);
}

.modal-actions {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
    margin-top: var(--space-6);
}

.form-error {
    color: var(--brand-red);
    font-size: var(--text-sm);
    margin-top: var(--space-1);
}

/* --- Issue autocomplete combobox --- */
.issue-combobox {
    position: relative;
}
.issue-dropdown {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    max-height: 260px;
    overflow-y: auto;
}
.issue-option {
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: background var(--duration-fast);
}
.issue-option:last-child { border-bottom: none; }
.issue-option:hover,
.issue-option.highlighted {
    background: oklch(0.55 0.17 250 / 0.07);
}
.issue-option .issue-opt-ref {
    font-family: var(--font-display);
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--brand-blue);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}
.issue-option .issue-opt-title {
    font-size: var(--text-sm);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.issue-option-empty {
    padding: var(--space-2) var(--space-3);
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-style: italic;
}

.issue-selected-badge {
    margin-top: var(--space-2);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    background: oklch(0.55 0.17 250 / 0.06);
    border: 1px solid oklch(0.55 0.17 250 / 0.15);
    font-size: var(--text-sm);
    color: var(--text-secondary);
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
}
.issue-selected-badge .issue-sel-ref {
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--brand-blue);
    white-space: nowrap;
    flex-shrink: 0;
}
.issue-selected-badge .issue-sel-title {
    flex: 1;
    word-break: break-word;
}
.issue-selected-badge .issue-sel-clear {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted);
    font-size: var(--text-base);
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
    transition: color var(--duration-fast);
}
.issue-selected-badge .issue-sel-clear:hover {
    color: var(--brand-red);
}

/* --- Label combobox (mapping modal) --- */
.label-combobox {
    position: relative;
}
.label-dropdown {
    position: absolute;
    top: calc(100% + 2px);
    left: 0;
    right: 0;
    background: var(--bg-raised);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    max-height: 220px;
    overflow-y: auto;
    display: none;
}
.label-option {
    padding: var(--space-3) var(--space-4);
    cursor: pointer;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--duration-fast);
}
.label-option:last-child { border-bottom: none; }
.label-option:hover,
.label-option.highlighted {
    background: oklch(0.55 0.17 250 / 0.07);
}
.label-option-empty {
    padding: var(--space-2) var(--space-3);
    color: var(--text-muted);
    font-size: var(--text-sm);
    font-style: italic;
}

/* --- Toggle switch --- */
.toggle-slider::before {
    content: '';
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: var(--bg-raised);
    border-radius: var(--radius-full);
    transition: transform var(--duration-normal) var(--ease-out);
}
input:checked + .toggle-slider::before {
    transform: translateX(22px);
}

/* --- Chips and badges --- */
.label-chip {
    background: var(--bg-sunken);
    color: var(--text-secondary);
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 600;
    line-height: var(--lh-snug);
}

.role-badge {
    display: inline-block;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-full);
    font-size: var(--text-xs);
    font-weight: 700;
    font-family: var(--font-display);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: var(--lh-snug);
}
.role-badge.assignee {
    background: oklch(0.90 0.06 250);
    color: oklch(0.40 0.14 250);
}
.role-badge.reviewer {
    background: oklch(0.90 0.06 300);
    color: oklch(0.40 0.14 300);
}

@media (prefers-color-scheme: dark) {
    .role-badge.assignee {
        background: oklch(0.25 0.05 250);
        color: oklch(0.72 0.12 250);
    }
    .role-badge.reviewer {
        background: oklch(0.25 0.05 300);
        color: oklch(0.72 0.12 300);
    }
}
[data-theme="dark"] .role-badge.assignee {
    background: oklch(0.25 0.05 250);
    color: oklch(0.72 0.12 250);
}
[data-theme="dark"] .role-badge.reviewer {
    background: oklch(0.25 0.05 300);
    color: oklch(0.72 0.12 300);
}

.kind-badge {
    display: inline-block;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-sm);
    font-size: var(--text-xs);
    font-weight: 700;
    font-family: var(--font-display);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: var(--lh-snug);
    margin-right: var(--space-2);
}
.kind-badge.issue {
    background: var(--surface-success);
    color: var(--text-success);
}
.kind-badge.mr {
    background: var(--surface-warning);
    color: var(--text-warning);
}

/* --- Section Headers --- */
.section-header {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--text-lg);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text);
    margin-bottom: var(--space-4);
    padding-bottom: var(--space-2);
    border-bottom: 2px solid var(--brand-red);
    display: inline-block;
}

/* --- Info banner — transient status messages --- */
.info-banner {
    background: var(--bg-sunken);
    color: var(--text-secondary);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--text-sm);
    margin-bottom: var(--space-3);
    text-align: center;
    border: 1px solid var(--border-subtle);
}
