/**
 * Media Picker Styles
 * 
 * @package ProofPoints_Story_Modal
 * @version 1.0.0
 */

/* Overlay - Must be higher than story modal (which uses 10100) */
.pp-media-picker-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999999;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding-top: 60px;
    backdrop-filter: blur(2px);
}

/* Modal */
.pp-media-picker-modal {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 900px;
    min-height: 500px;
    max-height: calc(100vh - 120px);
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    overflow: hidden;
    z-index: 1000000;
    position: relative;
}

/* Header */
.pp-media-picker-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}

.pp-media-picker-header h3 {
    margin: 0;
    font-family: 'Lexend Deca', sans-serif;
    font-size: 18px;
    font-weight: 500;
    color: #111827;
}

.pp-media-picker-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #6b7280;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all 0.2s;
}

.pp-media-picker-close:hover {
    background: #e5e7eb;
    color: #111827;
}

/* Tabs */
.pp-media-picker-tabs {
    display: flex;
    gap: 4px;
    padding: 12px 20px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
}

.pp-picker-tab {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: none;
    background: transparent;
    font-family: 'Lexend Deca', sans-serif;
    font-size: 13px;
    font-weight: 400;
    color: #6b7280;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

.pp-picker-tab:hover {
    background: #e5e7eb;
    color: #374151;
}

.pp-picker-tab.active {
    background: white;
    color: #111827;
    font-weight: 500;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.pp-picker-tab svg {
    opacity: 0.7;
}

.pp-picker-tab.active svg {
    opacity: 1;
}

/* Body - contains content and sidebar */
.pp-media-picker-body {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Content Area */
.pp-media-picker-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.pp-picker-tab-content {
    display: none;
}

.pp-picker-tab-content.active {
    display: block;
}

/* Media Grid */
.pp-media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
}

.pp-media-item {
    position: relative;
    aspect-ratio: 1;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.2s;
    background: #f3f4f6;
}

.pp-media-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.pp-media-item:hover {
    border-color: #3b82f6;
    transform: scale(1.02);
}

.pp-media-item.selected {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

.pp-media-item-check {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    background: #3b82f6;
    color: white;
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: bold;
}

.pp-media-item.selected .pp-media-item-check {
    display: flex;
}

/* Video specific */
.pp-media-item-video {
    position: relative;
}

.pp-media-video-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.pp-media-item-video:hover .pp-media-video-overlay {
    background: rgba(0, 0, 0, 0.8);
    transform: translate(-50%, -50%) scale(1.1);
}

.pp-media-duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-family: 'Lexend Deca', sans-serif;
}

/* Sidebar */
.pp-media-picker-sidebar {
    width: 220px;
    min-width: 220px;
    border-left: 1px solid #e5e7eb;
    padding: 20px;
    background: #f9fafb;
    overflow-y: auto;
}

.pp-media-picker-sidebar h4 {
    margin: 0 0 16px 0;
    font-family: 'Lexend Deca', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

#pp-selected-preview {
    margin-bottom: 16px;
}

#pp-selected-preview img {
    width: 100%;
    border-radius: 8px;
    margin-bottom: 8px;
}

.pp-selected-title {
    font-family: 'Lexend Deca', sans-serif;
    font-size: 13px;
    color: #6b7280;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pp-size-options,
.pp-alignment-options {
    margin-bottom: 16px;
}

.pp-size-options label,
.pp-alignment-options > label {
    display: block;
    font-family: 'Lexend Deca', sans-serif;
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
    margin-bottom: 6px;
}

#pp-media-size {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-family: 'Lexend Deca', sans-serif;
    font-size: 13px;
    color: #374151;
    background: white;
}

.pp-alignment-buttons {
    display: flex;
    gap: 4px;
}

.pp-alignment-buttons button {
    flex: 1;
    padding: 8px;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: #6b7280;
    transition: all 0.2s;
}

.pp-alignment-buttons button:hover {
    background: #f3f4f6;
}

.pp-alignment-buttons button.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
}

/* Video insert options */
.pp-video-insert-options {
    margin-top: 12px;
}

.pp-video-insert-options label {
    display: block;
    font-family: 'Lexend Deca', sans-serif;
    font-size: 12px;
    color: #6b7280;
    padding: 8px 0;
    cursor: pointer;
}

.pp-video-insert-options input[type="radio"] {
    margin-right: 8px;
}

/* Footer */
.pp-media-picker-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

.pp-footer-buttons {
    display: flex;
    gap: 12px;
}

.pp-btn {
    padding: 10px 20px;
    border-radius: 6px;
    font-family: 'Lexend Deca', sans-serif;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.pp-btn-secondary {
    background: white;
    border: 1px solid #d1d5db;
    color: #374151;
}

.pp-btn-secondary:hover {
    background: #f3f4f6;
}

.pp-btn-primary {
    background: #3b82f6;
    color: white;
}

.pp-btn-primary:hover {
    background: #2563eb;
}

.pp-btn-primary:disabled {
    background: #93c5fd;
    cursor: not-allowed;
}

/* External URL Tab */
.pp-external-url-form {
    max-width: 500px;
}

.pp-external-url-form label {
    display: block;
    font-family: 'Lexend Deca', sans-serif;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 8px;
}

#pp-external-url {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-family: 'Lexend Deca', sans-serif;
    font-size: 14px;
    margin-bottom: 16px;
    box-sizing: border-box;
}

#pp-external-url:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.pp-external-url-preview {
    min-height: 100px;
    background: #f9fafb;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 12px;
}

.pp-external-image-preview img {
    max-width: 100%;
    max-height: 200px;
    border-radius: 8px;
}

.pp-external-video-preview {
    position: relative;
}

.pp-external-video-preview img {
    width: 100%;
    max-width: 320px;
    border-radius: 8px;
}

.pp-video-overlay {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-family: 'Lexend Deca', sans-serif;
}

.pp-vimeo-placeholder {
    background: #1ab7ea;
    color: white;
    padding: 40px 20px;
    border-radius: 8px;
    text-align: center;
    font-family: 'Lexend Deca', sans-serif;
    font-size: 14px;
}

.pp-external-hint {
    font-family: 'Lexend Deca', sans-serif;
    font-size: 12px;
    color: #9ca3af;
    margin: 0;
}

.pp-preview-error {
    color: #dc2626;
    font-family: 'Lexend Deca', sans-serif;
    font-size: 13px;
}

.pp-preview-hint {
    color: #9ca3af;
    font-family: 'Lexend Deca', sans-serif;
    font-size: 13px;
}

/* Loading and Empty States */
.pp-media-loading,
.pp-media-empty,
.pp-media-error {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px 20px;
    font-family: 'Lexend Deca', sans-serif;
    font-size: 14px;
    color: #6b7280;
}

.pp-media-error {
    color: #dc2626;
}

/* Pagination */
.pp-media-pagination {
    display: flex;
    justify-content: flex-start;
}

.pp-media-pagination:empty {
    display: none;
}

.pp-pagination-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
}

.pp-pagination-btn {
    padding: 6px 12px;
    border: 1px solid #d1d5db;
    background: white;
    border-radius: 4px;
    font-family: 'Lexend Deca', sans-serif;
    font-size: 12px;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
}

.pp-pagination-btn:hover {
    background: #f3f4f6;
    border-color: #3b82f6;
}

.pp-pagination-info {
    font-family: 'Lexend Deca', sans-serif;
    font-size: 12px;
    color: #6b7280;
}

/* Inserted media styles (in TinyMCE content) */
.pp-inserted-image {
    border-radius: 4px;
}

.pp-video-link {
    display: inline-block;
    position: relative;
}

.pp-video-link::after {
    content: '▶';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
}

/* Video wrapper for responsive embeds */
.pp-video-wrapper {
    margin: 15px 0;
    border-radius: 8px;
    overflow: hidden;
}

.pp-video-wrapper iframe,
.pp-video-wrapper mux-player {
    border-radius: 8px;
}

/* Responsive */
@media (max-width: 768px) {
    .pp-media-picker-overlay {
        padding-top: 20px;
    }
    
    .pp-media-picker-modal {
        width: 95%;
        min-height: 400px;
        max-height: calc(100vh - 40px);
    }
    
    .pp-media-picker-body {
        flex-direction: column;
    }
    
    .pp-media-picker-sidebar {
        width: 100%;
        min-width: 100%;
        border-left: none;
        border-top: 1px solid #e5e7eb;
    }
    
    .pp-media-picker-tabs {
        flex-wrap: wrap;
    }
    
    .pp-picker-tab {
        padding: 6px 12px;
        font-size: 12px;
    }
    
    .pp-media-grid {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}
