/* ==========================================================================
   KFile Download Manager — public styles v2.9.9
   Most layout uses inline styles for theme isolation.
   This file handles: hover states, accordion chevron, responsive collapse,
   standalone button, dark mode, and the notice/empty/pagination components.
   ========================================================================== */

.kfile-directory {
    --kfile-accent:        #2271b1;
    --kfile-accent-hover:  #135e96;
    --kfile-accent-rgb:    34, 113, 177;
    /* font-family intentionally omitted — inherits from active theme */
    margin: 0 0 2.5rem;
    container-type: inline-size;
}

.kfile-directory *, .kfile-directory *::before, .kfile-directory *::after {
    box-sizing: border-box;
}

/* ── Category chips ───────────────────────────────────────────────────────── */
.kfile-directory .kfile-cat-chip {
    display: inline-block;
    padding: .15rem .55rem;
    font-size: .68rem;
    font-weight: 600;
    color: #374151;
    background: #f3f4f6;
    border-radius: 999px;
    white-space: nowrap;
    line-height: 1.5;
}

/* ── Card hover ───────────────────────────────────────────────────────────── */
.kfile-directory .kfile-card {
    height: 100%;         /* fill grid cell so all cards in a row are equal height */
}
.kfile-directory .kfile-card:hover {
    border-color: #9ca3af !important;
    box-shadow: 0 4px 12px rgba(0,0,0,.08), 0 1px 3px rgba(0,0,0,.05) !important;
    transform: translateY(-2px);
}

/* ── Table row hover ──────────────────────────────────────────────────────── */
.kfile-directory .kfile-table-wrap tr:hover td,
.kfile-directory .kfile-table-wrap tbody tr:hover td {
    background: rgba(var(--kfile-accent-rgb), .03) !important;
}

/* ── Accordion chevron rotation ───────────────────────────────────────────── */
.kfile-acc-trigger.kfile-acc-open .kfile-acc-chevron {
    transform: rotate(180deg);
}

/* ── Search focus ring ────────────────────────────────────────────────────── */
.kfile-directory .kfile-search:focus {
    border-color: var(--kfile-accent) !important;
    box-shadow: 0 0 0 3px rgba(var(--kfile-accent-rgb), .12) !important;
    outline: none !important;
}

/* ── Select focus ring ────────────────────────────────────────────────────── */
.kfile-directory .kfile-select:focus {
    border-color: var(--kfile-accent) !important;
    box-shadow: 0 0 0 3px rgba(var(--kfile-accent-rgb), .12) !important;
    outline: none !important;
}

/* ── Source badges ────────────────────────────────────────────────────────── */
.kfile-badge {
    display: inline-block;
    padding: .1rem .45rem;
    border-radius: 999px;
    font-size: .65rem;
    font-weight: 700;
    letter-spacing: .04em;
    text-transform: uppercase;
    background: transparent !important;
    border: 1.5px solid transparent;
    line-height: 1.4;
}
.kfile-badge-media { color: #1d4ed8 !important; border-color: #93c5fd !important; }
.kfile-badge-drive { color: #166534 !important; border-color: #86efac !important; }

/* ── Empty state ──────────────────────────────────────────────────────────── */
.kfile-directory .kfile-empty-msg {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
    padding: 3.5rem 1.5rem;
    text-align: center;
    color: #9ca3af !important;
    font-size: .9rem;
    background: transparent !important;
    border: 1.5px dashed #e5e7eb;
    border-radius: 10px;
    margin-top: .5rem;
}

/* ── Notices ──────────────────────────────────────────────────────────────── */
.kfile-notice {
    padding: .75rem 1rem;
    background: transparent !important;
    border-left: 3px solid #d1d5db;
    border-radius: 0 6px 6px 0;
    color: #6b7280 !important;
    font-size: .875rem;
    margin: .5rem 0;
}
.kfile-error { color: #dc2626 !important; font-size: .85rem; }

/* ── Pagination ───────────────────────────────────────────────────────────── */
.kfile-directory .kfile-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .75rem;
    margin-top: 1.25rem;
    font-size: .875rem;
    color: #6b7280;
    width: 100%;
}
/* JS toggles display:none / '' — ensure flex is re-applied */
.kfile-directory .kfile-pagination:not([style*="display: none"]):not([style*="display:none"]) {
    display: flex !important;
}
.kfile-directory .kfile-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border: 1.5px solid #e5e7eb !important;
    border-radius: 6px;
    background: transparent !important;
    cursor: pointer;
    color: #6b7280 !important;
    font-size: 1.25rem;
    line-height: 1;
    padding: 0;
    transition: border-color .14s, color .14s;
}
.kfile-directory .kfile-page-btn:hover:not(:disabled) {
    border-color: var(--kfile-accent) !important;
    color: var(--kfile-accent) !important;
}
.kfile-directory .kfile-page-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ── Standalone [kfile_download] button ──────────────────────────────────── */
.kfile-download-btn {
    display: inline-flex;
    align-items: center;
    gap: .5rem;
    padding: .6rem 1.25rem;
    background: var(--kfile-accent, #2271b1) !important;
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 6px;
    font-size: .925rem;
    font-weight: 600;
    line-height: 1.3;
    cursor: pointer;
    border: none;
    transition: background 140ms, transform 100ms;
}
.kfile-download-btn:hover  { background: var(--kfile-accent-hover, #135e96) !important; color: #fff !important; }
.kfile-download-btn:active { transform: scale(.97); }
.kfile-btn-icon            { width: 1rem; height: 1rem; flex-shrink: 0; }

/* ── Responsive: collapse to 1 column on mobile ──────────────────────────── */
@media (max-width: 600px) {
    .kfile-directory .kfile-cards {
        grid-template-columns: 1fr !important;
    }
    .kfile-directory .kfile-table-wrap thead {
        display: none !important;
    }
    .kfile-directory .kfile-table-wrap tbody tr {
        display: block !important;
        border: 1.5px solid #e5e7eb !important;
        border-radius: 8px;
        margin-bottom: .75rem;
    }
    .kfile-directory .kfile-table-wrap tbody td {
        display: flex !important;
        align-items: center;
        padding: .6rem .875rem !important;
        border-bottom: 1px solid #f3f4f6 !important;
        border-top: none !important;
    }
    .kfile-directory .kfile-table-wrap tbody tr:last-child td:last-child {
        border-bottom: none !important;
    }
}

@media (min-width: 601px) and (max-width: 900px) {
    .kfile-directory .kfile-cards {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Container query fallback */
@container (max-width: 500px) {
    .kfile-cards { grid-template-columns: 1fr !important; }
}

/* ── Dark mode ────────────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
    .kfile-directory .kfile-card { border-color: #374151 !important; }
    .kfile-directory .kfile-card:hover { border-color: #6b7280 !important; }
    .kfile-directory .kfile-empty-msg { border-color: #374151; }
    .kfile-badge-media { color: #93c5fd !important; border-color: #1d4ed8 !important; }
    .kfile-badge-drive { color: #86efac !important; border-color: #166534 !important; }
    .kfile-directory .kfile-cat-chip { background: #1f2937 !important; color: #d1d5db !important; }
}
