/* Repos & Sources — wireframe 1e: featured repo card, tab presets and a
   grid "table" of sources with one-tap Add / Copy.

   The rows are grid rows rather than <table> markup so source-manager.js can
   keep drag-reordering them. This file also carries the manager chrome
   (drag handle, delete button, add/edit modal) that used to come from
   repo.css, so the page no longer loads that stylesheet. */

.src-main {
    max-width: var(--dir-max);
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.hidden {
    display: none !important;
}

/* ---------- Head ---------- */

.src-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.src-title {
    margin: 0;
    font-size: 1.5rem;
    letter-spacing: -0.015em;
}

.src-head-actions {
    display: flex;
    gap: 0.5rem;
}

.src-submit-btn {
    padding: 0.6rem 1.1rem;
    border-radius: 12px;
    border: 0;
    background: var(--accent-blue);
    color: #08111f;
    font-size: 0.87rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
}

.src-manage-btn {
    padding: 0.6rem 1.1rem;
    border-radius: 12px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font-size: 0.87rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}

.src-manage-btn[aria-pressed="true"],
.source-action-btn-active {
    border-color: var(--accent-blue);
    color: var(--accent-blue);
}

.src-flash,
.src-error {
    margin: 0;
    padding: 0.7rem 1rem;
    border-radius: 11px;
    font-size: 0.88rem;
}

.src-flash {
    border: 1px solid rgba(52, 168, 83, 0.35);
    background: rgba(52, 168, 83, 0.12);
    color: #7ddc9c;
}

.src-error {
    border: 1px solid rgba(234, 67, 53, 0.35);
    background: rgba(234, 67, 53, 0.12);
    color: #ff9c92;
}

.src-hint {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* ---------- Featured repo ---------- */

.src-featured {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 1rem;
    min-height: 164px;
    padding: 1.15rem;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 20px;
    background:
        radial-gradient(circle at 28% 22%, rgba(74, 158, 255, 0.35), transparent 35%),
        linear-gradient(135deg, #2b1957 0%, #1e293b 100%);
}

.src-featured-title {
    margin: 0 0 0.25rem;
    font-size: 1.08rem;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.src-official {
    padding: 0.12rem 0.5rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.16);
    color: var(--accent-blue);
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.src-featured-desc {
    margin: 0;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.72);
}

.src-featured-actions {
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
}

/* ---------- Tabs ---------- */

.src-tabs {
    display: flex;
    gap: 0.3rem;
    padding: 0.25rem;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04);
    width: fit-content;
}

.src-tab {
    padding: 0.4rem 0.95rem;
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
}

.src-tab-active {
    background: rgba(74, 158, 255, 0.18);
    color: var(--accent-blue);
}

/* ---------- Table -> app-store-style card list ---------- */

.src-table {
    display: block;
}

.src-table-body {
    display: flex;
    flex-direction: column;
    gap: 0.72rem;
}

.src-row {
    position: relative;
    display: grid;
    grid-template-columns: 20px 44px minmax(0, 1fr) auto;
    align-items: center;
    gap: 0.65rem;
    min-height: 78px;
    padding: 0.6rem 0.7rem;
    border: 0;
    border-radius: 20px;
    background: rgba(28, 28, 30, 0.94);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
    cursor: pointer;
    transition: background 0.15s, transform 0.15s;
}

.src-row:hover {
    background: rgba(44, 44, 46, 0.98);
    transform: scale(0.992);
}

.src-mark {
    flex: none;
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    border-radius: 13px;
    background: linear-gradient(135deg, #4a9eff, #34a853);
    color: #fff;
    font-weight: 800;
    font-size: 1.05rem;
}

.src-source-text {
    display: flex;
    flex-direction: column;
    gap: 0.12rem;
    min-width: 0;
    text-decoration: none;
}

.src-name {
    font-size: 0.94rem;
    font-weight: 700;
    color: #fff;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.src-source-text:hover .src-name {
    color: var(--accent-blue);
}

.src-note {
    font-size: 0.76rem;
    color: #858585;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.src-cell-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.src-add-btn {
    padding: 0.4rem 0.85rem;
    border-radius: 999px;
    background: rgba(74, 158, 255, 0.16);
    color: var(--accent-blue);
    font-size: 0.8rem;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
}

/* Combined-class selector so this reliably wins over the plain .src-copy-btn
   padding declared further down, regardless of source order. */
.src-copy-btn.src-copy-btn-icon {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border-radius: 50%;
}

.src-copy-btn-icon svg {
    width: 15px;
    height: 15px;
}

.src-copy-btn-icon .icon-check {
    color: var(--accent-green);
}

.src-copy-btn-icon:not(.is-copied) .icon-check {
    display: none;
}

.src-copy-btn-icon.is-copied {
    border-color: var(--accent-green);
}

.src-copy-btn-icon.is-copied .icon-copy {
    display: none;
}

.src-add-btn:hover {
    text-decoration: none;
    background: var(--accent-blue);
    color: #08111f;
}

.src-copy-btn {
    padding: 0.4rem 0.9rem;
    border-radius: 999px;
    border: 1px solid var(--card-border);
    background: transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
}

.src-copy-btn:hover {
    color: var(--text);
    border-color: var(--accent-blue);
}

.src-copy-btn.is-copied {
    color: var(--accent-green);
    border-color: var(--accent-green);
}

.src-add-btn-lg,
.src-copy-btn-lg {
    padding: 0.6rem 1.1rem;
    border-radius: 12px;
    font-size: 0.87rem;
}

.src-add-btn-lg {
    background: var(--accent-blue);
    color: #08111f;
}

/* ---------- Manager chrome (drag handle, delete, modal) ---------- */

/* The handle keeps its grid cell when idle — hiding it with display:none
   would collapse the gutter column and shift every other cell left. */
.source-row-drag-handle {
    display: block;
    visibility: hidden;
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    cursor: grab;
    touch-action: none;
}

.source-row-drag-handle svg {
    width: 100%;
    height: 100%;
}

/* Pulled out of the grid flow so it cannot open an extra implicit row. */
.source-row-delete-form {
    display: none;
    position: absolute;
    top: 50%;
    right: 0.5rem;
    transform: translateY(-50%);
}

.source-editing .source-row-drag-handle {
    visibility: visible;
}

.source-editing .source-row-delete-form {
    display: block;
}

.source-editing .src-row {
    cursor: default;
    padding-right: 2.6rem;
}

.source-card-dragging {
    opacity: 0.55;
    background: rgba(74, 158, 255, 0.08);
}

.source-row-delete-btn {
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    border: 0;
    background: var(--accent-red);
    color: #fff;
    cursor: pointer;
}

.source-row-delete-btn svg {
    width: 15px;
    height: 15px;
}

.source-modal {
    position: fixed;
    inset: 0;
    z-index: 200;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(4, 8, 16, 0.7);
    backdrop-filter: blur(6px);
}

.source-modal-panel {
    width: min(420px, 100%);
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    padding: 1.25rem;
    border: 1px solid var(--card-border);
    border-radius: 18px;
    background: var(--surface);
}

.source-modal-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 1.05rem;
}

.source-modal-head button {
    border: 0;
    background: none;
    color: var(--text-muted);
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.source-modal-panel label {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.source-modal-panel input {
    padding: 0.65rem 0.8rem;
    border-radius: 11px;
    border: 1px solid var(--card-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text);
    font-size: 0.9rem;
    font-family: inherit;
}

.source-modal-panel input:focus {
    outline: none;
    border-color: var(--accent-blue);
}

.source-save-btn {
    padding: 0.7rem;
    border-radius: 12px;
    border: 0;
    background: var(--accent-blue);
    color: #08111f;
    font-size: 0.9rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
}

/* ---------- Responsive ---------- */

@media (max-width: 768px) {
    .src-main {
        padding-bottom: calc(var(--dir-tabbar-h) + 2rem);
    }

    .src-featured-actions .src-add-btn-lg,
    .src-featured-actions .src-copy-btn-lg {
        flex: 1 1 auto;
        text-align: center;
    }
}
