/**
 * Frontend Styles for System Dokumentacji
 * Methodology: BEM
 */

.doc-explorer {
    width: 100%;
    margin: 20px 0;
    font-family: inherit;
}

/* Filter Form Layout */
.doc-explorer__filter {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    background-color: #fff;
    padding: 40px;
    margin-bottom: 30px;
    border: 1px solid #eee;
    flex-wrap: wrap;
    gap: 40px;
}

.doc-explorer__filter-info {
    flex: 1;
    min-width: 300px;
}

.doc-explorer__filter-title {
    margin: 0 0 10px 0;
    font-size: 28px;
    font-weight: 700;
    color: #222;
}

.doc-explorer__filter-desc {
    margin: 0;
    color: #777;
    font-size: 15px;
    line-height: 1.6;
}

.doc-explorer__filter-form-wrapper {
    flex: 1;
    min-width: 350px;
}

.doc-explorer__filter-form-title {
    margin: 0 0 20px 0;
    font-size: 14px;
    font-weight: 800;
    color: #222;
    letter-spacing: 1px;
}

.doc-explorer__filter-fields {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.doc-explorer__filter-select,
.doc-explorer__filter-input {
    background-color: #f2f2f2;
    border: 1px solid #f2f2f2;
    padding: 0 15px;
    font-size: 14px;
    color: #333;
    width: 100%;
    height: 50px;
    outline: none;
    border-radius: 4px;
    transition: border-color 0.2s;
}

.doc-explorer__filter-select:focus,
.doc-explorer__filter-input:focus {
    border-color: #58479b;
}

.doc-explorer__filter-select:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.doc-explorer__filter-separator {
    font-size: 11px;
    font-weight: 700;
    color: #999;
    text-align: center;
    margin: 5px 0;
}

.doc-explorer__filter-submit {
    background-color: #58479b;
    color: #fff;
    border: none;
    padding: 0 25px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: background-color 0.2s ease;
    height: 50px;
    width: 100%;
    border-radius: 4px;
    text-transform: uppercase;
}

.doc-explorer__filter-submit:hover {
    background-color: #45367a;
}

.doc-explorer__filter-submit .dashicons {
    font-size: 20px;
    width: 20px;
    height: 20px;
}

/* Loading Spinner */
.sd-loading-spinner {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #58479b;
    border-radius: 50%;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s, visibility 0.2s;
}

.sd-loading-spinner--visible {
    opacity: 1;
    visibility: visible;
    animation: sd-spin 1s linear infinite;
}

@keyframes sd-spin {
    0% { transform: translateY(-50%) rotate(0deg); }
    100% { transform: translateY(-50%) rotate(360deg); }
}

.doc-explorer__filter-select.sd-loading {
    padding-right: 45px;
}

/* Error Message */
.sd-error-message {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    padding: 12px 15px;
    margin-top: 10px;
    font-size: 14px;
    animation: sd-fadeIn 0.3s;
}

@keyframes sd-fadeIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Breadcrumbs */
.doc-explorer__breadcrumbs {
    margin-bottom: 20px;
    font-size: 14px;
    color: #666;
}

.doc-explorer__breadcrumb-item {
    text-decoration: none;
    color: #222;
    font-weight: 600;
}

.doc-explorer__breadcrumb-item:hover {
    text-decoration: underline;
}

.doc-explorer__breadcrumb-item--current {
    color: #888;
    font-weight: normal;
}

.doc-explorer__breadcrumb-sep {
    margin: 0 8px;
    color: #ccc;
}

.doc-explorer__breadcrumb-filters {
    font-size: 13px;
    color: #999;
    font-style: italic;
}

/* Table Styles */
.doc-explorer__table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

.doc-explorer__thead {
    background-color: #222;
    color: #fff;
}

.doc-explorer__th {
    padding: 15px 20px;
    text-align: left;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.doc-explorer__row {
    border-bottom: 1px solid #eee;
    transition: background-color 0.2s ease;
}

.doc-explorer__row:hover {
    background-color: #f9f9f9;
}

.doc-explorer__cell {
    padding: 15px 20px;
    vertical-align: middle;
    color: #333;
}

.doc-explorer__cell--name {
    display: flex;
    align-items: center;
}

.doc-explorer__cell--name .dashicons {
    margin-right: 12px;
    color: #555;
}

.doc-explorer__link {
    text-decoration: none;
    color: #222;
    font-weight: 600;
    display: flex;
    align-items: center;
}

.doc-explorer__link:hover {
    color: #000;
}

.doc-explorer__link--pdf {
    cursor: pointer;
    transition: color 0.2s ease;
}

.doc-explorer__link--pdf:hover {
    color: #58479b;
}

.doc-explorer__link--pdf:hover .dashicons {
    color: #58479b;
}

.doc-explorer__cell--size {
    color: #777;
    font-size: 14px;
}

.doc-explorer__cell--action {
    text-align: right;
}

/* Button Styles */
.doc-explorer__button {
    display: inline-block;
    padding: 8px 20px;
    border: 2px solid #222;
    background-color: #fff;
    color: #222;
    text-decoration: none;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.doc-explorer__button:hover {
    background-color: #222;
    color: #fff;
}

/* Pagination */
.doc-explorer__pagination {
    margin-top: 30px;
    padding: 20px;
    text-align: center;
    background-color: #fff;
    border: 1px solid #eee;
}

.doc-explorer__pagination .page-numbers {
    display: inline-block;
    padding: 8px 15px;
    margin: 0 5px;
    border: 1px solid #ddd;
    text-decoration: none;
    color: #333;
    font-weight: 600;
    transition: all 0.2s ease;
}

.doc-explorer__pagination .page-numbers:hover {
    background-color: #f5f5f5;
    border-color: #58479b;
    color: #58479b;
}

.doc-explorer__pagination .page-numbers.current {
    background-color: #58479b;
    color: #fff;
    border-color: #58479b;
}

/* Table Wrapper for Horizontal Scroll */
.doc-explorer__table-wrapper {
    width: 100%;
    position: relative;
}

/* Responsiveness */
@media screen and (max-width: 768px) {
    .doc-explorer__filter {
        padding: 20px;
        flex-direction: column;
    }

    .doc-explorer__filter-info,
    .doc-explorer__filter-form-wrapper {
        width: 100%;
        min-width: 0;
    }

    /* Horizontal Scroll Container */
    .doc-explorer__table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        position: relative;
        margin-bottom: 20px;
        background:
            linear-gradient(90deg, #fff 0%, rgba(255,255,255,0) 100%),
            linear-gradient(90deg, rgba(255,255,255,0) 0%, #fff 100%),
            linear-gradient(90deg, rgba(0,0,0,0.1) 0%, rgba(255,255,255,0) 40px),
            linear-gradient(-90deg, rgba(0,0,0,0.1) 0%, rgba(255,255,255,0) 40px);
        background-position: 0 0, 100% 0, 0 0, 100% 0;
        background-repeat: no-repeat;
        background-size: 40px 100%, 40px 100%, 40px 100%, 40px 100%;
        background-attachment: local, local, scroll, scroll;
    }

    /* Table stays as table but with min-width */
    .doc-explorer__table {
        min-width: 600px;
        margin-bottom: 0;
    }

    /* Sticky first column for better UX */
    .doc-explorer__cell--name,
    .doc-explorer__th:first-child {
        position: sticky;
        left: 0;
        background-color: #fff;
        z-index: 1;
    }

    .doc-explorer__thead .doc-explorer__th:first-child {
        background-color: #222;
    }

    /* Reduce padding for mobile */
    .doc-explorer__th {
        padding: 12px 15px;
        font-size: 12px;
        white-space: nowrap;
    }

    .doc-explorer__cell {
        padding: 12px 15px;
        font-size: 14px;
    }

    /* Add shadow to sticky column */
    .doc-explorer__cell--name::after,
    .doc-explorer__th:first-child::after {
        content: '';
        position: absolute;
        top: 0;
        right: -10px;
        bottom: 0;
        width: 10px;
        background: linear-gradient(90deg, rgba(0,0,0,0.08) 0%, transparent 100%);
        pointer-events: none;
    }

    /* Ensure button stays visible */
    .doc-explorer__button {
        font-size: 11px;
        padding: 6px 15px;
        white-space: nowrap;
    }

    /* Pagination adjustments */
    .doc-explorer__pagination {
        padding: 15px;
    }

    .doc-explorer__pagination .page-numbers {
        padding: 6px 12px;
        margin: 0 3px;
        font-size: 14px;
    }
}
