/**
 * 後台響應式 - 專案原始碼管理頁面
 *
 * 由 admin-responsive.css 依原行序拆出；載入順序見 src/lib/assets.ts 的
 * ADMIN_STYLES，順序即 cascade 順序，不可調換。
 */

/* ========================================================================== */
/* ==================== 專案原始碼管理 - 響應式設計 ========================== */
/* ========================================================================== */

/* ===== 中等手機尺寸 (max-width: 48rem / 768px) ===== */
@media (max-width: 48rem) {

    /* 頁籤 - 等寬填滿 */
    .sc-tabs {
        gap: 0;
    }

    .sc-tab {
        flex: 1;
        justify-content: center;
        padding: 0.5rem 0.75rem;
        font-size: 0.8125rem;
    }

    /* 工具列按鈕 */
    #page-source-code .toolbar-right .btn span {
        display: inline;
    }

    #page-source-code .toolbar-right .btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.75rem;
    }

    #page-source-code .toolbar-right {
        flex-wrap: wrap;
        gap: 0.5rem;
    }

    /* ===== 主專案表格 → 卡片式佈局 ===== */
    #sourceCodeTableContainer {
        overflow-x: visible;
    }

    #sourceCodeTable {
        min-width: unset;
        display: block;
        width: 100%;
    }

    #sourceCodeTable thead {
        display: none;
    }

    #sourceCodeTable tbody {
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
        width: 100%;
    }

    #sourceCodeTable tbody tr {
        display: grid !important;
        grid-template-columns: auto 1fr 1fr auto;
        grid-template-rows: auto auto auto;
        column-gap: 0.625rem;
        row-gap: 0.375rem;
        padding: 0.75rem;
        background: #1a1a1a;
        border-radius: 0.625rem;
        border: 1px solid #2a2a2a;
        align-items: center;
    }

    .light-theme #sourceCodeTable tbody tr {
        background: #fff;
        border-color: #e5e5e5;
    }

    #sourceCodeTable tbody tr td {
        display: flex !important;
        align-items: center;
        border-bottom: none;
        padding: 0;
        width: auto !important;
        min-width: unset !important;
    }

    /* 縮圖 - col 1, row 1~2 */
    #sourceCodeTable tbody tr td:nth-child(1) {
        grid-column: 1;
        grid-row: 1 / 3;
    }

    /* 專案名稱 - col 2~3, row 1 */
    #sourceCodeTable tbody tr td:nth-child(2) {
        grid-column: 2 / 4;
        grid-row: 1;
        justify-content: flex-start;
    }

    #sourceCodeTable tbody tr td:nth-child(2) .sc-name-cell a {
        font-size: 0.9375rem;
    }

    /* 分支 - col 2, row 2 */
    #sourceCodeTable tbody tr td:nth-child(3) {
        grid-column: 2;
        grid-row: 2;
        justify-content: flex-start;
    }

    /* Tag - col 3, row 2 */
    #sourceCodeTable tbody tr td:nth-child(4) {
        grid-column: 3;
        grid-row: 2;
        justify-content: flex-start;
    }

    /* Submodule 欄位 - row 3 */
    #sourceCodeTable tbody tr td:nth-child(5),
    #sourceCodeTable tbody tr td:nth-child(6),
    #sourceCodeTable tbody tr td:nth-child(7) {
        flex-direction: column;
        gap: 0.125rem;
        align-items: flex-start;
        padding-top: 0.375rem;
        border-top: 1px solid rgba(255, 255, 255, 0.06);
    }

    .light-theme #sourceCodeTable tbody tr td:nth-child(5),
    .light-theme #sourceCodeTable tbody tr td:nth-child(6),
    .light-theme #sourceCodeTable tbody tr td:nth-child(7) {
        border-top-color: rgba(0, 0, 0, 0.06);
    }

    #sourceCodeTable tbody tr td:nth-child(5) {
        grid-column: 1;
        grid-row: 3;
    }

    #sourceCodeTable tbody tr td:nth-child(6) {
        grid-column: 2;
        grid-row: 3;
    }

    #sourceCodeTable tbody tr td:nth-child(7) {
        grid-column: 3;
        grid-row: 3;
    }

    /* 程式碼審查 - col 4, row 1~3, 垂直置中 */
    #sourceCodeTable tbody tr td:nth-child(8) {
        grid-column: 4;
        grid-row: 1 / 4;
        align-self: center;
        justify-self: center;
        border-top: none;
        padding-top: 0;
    }

    /* Submodule 欄位標籤 - 共用樣式 */
    #sourceCodeTable tbody tr td:nth-child(5)::before,
    #sourceCodeTable tbody tr td:nth-child(6)::before,
    #sourceCodeTable tbody tr td:nth-child(7)::before {
        font-size: 0.5625rem;
        font-weight: 700;
        color: var(--text-secondary);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        opacity: 0.5;
    }

    #sourceCodeTable tbody tr td:nth-child(5)::before { content: "Core"; }
    #sourceCodeTable tbody tr td:nth-child(6)::before { content: "Slot"; }
    #sourceCodeTable tbody tr td:nth-child(7)::before { content: "WebGL"; }

    /* Submodule 版本面板 - 三欄 → 單欄 */
    .sm-version-cards {
        grid-template-columns: 1fr !important;
    }

    .sm-version-card {
        border-right: none !important;
        border-bottom: 1px solid rgba(168, 85, 247, 0.08);
    }

    .sm-version-card:last-child {
        border-bottom: none;
    }

    .light-theme .sm-version-card {
        border-bottom-color: #e9d5ff;
    }

    /* Submodule 區塊標題 - 堆疊排列 */
    .sm-section-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }

    .sm-section-actions {
        width: 100%;
        flex-wrap: wrap;
        gap: 0.375rem;
    }

    .sm-section-actions .source-code-meta {
        order: -1;
        width: 100%;
    }

    /* ChangeLog 確認彈窗 - 直式排列 */
    .changelog-confirm-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }

    .changelog-start-tag-select {
        width: 100%;
    }

    /* ChangeLog 結果彈窗 - 寬度與間距 */
    .changelog-result-body {
        padding: 0.75rem;
        font-size: 0.8125rem;
    }

    .changelog-edit-textarea {
        min-height: 250px;
        font-size: 0.75rem;
    }

    /* 一鍵切換彈窗 - 步驟更緊湊 */
    .batch-sm-step-header {
        flex-wrap: wrap;
    }

    .batch-sm-project-list {
        max-height: 180px;
    }

    /* 新增 Tag 彈窗 - 遞增類型堆疊 */
    .create-tag-increment-row {
        flex-wrap: wrap;
    }

    .create-tag-increment-row select.form-input {
        min-width: 0;
        width: 100%;
    }

    .create-tag-tip {
        width: 100%;
        margin-top: 0.25rem;
    }
}

/* ===== 小型手機尺寸 (max-width: 30rem / 480px) ===== */
@media (max-width: 30rem) {

    /* 頁籤 - 更緊湊 */
    .sc-tab {
        padding: 0.4375rem 0.5rem;
        font-size: 0.75rem;
        gap: 0.375rem;
    }

    .sc-tab i {
        font-size: 0.6875rem;
    }

    /* 工具列按鈕 - 更小 */
    #page-source-code .toolbar-right .btn {
        padding: 0.4375rem 0.625rem;
        font-size: 0.6875rem;
    }

    /* 卡片 - 縮圖縮小 */
    #sourceCodeTable tbody tr td:nth-child(1) .sc-thumb-cell {
        width: 38px;
        height: 38px;
    }

    /* 名稱字體稍小 */
    #sourceCodeTable tbody tr td:nth-child(2) .sc-name-cell a {
        font-size: 0.8125rem;
    }

    /* 分支 / Tag 徽章縮小 */
    #sourceCodeTable .sc-ref-badge {
        font-size: 0.625rem;
        padding: 0.125rem 0.375rem;
    }

    #sourceCodeTable .sc-view-btn,
    #sourceCodeTable .sc-edit-btn {
        width: 20px;
        height: 20px;
        font-size: 0.5625rem;
    }

    /* Submodule 欄位 - 縮小間距 */
    #sourceCodeTable tbody tr td:nth-child(5),
    #sourceCodeTable tbody tr td:nth-child(6),
    #sourceCodeTable tbody tr td:nth-child(7) {
        padding-top: 0.25rem;
    }

    #sourceCodeTable .sc-sha-short {
        font-size: 0.625rem;
    }

    /* 卡片整體更緊湊 */
    #sourceCodeTable tbody tr {
        padding: 0.625rem;
        column-gap: 0.5rem;
        row-gap: 0.25rem;
    }

    /* 審查按鈕 - 480px 時縮小 */
    #sourceCodeTable tbody tr td:nth-child(8) .sc-review-btn {
        width: 24px;
        height: 24px;
        font-size: 0.625rem;
    }

    /* Submodule 版本面板 - 更緊湊 */
    .sm-version-card {
        padding: 0.625rem 0.75rem;
    }

    .sm-version-card-tag {
        font-size: 0.875rem;
    }

    .sm-version-card-meta {
        gap: 0.5rem;
    }

    .sm-version-card-meta span {
        font-size: 0.625rem;
    }

    /* Submodule 區塊操作按鈕 */
    .sm-section-actions .btn-sm {
        padding: 0.25rem 0.5rem;
        font-size: 0.625rem;
    }

    /* Submodule 列表卡片 */
    .sc-ref-group {
        flex-direction: column;
        gap: 0.25rem;
    }

    .sc-ref-label {
        min-width: unset;
    }

    .sc-ref-list {
        gap: 0.25rem;
    }

    /* 一鍵切換彈窗 - 更緊湊 */
    .batch-sm-project-item {
        padding: 0.375rem 0.5rem;
        gap: 0.5rem;
    }

    .batch-sm-project-thumb {
        width: 28px;
        height: 28px;
    }

    .batch-sm-project-name {
        font-size: 0.75rem;
    }

    .batch-sm-project-sha {
        font-size: 0.625rem;
    }

    /* ChangeLog 結果 */
    .changelog-h3 {
        font-size: 0.8125rem;
    }

    .changelog-list li {
        font-size: 0.75rem;
        padding-left: 1rem;
    }
}
