/**
 * BBH File Download - Frontend Styles
 */

/* Variables */
:root {
    --bbh-primary: #2563eb;
    --bbh-primary-hover: #1d4ed8;
    --bbh-success: #10b981;
    --bbh-text: #1f2937;
    --bbh-text-light: #6b7280;
    --bbh-border: #e5e7eb;
    --bbh-bg: #f9fafb;
    --bbh-bg-hover: #f3f4f6;
    --bbh-radius: 8px;
    --bbh-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --bbh-shadow-hover: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Wrapper */
.bbh-files-wrapper {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    max-width: 100%;
}

/* Category Filter */
.bbh-category-filter {
    margin-bottom: 20px;
}

.bbh-category-filter select {
    padding: 10px 40px 10px 15px;
    font-size: 14px;
    border: 1px solid var(--bbh-border);
    border-radius: var(--bbh-radius);
    background-color: #fff;
    cursor: pointer;
    min-width: 200px;
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 10px center;
    background-repeat: no-repeat;
    background-size: 20px;
}

.bbh-category-filter select:focus {
    outline: none;
    border-color: var(--bbh-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Files List */
.bbh-files-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* File Item */
.bbh-file-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: #fff;
    border: 1px solid var(--bbh-border);
    border-radius: var(--bbh-radius);
    transition: all 0.2s ease;
}

.bbh-file-item:hover {
    border-color: var(--bbh-primary);
    box-shadow: var(--bbh-shadow-hover);
    transform: translateY(-1px);
}

/* File Icon */
.bbh-file-icon {
    flex-shrink: 0;
    width: 56px;
    height: 56px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bbh-primary), #3b82f6);
    border-radius: var(--bbh-radius);
    color: #fff;
}

.bbh-file-icon .dashicons {
    font-size: 24px;
    width: 24px;
    height: 24px;
}

.bbh-file-icon .bbh-file-ext {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    margin-top: 2px;
}

/* PDF icon */
.bbh-file-item[data-file-type="pdf"] .bbh-file-icon {
    background: linear-gradient(135deg, #dc2626, #ef4444);
}

/* DOC icon */
.bbh-file-item[data-file-type="doc"] .bbh-file-icon,
.bbh-file-item[data-file-type="docx"] .bbh-file-icon {
    background: linear-gradient(135deg, #2563eb, #3b82f6);
}

/* XLS icon */
.bbh-file-item[data-file-type="xls"] .bbh-file-icon,
.bbh-file-item[data-file-type="xlsx"] .bbh-file-icon {
    background: linear-gradient(135deg, #059669, #10b981);
}

/* ZIP icon */
.bbh-file-item[data-file-type="zip"] .bbh-file-icon,
.bbh-file-item[data-file-type="rar"] .bbh-file-icon {
    background: linear-gradient(135deg, #7c3aed, #8b5cf6);
}

/* Image icon */
.bbh-file-item[data-file-type="jpg"] .bbh-file-icon,
.bbh-file-item[data-file-type="jpeg"] .bbh-file-icon,
.bbh-file-item[data-file-type="png"] .bbh-file-icon {
    background: linear-gradient(135deg, #f59e0b, #fbbf24);
}

/* File Info */
.bbh-file-info {
    flex: 1;
    min-width: 0;
}

.bbh-file-title {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--bbh-text);
    line-height: 1.4;
}

.bbh-file-description {
    margin: 0 0 8px 0;
    font-size: 14px;
    color: var(--bbh-text-light);
    line-height: 1.5;
}

/* File Meta */
.bbh-file-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    font-size: 13px;
    color: var(--bbh-text-light);
}

.bbh-file-meta span {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.bbh-file-meta .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
    color: var(--bbh-text-light);
}

/* File Actions */
.bbh-file-actions {
    flex-shrink: 0;
}

.bbh-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: var(--bbh-primary);
    color: #fff !important;
    text-decoration: none !important;
    border-radius: var(--bbh-radius);
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
}

.bbh-download-btn:hover {
    background: var(--bbh-primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--bbh-shadow);
}

.bbh-download-btn .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

/* No Files Message */
.bbh-no-files {
    text-align: center;
    padding: 40px 20px;
    background: var(--bbh-bg);
    border-radius: var(--bbh-radius);
    color: var(--bbh-text-light);
    font-size: 15px;
}

/* Responsive */
@media (max-width: 768px) {
    .bbh-file-item {
        flex-wrap: wrap;
        padding: 16px;
    }

    .bbh-file-icon {
        width: 48px;
        height: 48px;
    }

    .bbh-file-icon .dashicons {
        font-size: 20px;
        width: 20px;
        height: 20px;
    }

    .bbh-file-info {
        flex: 1 1 calc(100% - 70px);
    }

    .bbh-file-actions {
        flex: 1 1 100%;
        margin-top: 12px;
    }

    .bbh-download-btn {
        width: 100%;
        justify-content: center;
    }

    .bbh-file-meta {
        gap: 12px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .bbh-files-wrapper {
        --bbh-text: #f9fafb;
        --bbh-text-light: #9ca3af;
        --bbh-border: #374151;
        --bbh-bg: #1f2937;
        --bbh-bg-hover: #374151;
    }

    .bbh-file-item {
        background: #1f2937;
    }

    .bbh-category-filter select {
        background-color: #1f2937;
        color: #f9fafb;
        border-color: var(--bbh-border);
    }
}

/* Animation */
@keyframes bbh-fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bbh-file-item {
    animation: bbh-fade-in 0.3s ease forwards;
}

.bbh-file-item:nth-child(1) {
    animation-delay: 0s;
}

.bbh-file-item:nth-child(2) {
    animation-delay: 0.05s;
}

.bbh-file-item:nth-child(3) {
    animation-delay: 0.1s;
}

.bbh-file-item:nth-child(4) {
    animation-delay: 0.15s;
}

.bbh-file-item:nth-child(5) {
    animation-delay: 0.2s;
}

.bbh-file-item:nth-child(6) {
    animation-delay: 0.25s;
}

.bbh-file-item:nth-child(7) {
    animation-delay: 0.3s;
}

.bbh-file-item:nth-child(8) {
    animation-delay: 0.35s;
}

.bbh-file-item:nth-child(9) {
    animation-delay: 0.4s;
}

.bbh-file-item:nth-child(10) {
    animation-delay: 0.45s;
}

/* =========================================
   TABLE LAYOUT STYLES
   ========================================= */

/* Table Wrapper */
.bbh-table-wrapper {
    overflow-x: auto;
    border-radius: var(--bbh-radius);
    border: 1px solid var(--bbh-border);
}

/* Files Table */
.bbh-files-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.bbh-files-table th,
.bbh-files-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--bbh-border);
    font-size: 14px;
    color: var(--bbh-text);
}

.bbh-files-table th {
    background: var(--bbh-bg);
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--bbh-text-light);
}

.bbh-files-table tbody tr:hover {
    background: var(--bbh-bg-hover);
}

.bbh-files-table tbody tr:last-child td {
    border-bottom: none;
}

/* Table File Cell */
.bbh-table-file {
    display: flex;
    align-items: center;
    gap: 12px;
}

.bbh-file-type-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--bbh-primary), #3b82f6);
    border-radius: 8px;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    flex-shrink: 0;
}

.bbh-file-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.bbh-file-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--bbh-text);
    line-height: 1.4;
    margin: 0;
}

.bbh-file-filename {
    font-size: 12px;
    color: var(--bbh-text-light);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Category Badge */
.bbh-category-badge {
    display: inline-block;
    padding: 4px 10px;
    background: var(--bbh-bg);
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--bbh-text);
}

/* Download Button (Table) */
.bbh-btn-download {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: var(--bbh-primary);
    color: #fff !important;
    text-decoration: none !important;
    border-radius: 6px;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.bbh-btn-download:hover {
    background: var(--bbh-primary-hover);
    transform: translateY(-1px);
}

.bbh-btn-download .dashicons {
    font-size: 14px;
    width: 14px;
    height: 14px;
}

/* Column Widths */
.bbh-files-table .col-file {
    min-width: 280px;
}

.bbh-files-table .col-category {
    width: 150px;
}

.bbh-files-table .col-size,
.bbh-files-table .col-downloads,
.bbh-files-table .col-date {
    width: 100px;
    white-space: nowrap;
}

.bbh-files-table .col-action {
    width: 140px;
    text-align: right;
}

/* =========================================
   GROUPED TABLE LAYOUT STYLES
   ========================================= */

.bbh-grouped-tables {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Category Section */
.bbh-category-section {
    background: #fff;
    border-radius: var(--bbh-radius);
    overflow: hidden;
    border: 1px solid var(--bbh-border);
    box-shadow: var(--bbh-shadow);
}

/* Category Header */
.bbh-category-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: linear-gradient(135deg, var(--bbh-bg), #fff);
    border-bottom: 1px solid var(--bbh-border);
    border-left: 4px solid var(--bbh-primary);
}

.bbh-category-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    color: #fff;
}

.bbh-category-icon .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.bbh-category-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--bbh-text);
    flex: 1;
}

.bbh-category-count {
    font-size: 13px;
    color: var(--bbh-text-light);
    background: var(--bbh-bg);
    padding: 4px 10px;
    border-radius: 20px;
}

/* Grouped table wrapper */
.bbh-category-section .bbh-table-wrapper {
    border: none;
    border-radius: 0;
}

/* Responsive Table */
@media (max-width: 768px) {

    .bbh-files-table th,
    .bbh-files-table td {
        padding: 12px;
    }

    .bbh-file-type-badge {
        width: 36px;
        height: 36px;
        font-size: 10px;
    }

    .bbh-files-table .col-file {
        min-width: 200px;
    }

    .bbh-files-table .col-category,
    .bbh-files-table .col-downloads,
    .bbh-files-table .col-date {
        display: none;
    }

    .bbh-category-header {
        padding: 12px 16px;
    }

    .bbh-category-header h3 {
        font-size: 14px;
    }
}

/* Dark Mode for Table */
@media (prefers-color-scheme: dark) {
    .bbh-files-table {
        background: #1f2937;
    }

    .bbh-category-section {
        background: #1f2937;
    }

    .bbh-category-header {
        background: linear-gradient(135deg, #374151, #1f2937);
    }
}