/**
 * CT Organizer Dashboard - File Manager Styles
 * Version: 1.1 - Improved Toolbar Layout
 */

/* ========================================
   File Manager Container
   ======================================== */

.ctod-files-dashboard {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* ========================================
   File Stats Grid
   ======================================== */

.ctod-file-stats {
    margin-bottom: 30px;
}

/* ========================================
   File Toolbar - IMPROVED LAYOUT
   ======================================== */

.ctod-file-toolbar {
    background: #fff;
    border: 1px solid #dcdcde;
    border-radius: 8px;
    margin-bottom: 20px;
    overflow: hidden;
}

/* Main toolbar section */
.ctod-toolbar-main {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    gap: 15px;
}

.ctod-toolbar-section {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ctod-toolbar-left {
    flex-shrink: 0;
}

.ctod-toolbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Upload Button */
.ctod-upload-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
    padding: 8px 16px;
}

.ctod-upload-btn .dashicons {
    font-size: 18px;
}

/* View Toggle Buttons */
.ctod-view-toggle {
    display: flex;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
}

.ctod-view-btn {
    padding: 6px 10px;
    background: none;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ctod-view-btn:hover {
    background: #f6f7f7;
}

.ctod-view-btn.active {
    background: #2271b1;
    color: #fff;
}

.ctod-view-btn .dashicons {
    font-size: 18px;
}

/* Filter Toggle Button */
.ctod-filter-toggle {
    display: none; /* Hidden on desktop */
    padding: 8px 16px;
    background: #f6f7f7;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    cursor: pointer;
    align-items: center;
    gap: 6px;
    transition: all 0.2s ease;
}

.ctod-filter-toggle:hover {
    background: #e8e8e8;
}

.ctod-filter-toggle .dashicons {
    font-size: 18px;
    transition: transform 0.2s ease;
}

.ctod-filter-toggle.active .dashicons {
    transform: rotate(180deg);
}

/* Filters Container */
.ctod-toolbar-filters {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px 12px;
    flex-wrap: nowrap;
}

.ctod-toolbar-filters.collapsed {
    display: none;
}

.ctod-filter-select,
.ctod-search-input {
    padding: 8px 12px;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    font-size: 14px;
    background: #fff;
    transition: border-color 0.2s ease;
}

.ctod-filter-select {
    min-width: 140px;
    flex: 1;
    max-width: 200px;
}

.ctod-search-input {
    min-width: 180px;
    flex: 1.5;
    max-width: 300px;
}

.ctod-filter-select:focus,
.ctod-search-input:focus {
    outline: none;
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
}

/* Desktop: All on one line */
@media screen and (min-width: 993px) {
    .ctod-toolbar-filters {
        padding: 0;
        border-top: 1px solid #f0f0f1;
        padding: 12px 20px;
    }
}

/* Tablet: Show filter toggle, stack filters */
@media screen and (max-width: 992px) {
    .ctod-filter-toggle {
        display: inline-flex;
    }
    
    .ctod-toolbar-right {
        gap: 8px;
    }
    
    .ctod-toolbar-filters {
        border-top: 1px solid #f0f0f1;
        padding: 12px 20px;
        flex-wrap: wrap;
    }
    
    .ctod-filter-select,
    .ctod-search-input {
        flex: 1 1 calc(50% - 5px);
        min-width: 120px;
        max-width: none;
    }
}

/* Mobile: Stack everything */
@media screen and (max-width: 768px) {
    .ctod-toolbar-main {
        padding: 10px 15px;
        gap: 10px;
    }
    
    .ctod-upload-btn .ctod-btn-text {
        display: none; /* Show only icon */
    }
    
    .ctod-toolbar-filters {
        padding: 10px 15px;
        gap: 8px;
    }
    
    .ctod-filter-select,
    .ctod-search-input {
        flex: 1 1 100%;
        max-width: none;
    }
}

/* Extra small mobile */
@media screen and (max-width: 480px) {
    .ctod-file-toolbar {
        border-radius: 6px;
    }
    
    .ctod-toolbar-main {
        flex-wrap: wrap;
    }
    
    .ctod-toolbar-left,
    .ctod-toolbar-right {
        width: 100%;
        justify-content: space-between;
    }
    
    .ctod-filter-toggle {
        width: 100%;
        justify-content: center;
        margin-top: 10px;
    }
}

/* ========================================
   Upload Modal
   ======================================== */

.ctod-upload-area {
    border: 2px dashed #8c8f94;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: #f6f7f7;
}

.ctod-upload-area:hover {
    border-color: #2271b1;
    background: #f0f6fc;
}

.ctod-upload-area.dragover {
    border-color: #2271b1;
    background: #e6f2ff;
    border-style: solid;
}

.ctod-upload-area .dashicons {
    font-size: 64px;
    color: #8c8f94;
    margin-bottom: 10px;
}

.ctod-upload-area p {
    margin: 10px 0;
    color: #50575e;
}

.ctod-upload-hint {
    font-size: 12px;
    color: #8c8f94;
}

.ctod-upload-queue {
    margin-top: 20px;
    max-height: 300px;
    overflow-y: auto;
}

.ctod-upload-item {
    display: flex;
    align-items: center;
    padding: 12px;
    background: #f6f7f7;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    margin-bottom: 8px;
    position: relative;
}

.ctod-upload-icon {
    font-size: 32px;
    color: #50575e;
    margin-right: 12px;
    flex-shrink: 0;
}

.ctod-upload-info {
    flex: 1;
    min-width: 0;
}

.ctod-upload-name {
    font-weight: 500;
    color: #1e1e1e;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ctod-upload-size {
    font-size: 12px;
    color: #8c8f94;
}

.ctod-upload-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    background: #dcdcde;
    color: #1e1e1e;
    margin-right: 8px;
    flex-shrink: 0;
}

.ctod-upload-remove {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #8c8f94;
    transition: color 0.2s ease;
    flex-shrink: 0;
}

.ctod-upload-remove:hover {
    color: #d63638;
}

.ctod-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #dcdcde;
}

.ctod-modal-footer .ctod-btn {
    min-width: 100px;
    padding: 8px 16px;
}

/* ========================================
   File Grid View
   ======================================== */

.ctod-file-container {
    min-height: 400px;
}

.ctod-file-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    padding: 20px;
    background: #fff;
    border: 1px solid #dcdcde;
    border-radius: 8px;
}

.ctod-file-card {
    background: #fff;
    border: 1px solid #dcdcde;
    border-radius: 8px;
    padding: 15px;
    transition: all 0.2s ease;
    cursor: pointer;
    position: relative;
}

.ctod-file-card:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-color: #2271b1;
}

.ctod-file-preview {
    width: 100%;
    height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f6f7f7;
    border-radius: 6px;
    margin-bottom: 12px;
    position: relative;
    overflow: hidden;
}

.ctod-file-preview .dashicons {
    font-size: 64px;
    color: #8c8f94;
}

.ctod-file-category {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255,255,255,0.95);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    text-transform: capitalize;
    color: #50575e;
    border: 1px solid #dcdcde;
}

.ctod-file-info {
    margin-bottom: 10px;
}

.ctod-file-name {
    font-weight: 500;
    color: #1e1e1e;
    margin-bottom: 6px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 14px;
}

.ctod-file-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #8c8f94;
    gap: 8px;
}

.ctod-file-event {
    display: block;
    margin-top: 6px;
    font-size: 12px;
    color: #2271b1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ctod-file-actions {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid #f0f0f1;
}

.ctod-file-btn {
    background: none;
    border: none;
    padding: 6px;
    cursor: pointer;
    color: #50575e;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    text-decoration: none;
    border-radius: 4px;
}

.ctod-file-btn:hover {
    color: #2271b1;
    background: #f6f7f7;
}

.ctod-file-delete:hover {
    color: #d63638 !important;
}

.ctod-file-btn .dashicons {
    font-size: 18px;
}

/* ========================================
   Image Preview
   ======================================== */

.ctod-file-preview-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 4px;
}

.ctod-file-preview-clickable {
    cursor: pointer;
    position: relative;
}

.ctod-file-preview-clickable::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0);
    transition: background 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    border-radius: 6px;
}

.ctod-file-preview-clickable:hover::after {
    content: '🔍';
    background: rgba(0,0,0,0.4);
}

/* Image Modal */
.ctod-image-modal {
    display: none;
    position: fixed;
    z-index: 999999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0);
    transition: background 0.3s ease;
}

.ctod-image-modal.active {
    background: rgba(0,0,0,0.9);
}

.ctod-image-modal-backdrop {
    position: absolute;
    inset: 0;
    cursor: pointer;
}

.ctod-image-modal-content {
    position: relative;
    margin: auto;
    padding: 60px 20px 20px;
    width: 90%;
    max-width: 1200px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ctod-image-modal.active .ctod-image-modal-content {
    opacity: 1;
}

.ctod-image-modal-content img {
    width: 100%;
    height: auto;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.3);
}

.ctod-image-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255,255,255,0.1);
    color: #fff;
    font-size: 36px;
    font-weight: bold;
    cursor: pointer;
    z-index: 1;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
}

.ctod-image-modal-close:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.5);
}

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

.ctod-empty-state {
    text-align: center;
    padding: 60px 20px;
    background: #fff;
    border: 1px solid #dcdcde;
    border-radius: 8px;
}

.ctod-empty-state .dashicons {
    font-size: 80px;
    color: #dcdcde;
    margin-bottom: 20px;
}

.ctod-empty-state h3 {
    margin: 0 0 10px;
    color: #50575e;
    font-size: 20px;
}

.ctod-empty-state p {
    margin: 0 0 20px;
    color: #8c8f94;
}

/* ========================================
   Loading State
   ======================================== */

.ctod-loading {
    text-align: center;
    padding: 60px 20px;
    background: #fff;
    border: 1px solid #dcdcde;
    border-radius: 8px;
}

.ctod-spinner {
    width: 40px;
    height: 40px;
    margin: 0 auto 20px;
    border: 4px solid #f0f0f1;
    border-top: 4px solid #2271b1;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

.ctod-loading p {
    color: #50575e;
}

/* ========================================
   Storage Breakdown
   ======================================== */

.ctod-storage-breakdown {
    margin-top: 30px;
    padding: 20px;
    background: #fff;
    border: 1px solid #dcdcde;
    border-radius: 8px;
}

.ctod-storage-breakdown h3 {
    margin: 0 0 20px;
    font-size: 16px;
    color: #1e1e1e;
    font-weight: 600;
}

.ctod-storage-bars {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ctod-storage-bar-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ctod-storage-bar-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 14px;
}

.ctod-category-name {
    font-weight: 500;
    color: #1e1e1e;
    text-transform: capitalize;
}

.ctod-category-size {
    color: #50575e;
    font-weight: 500;
}

.ctod-storage-bar-track {
    width: 100%;
    height: 10px;
    background: #f0f0f1;
    border-radius: 5px;
    overflow: hidden;
}

.ctod-storage-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #2271b1, #4a9bd8);
    border-radius: 5px;
    transition: width 0.5s ease;
}

.ctod-storage-bar-stats {
    font-size: 12px;
    color: #8c8f94;
}

.ctod-no-data {
    color: #8c8f94;
    font-style: italic;
}

/* ========================================
   Responsive Grid
   ======================================== */

@media screen and (max-width: 1200px) {
    .ctod-file-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

@media screen and (max-width: 768px) {
    .ctod-files-dashboard {
        padding: 15px;
    }
    
    .ctod-file-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 15px;
        padding: 15px;
    }
}

@media screen and (max-width: 480px) {
    .ctod-file-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
        gap: 12px;
        padding: 12px;
    }
    
    .ctod-file-card {
        padding: 12px;
    }
    
    .ctod-file-preview {
        height: 120px;
    }
}

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

.ctod-file-card:focus,
.ctod-file-btn:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

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

@media print {
    .ctod-file-toolbar,
    .ctod-file-actions {
        display: none;
    }
}