/**
 * Media Content Management Styles
 * AI-generated images and videos management interface
 */

/* ============================================
   Container & Layout
   ============================================ */
.media-content-container {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding: 1rem 0;
}

/* ============================================
   Toggle Tabs
   ============================================ */
.media-tabs-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.media-toggle-tabs {
    display: flex;
    gap: 0.5rem;
    background: #f1f5f9;
    padding: 4px;
    border-radius: 12px;
    width: fit-content;
    height: 48px;
    box-sizing: border-box;
}

button.media-tab.media-tab-templates {
    background: linear-gradient(135deg, #0e1369 0%, #1e40af 100%);
    color: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(14, 19, 105, 0.25);
    transition: all 0.2s ease;
    flex-shrink: 0;
    height: 48px;
    box-sizing: border-box;
}

button.media-tab.media-tab-templates:hover {
    box-shadow: 0 4px 16px rgba(14, 19, 105, 0.35);
    background: linear-gradient(135deg, #0e1369 0%, #1e40af 100%);
    color: white;
    transform: translateY(-1px);
}

.media-tab {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1.5rem;
    border: none;
    background: transparent;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    height: 100%;
    box-sizing: border-box;
}

.media-tab:hover {
    color: #0e1369;
    background: rgba(14, 19, 105, 0.05);
}

.media-tab.active {
    background: white;
    color: #0e1369;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.media-tab i {
    font-size: 1.1rem;
}

.media-count {
    background: #e2e8f0;
    color: #64748b;
    padding: 0.25rem 0.625rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

.media-tab.active .media-count {
    background: #0e1369;
    color: white;
}

/* ============================================
   Toolbar - Search & Filters
   ============================================ */
.media-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.media-search {
    position: relative;
    flex: 1;
    min-width: 250px;
    max-width: 400px;
}

.media-search i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: #94a3b8;
}

.media-search input {
    width: 100%;
    padding: 0 1rem 0 2.75rem;
    height: 48px;
    box-sizing: border-box;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.2s ease;
}

.media-search input:focus {
    outline: none;
    border-color: #0e1369;
    box-shadow: 0 0 0 3px rgba(14, 19, 105, 0.1);
}

.media-filters {
    display: flex;
    gap: 0.75rem;
}

.media-filters select {
    padding: 0.75rem 2.5rem 0.75rem 1rem;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 0.9rem;
    background: white;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%2394a3b8'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
}

.media-filters select:focus {
    outline: none;
    border-color: #0e1369;
}

/* ============================================
   Loading & Empty States
   ============================================ */
.media-loading,
.media-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    color: #64748b;
    text-align: center;
}

.media-loading i,
.media-empty i {
    font-size: 3rem;
    margin-bottom: 1rem;
    color: #94a3b8;
}

.media-empty h3 {
    font-size: 1.25rem;
    color: #475569;
    margin-bottom: 0.5rem;
}

.media-empty p {
    color: #94a3b8;
    max-width: 400px;
}

/* ============================================
   Media Grid
   ============================================ */
.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
}

/* ============================================
   Media Card (Base)
   ============================================ */
.media-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid #e2e8f0;
    transition: all 0.3s ease;
    cursor: pointer;
}

.media-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
    border-color: #0e1369;
}

/* ============================================
   Media Thumbnail
   ============================================ */
.media-thumbnail {
    position: relative;
    aspect-ratio: 16 / 10;
    overflow: hidden;
    background: #f1f5f9;
}

.media-thumbnail img,
.media-thumbnail video.video-thumb-preview {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
    pointer-events: none;
}

.media-card:hover .media-thumbnail img,
.media-card:hover .media-thumbnail video.video-thumb-preview {
    transform: scale(1.05);
}

/* Video Play Button Overlay */
.video-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.media-card:hover .video-play-overlay {
    opacity: 1;
}

.play-button {
    width: 70px;
    height: 70px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease;
}

.play-button i {
    font-size: 1.75rem;
    color: #0e1369;
    margin-left: 4px;
}

.media-card:hover .play-button {
    transform: scale(1.1);
}

/* Video Duration Badge */
.video-duration {
    position: absolute;
    bottom: 0.75rem;
    right: 0.75rem;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Media Type Badge */
.media-type-badge {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    background: linear-gradient(135deg, #0e1369 0%, #1e40af 100%);
    color: white;
    padding: 0.375rem 0.75rem;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   Media Info
   ============================================ */
.media-info {
    padding: 1rem;
}

.media-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.media-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.8rem;
    color: #94a3b8;
}

.media-project {
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.media-date {
    font-weight: 500;
}

/* ============================================
   Video Modal
   ============================================ */
.video-modal,
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
}

.video-modal.active,
.image-modal.active {
    display: flex;
}

.video-modal-backdrop,
.image-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(4px);
}

.video-modal-content,
.image-modal-content {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 90vh;
    background: #1a1a1a;
    border-radius: 16px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.video-modal-close,
.image-modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 10;
    width: 40px;
    height: 40px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    color: white;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.video-modal-close:hover,
.image-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

/* Video Player */
.video-modal-player {
    background: black;
}

.video-modal-player video {
    max-width: 80vw;
    max-height: 70vh;
    display: block;
}

/* Image Viewer */
.image-modal-content img {
    max-width: 85vw;
    max-height: 75vh;
    object-fit: contain;
}

/* Modal Info */
.video-modal-info,
.image-modal-info {
    padding: 1.25rem 1.5rem;
    background: #1a1a1a;
    color: white;
}

.video-modal-info h3,
.image-modal-info h3 {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.375rem;
}

.video-modal-info p,
.image-modal-info p {
    font-size: 0.875rem;
    color: #94a3b8;
    margin-bottom: 1rem;
}

.video-modal-actions,
.image-modal-actions {
    display: flex;
    gap: 0.75rem;
}

.video-action-btn,
.image-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.video-action-btn:hover,
.image-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 768px) {
    .media-tabs-row {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }

    button.media-tab.media-tab-templates {
        width: 100%;
        justify-content: center;
        order: -1;
    }

    .media-toggle-tabs {
        width: 100%;
        gap: 0.25rem;
        padding: 3px;
    }
    
    .media-tab {
        flex: 1;
        justify-content: center;
        padding: 0.5rem 0.4rem;
        gap: 0.35rem;
        font-size: 0.8rem;
        min-width: 0;
        overflow: hidden;
    }

    .media-tab i {
        font-size: 0.95rem;
        flex-shrink: 0;
    }

    .media-tab span:not(.media-count) {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        min-width: 0;
    }

    .media-count {
        padding: 0.15rem 0.4rem;
        font-size: 0.7rem;
        flex-shrink: 0;
    }
    
    .media-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .media-search {
        max-width: none;
    }
    
    .media-filters {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .media-filters select {
        flex: 1;
        min-width: 0;
    }
    
    .media-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 1rem;
    }
    
    .video-modal-player video {
        max-width: 95vw;
    }
    
    .image-modal-content img {
        max-width: 95vw;
    }

    .video-modal-actions,
    .image-modal-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }

    .video-action-btn,
    .image-action-btn {
        justify-content: center;
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
        text-align: center;
    }

    .video-modal-info,
    .image-modal-info {
        padding: 1rem;
    }

    .video-modal-content,
    .image-modal-content {
        max-width: 95vw;
    }
}

@media (max-width: 400px) {
    .media-tab {
        padding: 0.5rem 0.25rem;
        gap: 0.25rem;
        font-size: 0.75rem;
    }

    .media-tab span:not(.media-count) {
        display: none;
    }

    .media-count {
        padding: 0.1rem 0.35rem;
        font-size: 0.65rem;
    }
}

/* ============================================
   Dark Mode Support
   ============================================ */
body.dark-mode .media-toggle-tabs {
    background: #1e293b;
}

body.dark-mode .media-tab {
    color: #94a3b8;
}

body.dark-mode .media-tab:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
}

body.dark-mode .media-tab.active {
    background: #334155;
    color: white;
}

body.dark-mode .media-count {
    background: #475569;
    color: #e2e8f0;
}

body.dark-mode .media-search input,
body.dark-mode .media-filters select {
    background: #1e293b;
    border-color: #334155;
    color: white;
}

body.dark-mode .media-card {
    background: #1e293b;
    border-color: #334155;
}

body.dark-mode .media-title {
    color: white;
}

body.dark-mode .media-thumbnail {
    background: #0f172a;
}

/* ============================================
   Select Button & Bulk Actions
   ============================================ */
.media-select-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.625rem 1rem;
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    color: #64748b;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.media-select-btn:hover {
    background: #e2e8f0;
    color: #0e1369;
}

.media-select-btn.active {
    background: #0e1369;
    color: white;
    border-color: #0e1369;
}

.media-bulk-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: #fef3c7;
    border: 1px solid #fcd34d;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.media-bulk-actions span {
    font-weight: 600;
    color: #92400e;
}

.bulk-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.5rem 0.875rem;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    color: #64748b;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.bulk-action-btn:hover {
    background: #f8fafc;
    color: #0e1369;
}

.bulk-action-btn.delete-btn {
    background: #fef2f2;
    border-color: #fecaca;
    color: #dc2626;
}

.bulk-action-btn.delete-btn:hover {
    background: #fee2e2;
}

/* ============================================
   Media Card Selection & Actions
   ============================================ */
.media-card {
    position: relative;
}

.media-card.select-mode {
    cursor: pointer;
}

.media-card.selected {
    outline: 3px solid #0e1369;
    outline-offset: -3px;
}

.media-card.selected .media-thumbnail::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(14, 19, 105, 0.1);
    pointer-events: none;
}

.media-checkbox {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    z-index: 10;
}

.media-checkbox input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #0e1369;
}

.media-card-actions {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    display: flex;
    gap: 0.375rem;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
}

.media-card:hover .media-card-actions {
    opacity: 1;
}

.media-card-actions .media-action-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.95);
    border: none;
    border-radius: 6px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.media-card-actions .media-action-btn:hover {
    background: white;
    color: #0e1369;
    transform: scale(1.1);
}

.media-card-actions .delete-btn:hover {
    background: #fef2f2;
    color: #dc2626;
}

.media-card-actions .edit-btn:hover {
    background: #eff6ff;
    color: #2563eb;
}

.media-card-actions .edit-canvas-btn:hover {
    background: #f0fdf4;
    color: #059669;
}

.edit-in-canvas-btn {
    background: rgba(5, 150, 105, 0.15) !important;
    color: #059669 !important;
    border: 1px solid rgba(5, 150, 105, 0.3) !important;
}

.edit-in-canvas-btn:hover {
    background: rgba(5, 150, 105, 0.3) !important;
    color: #047857 !important;
}

/* Dark mode adjustments */
body.dark-mode .media-select-btn {
    background: #1e293b;
    border-color: #334155;
    color: #94a3b8;
}

body.dark-mode .media-select-btn:hover {
    background: #334155;
    color: white;
}

body.dark-mode .media-bulk-actions {
    background: #422006;
    border-color: #854d0e;
}

body.dark-mode .media-bulk-actions span {
    color: #fbbf24;
}

body.dark-mode .bulk-action-btn {
    background: #1e293b;
    border-color: #334155;
    color: #94a3b8;
}

body.dark-mode .bulk-action-btn:hover {
    background: #334155;
    color: white;
}

body.dark-mode .media-card-actions .media-action-btn {
    background: rgba(30, 41, 59, 0.95);
    color: #94a3b8;
}

body.dark-mode .media-card-actions .media-action-btn:hover {
    background: #334155;
    color: white;
}

body.dark-mode .media-card-actions .edit-canvas-btn:hover {
    background: #064e3b;
    color: #34d399;
}

body.dark-mode .edit-in-canvas-btn {
    background: rgba(5, 150, 105, 0.2) !important;
    color: #34d399 !important;
    border: 1px solid rgba(52, 211, 153, 0.3) !important;
}

body.dark-mode .edit-in-canvas-btn:hover {
    background: rgba(5, 150, 105, 0.35) !important;
    color: #6ee7b7 !important;
}

/* ============================================
   Inline Filename Editing in Modal
   ============================================ */
.editable-filename {
    cursor: pointer;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.editable-filename:hover {
    background: rgba(255, 255, 255, 0.1);
}

.edit-hint {
    font-size: 0.75rem;
    margin-left: 0.5rem;
    opacity: 0.5;
    transition: opacity 0.2s ease;
}

.video-modal-info h3:hover .edit-hint,
.image-modal-info h3:hover .edit-hint {
    opacity: 1;
}

.inline-filename-edit {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
    font-weight: 600;
    color: white;
    outline: none;
    min-width: 200px;
}

.inline-filename-edit:focus {
    border-color: #60a5fa;
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.3);
}

.filename-extension {
    color: #94a3b8;
    font-size: 1rem;
    margin-left: 0.25rem;
}

.inline-save-btn,
.inline-cancel-btn {
    width: 32px;
    height: 32px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 0.5rem;
    transition: all 0.2s ease;
}

.inline-save-btn {
    background: #22c55e;
    color: white;
}

.inline-save-btn:hover {
    background: #16a34a;
}

.inline-cancel-btn {
    background: rgba(255, 255, 255, 0.1);
    color: #94a3b8;
}

.inline-cancel-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

.video-modal-info h3,
.image-modal-info h3 {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.25rem;
}

/* ============================================
   Files Tab — Agent-Generated Files
   ============================================ */

.files-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 4rem 2rem;
    color: #64748b;
    font-size: 1rem;
}

.files-loading i {
    font-size: 2rem;
    color: #0e1369;
}

.files-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 4rem 2rem;
    text-align: center;
    color: #94a3b8;
}

.files-empty i {
    font-size: 3rem;
    color: #cbd5e1;
}

.files-empty h3 {
    margin: 0;
    color: #475569;
    font-size: 1.15rem;
}

.files-empty p {
    margin: 0;
    font-size: 0.9rem;
    max-width: 360px;
}

.files-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 0.75rem;
}

.file-card {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    transition: all 0.2s ease;
    cursor: default;
}

.file-card:hover {
    border-color: #c7d2fe;
    box-shadow: 0 2px 12px rgba(14, 19, 105, 0.06);
}

.file-card-icon {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 12px;
    flex-shrink: 0;
    position: relative;
}

.file-card-icon i {
    font-size: 1.5rem;
    color: white;
}

.file-card-ext {
    font-size: 0.55rem;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.85);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

.file-card-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.file-card-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-card-desc {
    font-size: 0.82rem;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-card-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.78rem;
    color: #94a3b8;
    flex-wrap: wrap;
}

.file-card-meta i {
    font-size: 0.7rem;
    margin-right: 0.2rem;
}

.file-card-category {
    display: flex;
    align-items: center;
    background: #f1f5f9;
    padding: 0.15rem 0.5rem;
    border-radius: 6px;
    font-weight: 500;
    color: #475569;
}

.file-card-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-shrink: 0;
}

.file-download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border: none;
    background: #f1f5f9;
    border-radius: 10px;
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 1rem;
}

.file-download-btn:hover {
    background: #0e1369;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(14, 19, 105, 0.2);
}

@media (max-width: 640px) {
    .file-card {
        padding: 0.75rem 1rem;
    }

    .file-card-icon {
        width: 44px;
        height: 44px;
    }

    .file-card-icon i {
        font-size: 1.2rem;
    }

    .file-card-meta {
        gap: 0.5rem;
    }

    .file-download-btn {
        width: 36px;
        height: 36px;
    }
}
