/* =================================================================
 * KCDownloads — frontend styles
 * =============================================================== */

.kcd-downloads {
    font-size: 16px;
    line-height: 1.4;
}

/* ---------- Category grid ---------- */
.kcd-category-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 12px;
}

@media (max-width: 1200px) { .kcd-category-grid { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 900px)  { .kcd-category-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 640px)  { .kcd-category-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 400px)  { .kcd-category-grid { grid-template-columns: 1fr; } }

/* ---------- Category card (grid item) ---------- */
.kcd-category-card {
    border: 1px solid #e2e6ea;
    border-radius: 6px;
    background: #fff;
    /* no grid-column: default is one cell */
    overflow: hidden;
    min-width: 0;
    transition: box-shadow .15s ease;
}
.kcd-category-card:hover {
    box-shadow: 0 2px 10px rgba(0, 0, 0, .06);
}

/* When expanded, take the full row so the file cards have space */
.kcd-category-card.is-open {
    grid-column: 1 / -1;
}
/* ---------- Category toggle button ---------- */
.kcd-category-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-width: 0;             /* key: allow the button to shrink */
    background: #fff;
    border: 0;
    padding: 18px 16px;
    cursor: pointer;
    font: inherit;
    color: inherit;
    text-align: left;
    min-height: 100px;
    box-sizing: border-box;
    transition: background .12s ease;
}
.kcd-category-toggle:hover {
    background: #fafbfc;
}
.kcd-category-toggle[disabled] {
    cursor: default;
}

/* ---------- Logo container ---------- */
.kcd-category-logo {
    display: flex !important;
    flex: 1 1 0;              /* basis 0, not auto — size by available space */
    min-width: 0;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    max-height: 60px;
    line-height: 0;           /* removes inline whitespace under the img */
}
.kcd-category-logo img {
    display: block !important;
    max-height: 55px !important;
    max-width: 100% !important;
    min-width: 0;
    width: auto !important;
    height: auto !important;
    object-fit: contain;
}

/* ---------- Chevron ---------- */
.kcd-chevron {
    flex: 0 0 auto;
    margin-left: 12px;
    color: #b8bfc6;
    font-size: 22px;
    width: 22px;
    height: 22px;
    transition: transform .15s ease, color .15s ease;
}
.kcd-category-card.is-open .kcd-chevron {
    transform: rotate(90deg);
    color: #4b5563;
}

/* ---------- Expanded panel ---------- */
.kcd-category-panel {
    border-top: 1px solid #e2e6ea;
    padding: 14px 16px 16px;
    background: #fafbfc;
}

.kcd-file-cards {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}
@media (max-width: 640px) {
    .kcd-file-cards { grid-template-columns: 1fr; }
}

/* ---------- Individual file card ---------- */
.kcd-file-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px;
    border: 1px solid #e2e6ea;
    border-radius: 6px;
    background: #fff;
}

.kcd-file-thumb {
    flex: 0 0 64px;
    width: 64px;
    height: 80px;
    border: 1px solid #e2e6ea;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    background: #fff;
}
.kcd-file-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.kcd-file-thumb .dashicons {
    font-size: 34px;
    width: 34px;
    height: 34px;
    color: #6b7280;
}

.kcd-file-meta {
    flex: 1 1 auto;
    min-width: 0;
}
.kcd-file-title {
    font-weight: 700;
    font-size: 15px;
    color: #111827;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.kcd-file-info {
    font-size: 13px;
    color: #6b7280;
}
.kcd-file-info .kcd-file-sep { margin: 0 4px; }

.kcd-file-download {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 4px;
    background: #2b5876;
    color: #fff;
    text-decoration: none;
    transition: background .15s ease;
}
.kcd-file-download:hover {
    background: #1d3f56;
    color: #fff;
}
.kcd-file-download .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

/* ---------- Password form ---------- */
.kcd-password-form {
    margin-top: 20px;
}
.kcd-password-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: bold;
}
.kcd-password-form input[type="password"] {
    padding: 5px;
    width: 220px;
    margin-right: 10px;
}
.kcd-password-form input[type="submit"] {
    padding: 6px 12px;
    background: #0073aa;
    color: #fff;
    border: none;
    cursor: pointer;
}
.kcd-password-form input[type="submit"]:hover {
    background: #005177;
}