/**
 * 後台響應式 - 品牌管理：表格卡片式佈局
 *
 * 由 admin-responsive.css 依原行序拆出；載入順序見 src/lib/assets.ts 的
 * ADMIN_STYLES，順序即 cascade 順序，不可調換。
 */

/* ==================== 品牌管理表格 - 卡片式佈局（優化版） ==================== */
@media (max-width: 48rem) {
    /* 品牌表格容器 */
    #brandsTableContainer {
        overflow-x: visible;
        background: transparent;
        border: none;
    }

    #brandsTable {
        min-width: unset;
        display: block;
    }

    #brandsTable thead {
        display: none;
    }

    #brandsTable tbody {
        display: flex;
        flex-direction: column;
        gap: 0.625rem;
    }

    #brandsTable tbody tr {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        padding: 1rem;
        background: linear-gradient(135deg, #1e1e1e, #1a1a1a);
        border-radius: 0.75rem;
        border: 1px solid rgba(255, 255, 255, 0.06);
        position: relative;
        transition-property: color, background-color, border-color, box-shadow, transform, opacity, scale, translate, rotate, filter;
        transition-duration: var(--motion-fast);
        transition-timing-function: var(--ease-out-quart);
        gap: 0.5rem 0.625rem;
        cursor: pointer;
    }

    #brandsTable tbody tr:hover {
        border-color: rgba(212, 165, 32, 0.3);
        background: linear-gradient(135deg, #252525, #1f1f1f);
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    }

    #brandsTable tbody tr:active {
        transform: translateY(0);
    }

    .light-theme #brandsTable tbody tr {
        background: linear-gradient(135deg, #ffffff, #fafafa);
        border-color: #e2e8f0;
    }

    .light-theme #brandsTable tbody tr:hover {
        border-color: rgba(212, 165, 32, 0.3);
        background: linear-gradient(135deg, #fafafa, #f5f5f5);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    }

    #brandsTable tbody tr td {
        border-bottom: none;
        padding: 0;
    }

    /* 分隔線 */
    #brandsTable tbody tr::before {
        content: '';
        order: 10;
        flex-basis: 100%;
        height: 0;
        margin-top: 0.5rem;
        border-top: 1px solid rgba(255, 255, 255, 0.06);
    }

    .light-theme #brandsTable tbody tr::before {
        border-top-color: rgba(0, 0, 0, 0.06);
    }

    /* ID - 隱藏 */
    #brandsTable tbody tr td:nth-child(1) {
        display: none;
    }

    /* 顯示名稱 - 主標題 */
    #brandsTable tbody tr td:nth-child(3) {
        order: 1;
    }

    #brandsTable tbody tr td:nth-child(3) .brand-display-name {
        font-weight: 600;
        font-size: 1rem;
        color: #f1f5f9;
    }

    .light-theme #brandsTable tbody tr td:nth-child(3) .brand-display-name {
        color: #1e293b;
    }

    /* 品牌代碼 - 樣式優化 */
    #brandsTable tbody tr td:nth-child(2) {
        order: 2;
    }

    #brandsTable tbody tr td:nth-child(2) .brand-code {
        font-size: 0.6875rem;
        padding: 0.25rem 0.5rem;
        background: rgba(212, 165, 32, 0.1);
        color: #f5c542;
        border-radius: 0.25rem;
    }

    .light-theme #brandsTable tbody tr td:nth-child(2) .brand-code {
        background: rgba(212, 165, 32, 0.1);
        color: #8b6914;
    }

    /* 狀態 - 第一行 */
    #brandsTable tbody tr td:nth-child(7) {
        order: 3;
    }

    #brandsTable tbody tr td:nth-child(7) .status-badge {
        font-size: 0.5625rem;
        padding: 0.25rem 0.5rem;
    }

    /* 操作按鈕 - 右側 */
    #brandsTable tbody tr td:nth-child(8) {
        order: 4;
        display: flex;
        align-items: center;
        gap: 0.375rem;
        margin-left: auto;
        position: relative;
        z-index: 2;
    }

    #brandsTable tbody tr td:nth-child(8) .btn-icon {
        width: 2rem;
        height: 2rem;
        border-radius: 0.5rem;
        font-size: 0.8125rem;
        background: rgba(255, 255, 255, 0.05);
        border: 1px solid rgba(255, 255, 255, 0.08);
        color: #94a3b8;
        transition-property: color, background-color, border-color, box-shadow, transform, opacity, scale, translate, rotate, filter;
        transition-duration: var(--motion-fast);
        transition-timing-function: var(--ease-out-quart);
        cursor: pointer;
        position: relative;
        z-index: 3;
    }

    #brandsTable tbody tr td:nth-child(8) .btn-icon:hover {
        background: rgba(212, 165, 32, 0.15);
        border-color: rgba(212, 165, 32, 0.3);
        color: #f5c542;
    }

    .light-theme #brandsTable tbody tr td:nth-child(8) .btn-icon {
        background: #f8fafc;
        border-color: #e2e8f0;
        color: #64748b;
    }

    .light-theme #brandsTable tbody tr td:nth-child(8) .btn-icon:hover {
        background: rgba(212, 165, 32, 0.1);
        border-color: rgba(212, 165, 32, 0.3);
        color: #d4a520;
    }

    /* Logo 圖片區域 - 第二行，橫向排列 */
    #brandsTable tbody tr td:nth-child(4),
    #brandsTable tbody tr td:nth-child(5),
    #brandsTable tbody tr td:nth-child(6) {
        order: 11;
        padding-top: 0.5rem;
        display: flex;
        align-items: center;
        gap: 0.5rem;
    }

    /* Logo 標籤 - 共用樣式 */
    #brandsTable tbody tr td:nth-child(4)::before,
    #brandsTable tbody tr td:nth-child(5)::before,
    #brandsTable tbody tr td:nth-child(6)::before {
        font-size: 0.5rem;
        font-weight: 600;
        background: rgba(255, 255, 255, 0.08);
        padding: 0.1875rem 0.375rem;
        border-radius: 0.25rem;
        color: #94a3b8;
        letter-spacing: 0.02em;
    }

    #brandsTable tbody tr td:nth-child(4)::before { content: '淺'; }
    #brandsTable tbody tr td:nth-child(5)::before { content: '深'; }
    #brandsTable tbody tr td:nth-child(6)::before { content: 'ico'; }

    .light-theme #brandsTable tbody tr td:nth-child(4)::before,
    .light-theme #brandsTable tbody tr td:nth-child(5)::before,
    .light-theme #brandsTable tbody tr td:nth-child(6)::before {
        background: #f1f5f9;
        color: #64748b;
    }

    /* Logo 預覽與佔位符樣式 */
    #brandsTable tbody tr td:nth-child(4) .logo-preview,
    #brandsTable tbody tr td:nth-child(5) .logo-preview,
    #brandsTable tbody tr td:nth-child(6) .logo-preview {
        width: 36px !important;
        height: 36px !important;
        object-fit: contain;
        border-radius: 0.375rem;
        background: #2a2a2a;
        padding: 0.25rem;
        border: 1px solid rgba(255, 255, 255, 0.06);
    }

    #brandsTable tbody tr td:nth-child(4) .logo-placeholder,
    #brandsTable tbody tr td:nth-child(5) .logo-placeholder,
    #brandsTable tbody tr td:nth-child(6) .logo-placeholder {
        width: 36px !important;
        height: 36px !important;
        border-radius: 0.375rem;
        background: linear-gradient(135deg, #2a2a2a, #1f1f1f);
        border: 1px dashed rgba(255, 255, 255, 0.1);
        display: flex;
        align-items: center;
        justify-content: center;
        color: #4b5563;
        font-size: 0.75rem;
    }

    .light-theme #brandsTable tbody tr td:nth-child(4) .logo-preview,
    .light-theme #brandsTable tbody tr td:nth-child(5) .logo-preview,
    .light-theme #brandsTable tbody tr td:nth-child(6) .logo-preview {
        background: #f8fafc;
        border-color: #e2e8f0;
    }

    .light-theme #brandsTable tbody tr td:nth-child(4) .logo-placeholder,
    .light-theme #brandsTable tbody tr td:nth-child(5) .logo-placeholder,
    .light-theme #brandsTable tbody tr td:nth-child(6) .logo-placeholder {
        background: linear-gradient(135deg, #f8fafc, #f1f5f9);
        border-color: #d1d5db;
        color: #9ca3af;
    }

    /* 品牌頁面排序按鈕 */
    #page-brands .mobile-sort-btn {
        display: flex;
    }

    /* 品牌頁面工具列按鈕 */
    #page-brands .toolbar-right .btn span {
        display: inline;
    }

    #page-brands .toolbar-right .btn {
        padding: 0.5rem 0.875rem;
        font-size: 0.8125rem;
        gap: 0.5rem;
        border-radius: 0.5rem;
    }

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

    /* 空狀態優化 */
    #brandsTable .empty-state {
        background: linear-gradient(135deg, #1e1e1e, #1a1a1a);
        border-radius: 0.75rem;
        border: 1px solid rgba(255, 255, 255, 0.06);
        padding: 2.5rem 1.5rem;
    }

    .light-theme #brandsTable .empty-state {
        background: linear-gradient(135deg, #ffffff, #fafafa);
        border-color: #e2e8f0;
    }
}

/* 品牌管理表格 - 小型手機優化 */
@media (max-width: 30rem) {
    #brandsTable tbody tr {
        padding: 0.875rem;
        gap: 0.375rem 0.5rem;
    }

    #brandsTable tbody tr td:nth-child(3) .brand-display-name {
        font-size: 0.9375rem;
    }

    #brandsTable tbody tr td:nth-child(2) .brand-code {
        font-size: 0.625rem;
        padding: 0.1875rem 0.375rem;
    }

    #brandsTable tbody tr td:nth-child(7) .status-badge {
        font-size: 0.5rem;
        padding: 0.1875rem 0.375rem;
    }

    #brandsTable tbody tr td:nth-child(8) .btn-icon {
        width: 1.75rem;
        height: 1.75rem;
        font-size: 0.75rem;
    }

    #brandsTable tbody tr td:nth-child(4) .logo-preview,
    #brandsTable tbody tr td:nth-child(5) .logo-preview,
    #brandsTable tbody tr td:nth-child(6) .logo-preview,
    #brandsTable tbody tr td:nth-child(4) .logo-placeholder,
    #brandsTable tbody tr td:nth-child(5) .logo-placeholder,
    #brandsTable tbody tr td:nth-child(6) .logo-placeholder {
        width: 32px !important;
        height: 32px !important;
    }

    #brandsTable tbody tr td:nth-child(4)::before,
    #brandsTable tbody tr td:nth-child(5)::before,
    #brandsTable tbody tr td:nth-child(6)::before {
        font-size: 0.4375rem;
        padding: 0.125rem 0.25rem;
    }

    #page-brands .toolbar-right .btn {
        padding: 0.4375rem 0.625rem;
        font-size: 0.75rem;
    }

    #page-brands .page-header h2 {
        font-size: 1.25rem;
    }

    #page-brands .page-header h2 i {
        font-size: 1rem;
        padding: 0.5rem;
    }
}
