/**
 * TVK Unified Modal System CSS
 * 
 * This file provides modern, responsive styling for the unified modal system
 * with smooth transitions and professional appearance.
 */

/* Modal Container */
.tvk-modals-container {
    position: relative;
    z-index: 10000;
}

/* Base Modal Styles */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    z-index: 10001;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Ensure modal displays properly when shown */
.modal.show,
.modal.active,
.modal[style*="display: flex"],
.modal[style*="display: block"] {
    display: flex !important;
    align-items: center;
    justify-content: center;
}

/* Ensure modal content is properly sized and positioned */
.modal-wrapper {
    width: 90%;
    max-width: 1200px;
    height: 90%;
    max-height: 800px;
    overflow: hidden;
    position: relative;
}

.modal-body-wrapper {
    display: flex;
    gap: 20px;
    padding: 20px;
    height: calc(100% - 80px); /* Subtract header height */
    overflow: hidden;
    position: relative;
}

.modal-sidebar {
    flex: 0 0 200px;
    overflow-y: auto;
    position: relative;
}

.modal-main-content {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    position: relative;
}

.video-section {
    height: 100%;
    position: relative;
}

.video-player-container {
    height: 100%;
    min-height: 400px;
    position: relative;
}

/* Fix modal positioning and sizing issues */
.modal {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 999999 !important;
}

/* Ensure modal content is always visible */
.modal.show .modal-wrapper,
.modal.active .modal-wrapper,
.modal[style*="display: flex"] .modal-wrapper,
.modal[style*="display: block"] .modal-wrapper {
    position: relative !important;
    z-index: 1000000 !important;
    max-height: 90vh !important;
    max-width: 90vw !important;
    overflow: visible !important;
    transform: none !important;
}

/* Fix any content overflow issues */
.modal-body-wrapper {
    overflow: visible !important;
    max-height: calc(90vh - 120px) !important;
}

.modal-sidebar,
.modal-main-content {
    overflow: visible !important;
}

/* Ensure video player is always visible */
.video-player-container {
    overflow: visible !important;
    max-height: calc(90vh - 200px) !important;
}

/* Fix accordion content visibility */
.accordion-content.show {
    overflow: visible !important;
    max-height: none !important;
}

/* Additional fixes for modal content visibility */
.modal * {
    box-sizing: border-box;
}

/* Ensure no content is clipped */
.modal-wrapper,
.modal-content,
.modal-body-wrapper,
.modal-sidebar,
.modal-main-content {
    clip: auto !important;
    clip-path: none !important;
}

/* Fix any potential viewport issues */
@media screen and (max-height: 600px) {
    .modal-wrapper {
        max-height: 95vh !important;
    }
    
    .modal-body-wrapper {
        max-height: calc(95vh - 120px) !important;
    }
}

/* Ensure modal is always on top */
.modal.show,
.modal.active {
    z-index: 999999 !important;
    position: fixed !important;
}

/* Fix header positioning */
.modal-header {
    position: sticky !important;
    top: 0 !important;
    z-index: 1000001 !important;
    border-radius: 20px 20px 0 0 !important;
}

/* Ensure content areas are properly sized */
.modal-sidebar.left,
.modal-sidebar.right {
    min-height: 400px !important;
    max-height: calc(90vh - 120px) !important;
}

.modal-main-content {
    min-height: 400px !important;
    max-height: calc(90vh - 120px) !important;
}

.modal.show,
.modal[style*="display: block"],
.modal[style*="display: flex"] {
    opacity: 1;
    visibility: visible;
}

/* Modal Wrapper */
.modal-wrapper,
.modal-content {
    background: white;
    border-radius: 16px;
    max-width: 90%;
    max-height: 90%;
    overflow: hidden;
    position: relative;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.1);
    transform: scale(0.9) translateY(-20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal.show .modal-wrapper,
.modal.show .modal-content,
.modal[style*="display: block"] .modal-wrapper,
.modal[style*="display: block"] .modal-content,
.modal[style*="display: flex"] .modal-wrapper,
.modal[style*="display: flex"] .modal-content {
    transform: scale(1) translateY(0);
}

/* Modal Header */
.modal-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 24px 30px;
    border-radius: 16px 16px 0 0;
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Template Switcher */
.template-switcher {
    display: inline-block;
    margin-right: 15px;
}

.modal-template-selector {
    padding: 8px 16px;
    font-size: 13px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    min-width: 180px;
    font-weight: 500;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
}

.modal-template-selector:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.6);
    background: rgba(255, 255, 255, 0.2);
}

.modal-template-selector option {
    background: #2c3e50;
    color: white;
}

/* Refresh Button */
.refresh-playlist {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
    color: white;
    font-weight: 600;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    gap: 8px;
}

.refresh-playlist:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

.refresh-playlist:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.refresh-playlist.refreshing {
    background: rgba(255, 255, 255, 0.4);
}

.refresh-playlist .dashicons {
    font-size: 16px;
}

.refresh-playlist .dashicons.spinning {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Modal Close Button */
.modal-close {
    position: absolute;
    top: 20px;
    right: 25px;
    font-size: 28px;
    cursor: pointer;
    color: white;
    z-index: 1000;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    backdrop-filter: blur(10px);
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Modal Body */
.modal-body-wrapper,
.modal-body {
    padding: 30px;
    background: #fafbfc;
    max-height: 70vh;
    overflow-y: auto;
}

/* Template Loading Overlay */
.template-loading-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    background: rgba(255, 255, 255, 0.9);
}

.loading-spinner {
    text-align: center;
    color: #667eea;
}

.loading-spinner .dashicons {
    font-size: 48px;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
    display: block;
}

.loading-text {
    font-size: 16px;
    color: #666;
    font-weight: 500;
}

/* Template Content */
.template-content {
    animation: fadeIn 0.3s ease-in-out;
}

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

.template-header {
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid #e9ecef;
}

.template-header h3 {
    margin: 0 0 5px 0;
    color: #2c3e50;
    font-size: 20px;
    font-weight: 600;
}

.template-header p {
    margin: 0;
    color: #6c757d;
    font-size: 14px;
}

/* Video Section */
.video-section {
    margin-bottom: 30px;
}

.video-player-container {
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    position: relative;
}

#mainVideoPlayer {
    width: 100%;
    height: auto;
    border-radius: 12px;
}

/* Playlist Section */
.playlist-section {
    background: white;
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.05);
}

.playlist-items {
    max-height: 400px;
    overflow-y: auto;
}

.playlist-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 10px;
    border: 1px solid #e9ecef;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.playlist-item:hover {
    background: white;
    border-color: #667eea;
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.15);
}

.playlist-item-thumbnail {
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.playlist-item-thumbnail .dashicons {
    color: white;
    font-size: 20px;
}

.playlist-item-content h4 {
    margin: 0 0 5px 0;
    font-size: 14px;
    font-weight: 600;
    color: #2c3e50;
}

.playlist-item-content p {
    margin: 0;
    font-size: 12px;
    color: #6c757d;
}

/* Messages */
.tvk-message {
    padding: 12px 20px;
    margin: 0 20px 15px 20px;
    border-radius: 8px;
    text-align: center;
    font-weight: 600;
    font-size: 14px;
    animation: slideInDown 0.3s ease-out;
}

.tvk-message-success {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
}

.tvk-message-error {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
}

.tvk-message-info {
    background: linear-gradient(135deg, #17a2b8 0%, #138496 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(23, 162, 184, 0.3);
}

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

/* Choice Buttons */
.choice-buttons {
    display: flex;
    gap: 30px;
    justify-content: center;
    padding: 20px 0;
}

.choice-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px 25px;
    border: none;
    border-radius: 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    text-decoration: none;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    min-width: 180px;
    box-shadow: 0 8px 32px rgba(102, 126, 234, 0.3);
    position: relative;
    overflow: hidden;
}

.choice-button::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.choice-button:hover::before {
    left: 100%;
}

.choice-button:hover {
    transform: translateY(-8px) scale(1.05);
    box-shadow: 0 20px 40px rgba(102, 126, 234, 0.4);
}

.choice-button i {
    font-size: 40px;
    margin-bottom: 15px;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.choice-button span {
    font-size: 16px;
    font-weight: 600;
    text-align: center;
    line-height: 1.3;
}

/* Form Styling */
.form-group {
    margin-bottom: 25px;
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 15px 18px;
    border: 2px solid #e1e8ed;
    border-radius: 12px;
    font-size: 15px;
    background: #f8f9fa;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.15);
    transform: translateY(-1px);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.6;
}

.form-actions {
    margin-top: 30px;
    text-align: right;
    display: flex;
    gap: 15px;
    justify-content: flex-end;
}

/* Button Styling */
.tvk-button {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    position: relative;
    overflow: hidden;
}

.tvk-button-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.tvk-button-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.tvk-button-secondary {
    background: #6c757d;
    color: white;
    box-shadow: 0 4px 15px rgba(108, 117, 125, 0.3);
}

.tvk-button-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(108, 117, 125, 0.4);
}

.tvk-button-danger {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(231, 76, 60, 0.3);
}

.tvk-button-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(231, 76, 60, 0.4);
}

/* Responsive Design */
@media (max-width: 768px) {
    .modal-wrapper,
    .modal-content {
        max-width: 95%;
        margin: 20px;
    }
    
    .modal-header {
        padding: 20px;
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
    
    .header-controls {
        flex-direction: column;
        gap: 10px;
    }
    
    .template-switcher {
        margin-right: 0;
        margin-bottom: 10px;
    }
    
    .modal-template-selector {
        min-width: 200px;
    }
    
    .choice-buttons {
        flex-direction: column;
        gap: 20px;
    }
    
    .choice-button {
        min-width: auto;
        width: 100%;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 10px;
    }
    
    .form-actions button {
        width: 100%;
        margin-left: 0;
    }
}

/* Scrollbar Styling */
.modal-body-wrapper::-webkit-scrollbar,
.modal-body::-webkit-scrollbar {
    width: 8px;
}

.modal-body-wrapper::-webkit-scrollbar-track,
.modal-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.modal-body-wrapper::-webkit-scrollbar-thumb,
.modal-body::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.modal-body-wrapper::-webkit-scrollbar-thumb:hover,
.modal-body::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Drag and Drop Sortable Styles */
.sortable-placeholder {
    background: #f0f8ff !important;
    border: 2px dashed #0073aa !important;
    border-radius: 8px !important;
    opacity: 0.6 !important;
    margin: 10px 0 !important;
    min-height: 100px !important;
}

.tvk-video-card.ui-sortable-helper {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
    transform: rotate(2deg) !important;
    z-index: 1000 !important;
}

.tvk-video-card.ui-sortable-placeholder {
    background: #f0f8ff !important;
    border: 2px dashed #0073aa !important;
    border-radius: 8px !important;
    opacity: 0.6 !important;
    margin: 10px 0 !important;
    min-height: 200px !important;
}

/* Table sortable styles */
#sortable-videos tr.ui-sortable-helper {
    background: #fff !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15) !important;
    transform: rotate(1deg) !important;
    z-index: 1000 !important;
}

#sortable-videos tr.ui-sortable-placeholder {
    background: #f0f8ff !important;
    border: 2px dashed #0073aa !important;
    opacity: 0.6 !important;
    height: 60px !important;
}

/* Drag handle styles */
.video-card-handle,
.reorder-handle {
    cursor: move !important;
    opacity: 0.7 !important;
    transition: opacity 0.2s ease !important;
    background: rgba(0, 115, 170, 0.1) !important;
    border: 1px solid rgba(0, 115, 170, 0.3) !important;
    border-radius: 4px !important;
    padding: 4px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 24px !important;
    min-height: 24px !important;
}

.video-card-handle:hover,
.reorder-handle:hover {
    opacity: 1 !important;
    background: rgba(0, 115, 170, 0.2) !important;
    border-color: rgba(0, 115, 170, 0.5) !important;
}

.video-card-handle .dashicons,
.reorder-handle .dashicons {
    color: #0073aa !important;
    font-size: 16px !important;
    pointer-events: none !important;
}

/* Sortable animation */
.tvk-video-card,
#sortable-videos tr {
    transition: all 0.3s ease !important;
}

/* Drag feedback */
.ui-sortable-helper {
    cursor: move !important;
}

.ui-sortable-placeholder {
    visibility: visible !important;
    opacity: 0.6 !important;
}

/* Success/Error message styles */
.notice {
    margin: 15px 0 !important;
    padding: 10px 15px !important;
    border-left: 4px solid !important;
    background: #fff !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
}

.notice-success {
    border-left-color: #46b450 !important;
}

.notice-error {
    border-left-color: #dc3232 !important;
}

.notice p {
    margin: 0 !important;
    font-size: 14px !important;
}

.notice-dismiss {
    float: right !important;
    margin: 0 0 0 10px !important;
    padding: 0 !important;
    cursor: pointer !important;
    background: 0 0 !important;
    border: 0 !important;
    -webkit-appearance: none !important;
}

.notice-dismiss:hover {
    opacity: 0.7 !important;
}
