/**
 * KO Downloader - Frontend Styles
 *
 * Complements Bootstrap 4 for the file browser UI.
 * Includes all migrated inline styles from the legacy plugin.
 *
 * @package KO_Downloader
 * @since 2.0.0
 */

/* ==========================================================================
   1. MAIN WRAPPER
   ========================================================================== */

.ko-downloader-wrap {
    position: relative;
    max-width: 100%;
    margin: 0 auto;
    font-family: inherit;
}

.ko-downloader-wrap::after {
    content: '';
    display: table;
    clear: both;
}

/* ==========================================================================
   2. SEARCH BAR
   ========================================================================== */

.ko-search-bar {
    max-width: 300px;
    width: 100%;
    position: relative;
    z-index: 100;
}

.ko-search-bar .input-group {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    border-radius: 4px;
    overflow: hidden;
}

.ko-search-input {
    border: 1px solid #dee2e6 !important;
    font-size: 0.875rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.ko-search-input:focus {
    border-color: #5b73e8 !important;
    box-shadow: 0 0 0 0.15rem rgba(91, 115, 232, 0.15) !important;
}

.ko-search-bar .input-group-text {
    background-color: #f8f9fa !important;
    border: 1px solid #dee2e6 !important;
    border-left: 0 !important;
    color: #6c757d;
}

/* Search Results Dropdown */
.ko-search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 6px 6px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12);
    max-height: 400px;
    overflow-y: auto;
    z-index: 1050;
    animation: ko-dropdown-in 0.2s ease-out;
}

@keyframes ko-dropdown-in {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ko-search-results .ko-search-item {
    display: flex;
    align-items: center;
    padding: 10px 14px;
    text-decoration: none;
    color: #333;
    border-bottom: 1px solid #f1f3f5;
    transition: background-color 0.15s ease;
    gap: 10px;
}

.ko-search-results .ko-search-item:last-child {
    border-bottom: none;
}

.ko-search-results .ko-search-item:hover {
    background-color: #f0f4ff;
    color: #333;
    text-decoration: none;
}

.ko-search-results .ko-search-item i {
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.ko-search-item-name {
    font-weight: 600;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
    max-width: 60%;
}

.ko-search-item-info {
    font-size: 0.75rem;
    color: #8a98ac;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-left: auto;
}

.ko-search-no-results {
    padding: 14px;
    text-align: center;
    color: #8a98ac;
    font-size: 0.875rem;
}

.ko-search-loading {
    padding: 14px;
    text-align: center;
    color: #8a98ac;
    font-size: 0.875rem;
}

.ko-search-loading i {
    animation: ko-spin 1s linear infinite;
}

@keyframes ko-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   3. BREADCRUMB NAVIGATION
   ========================================================================== */

.ko-breadcrumb-nav {
    padding: 0.6rem 0;
    font-size: 0.9rem;
}

.ko-breadcrumb-nav a {
    color: #5b73e8;
    text-decoration: none;
    transition: color 0.2s ease;
}

.ko-breadcrumb-nav a:hover {
    color: #3b53c8;
}

.ko-breadcrumb-sep {
    color: #adb5bd;
    margin: 0 2px;
}

.ko-breadcrumb-current {
    color: #495057;
    font-weight: 600;
}

/* ==========================================================================
   4. FILE TABLE
   ========================================================================== */

/* Fix button styles (prevent theme overrides) */
.ko-downloader-wrap .btn {
    text-decoration: none !important;
    outline: none !important;
    box-shadow: none !important;
    border-width: 1px !important;
    border-style: solid !important;
    padding: 0.25rem 0.8rem !important;
    margin: 0 !important;
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px !important;
    border-radius: 50rem !important;
    font-weight: 500 !important;
    transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease !important;
    box-sizing: border-box !important;
    line-height: 1.5 !important;
}

.ko-downloader-wrap .btn:hover,
.ko-downloader-wrap .btn:focus,
.ko-downloader-wrap .btn:active,
.ko-downloader-wrap .btn:focus-visible {
    text-decoration: none !important;
    outline: none !important;
    box-shadow: none !important;
    padding: 0.25rem 0.8rem !important;
    margin: 0 !important;
    border-width: 1px !important;
    border-style: solid !important;
    box-sizing: border-box !important;
}

.ko-downloader-wrap a:not(.btn) {
    text-decoration: none !important;
    box-shadow: none !important;
    border: none !important;
    outline: none !important;
}

.ko-downloader-wrap a:not(.btn):hover,
.ko-downloader-wrap a:not(.btn):focus,
.ko-downloader-wrap a:not(.btn):active,
.ko-downloader-wrap a:not(.btn):focus-visible {
    outline: 0 !important;
    outline-offset: 0 !important;
    text-decoration: none !important;
    box-shadow: none !important;
    border: none !important;
    background-color: transparent !important;
}

.ko-file-table {
    margin-bottom: 0;
    background: #fff !important;
    border-collapse: collapse !important;
    width: 100% !important;
}

.ko-file-table thead th {
    border-top: none !important;
    border-bottom: 2px solid #dee2e6 !important;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #8a98ac !important;
    font-weight: 600;
    padding: 0.6rem 0.75rem !important;
    background-color: #f8f9fa !important;
}

.ko-downloader-wrap table.ko-file-table tbody tr {
    transition: background-color 0.15s ease;
    background-color: #ffffff !important;
}

.ko-downloader-wrap table.ko-file-table tbody tr:nth-child(even) {
    background-color: #f8f9fa !important;
}

.ko-downloader-wrap table.ko-file-table tbody tr:hover {
    background-color: #f1f3f5 !important;
}

.ko-file-table tbody td {
    vertical-align: middle;
    padding: 0.55rem 0.75rem !important;
    font-size: 0.9rem;
    background: transparent !important; /* Let TR background show */
    border-top: none !important;
    border-bottom: 1px solid #dee2e6 !important;
}

/* Folder rows */
.ko-front-folder td {
    padding: 0.65rem 0.75rem !important;
}

.ko-front-folder-link {
    font-weight: 600;
    text-decoration: none !important;
    color: #333 !important;
    transition: color 0.2s ease;
}

.ko-front-folder-link:hover {
    color: #5b73e8 !important;
    text-decoration: none !important;
}

.ko-front-folder-link i.fa-folder {
    color: #f0ad4e;
    margin-right: 4px;
    transition: transform 0.2s ease, color 0.2s ease;
}

.ko-front-folder-link:hover i.fa-folder {
    transform: scale(1.1);
    color: #e09a2f;
}

/* File rows */
.ko-front-file td:first-child i {
    margin-right: 4px;
    width: 18px;
    text-align: center;
}

/* ==========================================================================
   5. COPY LINK BUTTON & TOOLTIP
   ========================================================================== */

.ko-copy-link {
    display: inline-block;
    color: #adb5bd;
    font-size: 0.85rem;
    margin-left: 8px;
    text-decoration: none !important;
    transition: color 0.2s ease, transform 0.2s ease;
    position: relative;
    vertical-align: middle;
}

.ko-copy-link:hover {
    color: #5b73e8;
    transform: scale(1.15);
    text-decoration: none !important;
}

.ko-copied-tooltip {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%) translateY(4px);
    background: #333;
    color: #fff;
    font-size: 0.7rem;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 1000;
}

.ko-copied-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: #333;
}

.ko-copied-tooltip.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ==========================================================================
   6. FRESH BADGE
   ========================================================================== */

.ko-file-table sup.badge-danger,
.ko-front-folder sup.badge-danger,
.product-file-type sup.badge-danger {
    font-size: 0.6rem;
    font-weight: 600;
    vertical-align: super;
    margin-left: 4px;
    animation: ko-pulse-badge 2s ease-in-out infinite;
}

@keyframes ko-pulse-badge {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* ==========================================================================
   7. PRODUCT FILE TYPE (single file card) — migrated from legacy inline styles
   ========================================================================== */

.product-file-type .img-icon {
    width: 46px !important;
    height: 46px !important;
    line-height: 46px !important;
    font-weight: 600;
    border-radius: 50%;
    font-size: 25px !important;
    text-align: center !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.product-file-type .img-icon i.fa {
    width: 40px !important;
    height: 40px !important;
    text-align: center !important;
    line-height: 40px !important;
}

.product-file-type p,
.product-file-type span,
.product-file-type a {
    font-family: inherit;
}

.product-file-type .h5 {
    font-weight: 600;
    color: #282828;
}

/* ==========================================================================
   8. RGBA COLOR CLASSES — migrated from legacy inline styles
   ========================================================================== */

.primary-rgba {
    background-color: rgba(110, 129, 220, 0.1);
}

.secondary-rgba {
    background-color: rgba(113, 128, 147, 0.1);
}

.success-rgba {
    background-color: rgba(95, 194, 126, 0.1);
}

.danger-rgba {
    background-color: rgba(244, 68, 85, 0.1);
}

.warning-rgba {
    background-color: rgba(252, 193, 0, 0.1);
}

.info-rgba {
    background-color: rgba(114, 208, 251, 0.1);
}

.light-rgba {
    background-color: rgba(220, 221, 225, 0.1);
}

.dark-rgba {
    background-color: rgba(45, 54, 70, 0.1);
}

/* ==========================================================================
   9. LIST & TABLE LEGACY STYLES — migrated from legacy inline styles
   ========================================================================== */

.ko-downloader-wrap .list-unstyled {
    padding: 2em !important;
}

.ko-downloader-wrap .list-unstyled p {
    color: #8a98ac;
}

.tdclear {
    padding: 0 !important;
    margin: 0 !important;
    border-top: 0 !important;
}

.table.tableclear thead th {
    border-bottom: 1px !important;
}

.table a sup {
    font-weight: normal !important;
}

.table.hided {
    display: none;
}

.table.tableclear a {
    text-decoration: none !important;
    border: 0 !important;
    transition: none !important;
}

/* ==========================================================================
   10. CARD ENHANCEMENTS
   ========================================================================== */

.ko-downloader-wrap .card {
    border: 1px solid #e9ecef;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.04);
}

.ko-downloader-wrap .card-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
    padding: 0.75rem 1.25rem;
}

.ko-downloader-wrap .card-header h3 {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 600;
    color: #333;
}

.ko-downloader-wrap .card-header h3 i {
    margin-right: 6px;
    color: #5b73e8;
}

.ko-downloader-wrap .card-body {
    padding: 0;
}

/* Download button */
.ko-downloader-wrap .btn-primary {
    background-color: #5b73e8;
    border-color: #5b73e8;
    font-size: 0.8rem;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.ko-downloader-wrap .btn-primary:hover {
    background-color: #4a62d7;
    border-color: #4a62d7;
    box-shadow: 0 2px 6px rgba(91, 115, 232, 0.35);
}

/* ==========================================================================
   11. EMPTY STATE
   ========================================================================== */

.ko-empty-dir {
    text-align: center;
    color: #8a98ac;
    padding: 2rem 1rem;
    font-size: 0.95rem;
}

.ko-error {
    text-align: center;
    color: #dc3545;
    padding: 1rem;
    font-size: 0.9rem;
}

/* ==========================================================================
   12. RESPONSIVE
   ========================================================================== */

@media (max-width: 768px) {
    .ko-search-bar {
        float: none;
        max-width: 100%;
        margin-bottom: 0.75rem;
    }

    .ko-file-table thead {
        display: none;
    }

    .ko-file-table tbody tr.ko-front-file {
        display: flex;
        flex-wrap: wrap;
        padding: 0.5rem 0.75rem;
        border-bottom: 1px solid #dee2e6;
    }

    .ko-file-table tbody tr.ko-front-file td {
        border: none;
        padding: 0.2rem 0;
    }

    .ko-file-table tbody tr.ko-front-file td:first-child {
        width: 100%;
        font-weight: 600;
    }

    .ko-file-table tbody tr.ko-front-file td:nth-child(2) {
        width: 50%;
    }

    .ko-file-table tbody tr.ko-front-file td:nth-child(3) {
        width: 50%;
        text-align: right;
    }

    .ko-file-table tbody tr.ko-front-file td:last-child {
        width: 100%;
        text-align: right;
        padding-top: 0.3rem;
    }

    .ko-breadcrumb-nav {
        font-size: 0.8rem;
    }
}

/* ==========================================================================
   13. HASH HIGHLIGHT
   ========================================================================== */

.ko-highlight {
    background-color: rgba(255, 235, 59, 0.4) !important;
    transition: background-color 0.5s ease;
}

