/*!
 * File-EXT Frontend Minimal Styles
 * Designed to inherit theme styles for seamless integration
 * Author: Kristian Orozco (Kronnos)
 * Version: 1.3.2
 */

/* ==========================================================================
   Base Container - Inherits everything from theme
   ========================================================================== */

.fileext-container {
    width: 100%;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    color: inherit;
    background: inherit;
}

/* ==========================================================================
   Loading Indicator
   ========================================================================== */

.fileext-loading {
    padding: 2rem;
    text-align: center;
}

.fileext-spinner {
    border: 4px solid rgba(0, 0, 0, 0.1);
    border-left-color: #2271b1;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: fileext-spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

/* ==========================================================================
   Filter Controls - NEW
   ========================================================================== */

.fileext-filter-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 1.5rem;
    margin-bottom: 2rem;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.02), rgba(0, 0, 0, 0.04));
    border: 1px solid rgba(0, 0, 0, 0.1);
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.fileext-filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex: 1;
    min-width: 200px;
}

.fileext-filter-label {
    font-weight: 600;
    font-size: 0.9rem;
    color: inherit;
    margin-bottom: 0.25rem;
    display: block;
}

.fileext-folder-filter,
.fileext-search-input {
    padding: 0.6rem 0.8rem;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 0.375rem;
    font-family: inherit;
    font-size: 0.95rem;
    color: inherit;
    background: white;
    transition: all 0.2s ease;
    width: 100%;
}

.fileext-folder-filter:hover,
.fileext-search-input:hover {
    border-color: rgba(0, 0, 0, 0.3);
}

.fileext-folder-filter:focus,
.fileext-search-input:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.fileext-clear-filters {
    align-self: flex-end;
    padding: 0.6rem 1.2rem;
    background: #f0f0f0;
    border: 1px solid rgba(0, 0, 0, 0.2);
    border-radius: 0.375rem;
    font-family: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.fileext-clear-filters:hover {
    background: #e0e0e0;
    border-color: rgba(0, 0, 0, 0.3);
}

.fileext-clear-filters:active {
    transform: translateY(1px);
}

.fileext-clear-filters:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
    .fileext-filter-controls {
        flex-direction: column;
        padding: 1rem;
        gap: 1rem;
    }

    .fileext-filter-group {
        min-width: 100%;
    }

    .fileext-clear-filters {
        align-self: stretch;
        width: 100%;
    }
}

/* ==========================================================================
   Folder Structure
   ========================================================================== */

.fileext-folder-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.fileext-item {
    margin: 0.5rem 0;
}

/* Folder Details */
.fileext-folder-details {
    border: 1px solid currentColor;
    border-opacity: 0.2;
    border-radius: 0.25rem;
    padding: 0.75rem;
    background: rgba(0, 0, 0, 0.02);
    transition: all 0.2s ease;
}

.fileext-folder-details:hover {
    border-opacity: 0.4;
    background: rgba(0, 0, 0, 0.04);
}

.fileext-folder-details[open] {
    border-opacity: 0.3;
}

.fileext-folder-summary {
    cursor: pointer;
    font-weight: inherit;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    padding: 0;
    list-style: none;
    outline: none;
}

.fileext-folder-summary::-webkit-details-marker {
    display: none;
}

.fileext-folder-summary::marker {
    content: '';
}

.fileext-folder-summary:hover {
    opacity: 0.8;
}

.fileext-folder-summary:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

.fileext-folder-icon {
    font-size: 1.1em;
    min-width: 1.5rem;
    text-align: center;
}

.fileext-folder-name {
    flex-grow: 1;
    font-weight: 500;
}

.fileext-folder-count {
    font-size: 0.85em;
    opacity: 0.7;
    font-weight: normal;
}

.fileext-folder-content {
    margin: 1rem 0 0.5rem 1.5rem;
    padding-left: 1rem;
    border-left: 2px dotted currentColor;
    border-opacity: 0.3;
}

.fileext-folder-empty {
    margin: 1rem 0 0.5rem 1.5rem;
    padding-left: 1rem;
    opacity: 0.6;
    font-style: italic;
}

/* ==========================================================================
   File Items
   ========================================================================== */

.fileext-file-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border: 1px solid currentColor;
    border-opacity: 0.2;
    border-radius: 0.25rem;
    margin: 0.5rem 0;
    background: rgba(255, 255, 255, 0.5);
    transition: all 0.2s ease;
}

.fileext-file-item:hover {
    border-opacity: 0.4;
    background: rgba(255, 255, 255, 0.8);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.fileext-file-main {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-grow: 1;
    min-width: 0; /* For text overflow */
}

.fileext-file-icon {
    font-size: 1.2em;
    min-width: 1.5rem;
    text-align: center;
}

.fileext-file-name {
    font-weight: 500;
    word-break: break-word;
    hyphens: auto;
}

.fileext-file-meta {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-left: auto;
    text-align: right;
    font-size: 0.85em;
    opacity: 0.7;
    min-width: fit-content;
}

.fileext-file-size,
.fileext-file-date {
    white-space: nowrap;
}

.fileext-file-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* ==========================================================================
   Buttons - Inheriting WordPress/Theme button styles
   ========================================================================== */

.fileext-file-actions .button {
    font-family: inherit;
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
    line-height: 1.2;
    border-radius: 0.25rem;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    transition: all 0.2s ease;
    white-space: nowrap;
}

/* Fallback styles if theme doesn't define .button */
.fileext-file-actions .button:not([class*="wp-"]):not([class*="button-"]) {
    background-color: #0073aa;
    color: white;
    border: 1px solid #0073aa;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.fileext-file-actions .button:not([class*="wp-"]):not([class*="button-"]):hover {
    background-color: #005a87;
    border-color: #005a87;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.fileext-view-button {
    background-color: #2271b1;
    color: white;
    border-color: #2271b1;
}

.fileext-view-button:hover {
    background-color: #135e96;
    border-color: #135e96;
}

.fileext-download-button {
    background-color: #50575e;
    color: white;
    border-color: #50575e;
}

.fileext-download-button:hover {
    background-color: #3c434a;
    border-color: #3c434a;
}

/* ==========================================================================
   Empty State
   ========================================================================== */

.fileext-empty-state {
    text-align: center;
    padding: 3rem 1rem;
    opacity: 0.7;
}

.fileext-empty-state p {
    margin: 0;
    font-style: italic;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
    .fileext-file-item {
        flex-direction: column;
        align-items: stretch;
        gap: 0.5rem;
    }
    
    .fileext-file-main {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
    
    .fileext-file-meta {
        margin-left: 0;
        text-align: left;
        flex-direction: row;
        gap: 0.75rem;
    }
    
    .fileext-file-actions {
        width: 100%;
        justify-content: center;
    }
    
    .fileext-file-actions .button {
        flex: 1;
        justify-content: center;
        min-width: 0;
    }
    
    .fileext-folder-content {
        margin-left: 0.75rem;
        padding-left: 0.75rem;
    }
}

@media (max-width: 480px) {
    .fileext-container {
        font-size: 0.9rem;
    }
    
    .fileext-folder-details {
        padding: 0.5rem;
    }
    
    .fileext-file-item {
        padding: 0.5rem;
    }
    
    .fileext-file-actions {
        flex-direction: column;
        gap: 0.25rem;
    }
    
    .fileext-file-actions .button {
        width: 100%;
    }
}

/* ==========================================================================
   Accessibility Improvements
   ========================================================================== */

.fileext-folder-summary:focus-visible,
.fileext-file-actions .button:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .fileext-folder-details,
    .fileext-file-item,
    .fileext-file-actions .button {
        transition: none;
    }
    
    .fileext-file-item:hover {
        transform: none;
    }
}

/* Screen reader only content */
.screen-reader-text {
    position: absolute !important;
    clip: rect(1px, 1px, 1px, 1px);
    width: 1px !important;
    height: 1px !important;
    overflow: hidden;
}

/* ==========================================================================
   High Contrast Mode Support
   ========================================================================== */

@media (prefers-contrast: high) {
    .fileext-folder-details,
    .fileext-file-item {
        border-width: 2px;
        border-opacity: 1;
    }
    
    .fileext-file-actions .button {
        border-width: 2px;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .fileext-file-actions {
        display: none;
    }
    
    .fileext-folder-details {
        border: 1px solid #000;
        page-break-inside: avoid;
    }
    
    .fileext-file-item {
        border: 1px solid #000;
        margin: 0.25rem 0;
        page-break-inside: avoid;
    }
}