/**
 * TVK Video Shortcodes Modal CSS
 * Provides styling for all modal functionality
 */

/* Modal Overlay */
.tvk-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 999999999 !important;
    display: none;
    overflow: auto;
}

/* Modal Container */
.tvk-modal {
    position: relative;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    margin: 20px auto;
    max-width: 95vw;
    max-height: 95vh;
    overflow: hidden;
    z-index: 999999999 !important;
}

/* Modal Header */
.tvk-modal-header {
    background: #0073aa;
    color: white;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #005a87;
}

.tvk-modal-header h2 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
}

.tvk-modal-close {
    background: none;
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.tvk-modal-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Modal Content */
.tvk-modal-content {
    padding: 20px;
    max-height: calc(95vh - 120px);
    overflow-y: auto;
}

/* Add Video Modal Specific Styles */
.tvk-add-video-modal-content {
    max-width: 800px;
    margin: 0 auto;
}

.tvk-add-video-header {
    text-align: center;
    margin-bottom: 30px;
}

.tvk-add-video-header h4 {
    color: #333;
    margin-bottom: 15px;
    font-size: 18px;
}

.tvk-user-status {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border-left: 4px solid #0073aa;
}

.tvk-user-status p {
    margin: 0;
    color: #666;
    font-size: 14px;
}

/* Video Addition Choices Grid */
.tvk-add-video-choices {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); /* Reduced from 250px */
    gap: 20px; /* Reduced from 25px */
    margin: 20px 0;
}

.tvk-add-video-choice {
    background: #ffffff;
    border: 2px solid #e9ecef;
    border-radius: 12px; /* Reduced from 16px */
    padding: 20px; /* Reduced from 25px */
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 120px; /* Reduced from 150px */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.tvk-add-video-choice:hover {
    border-color: #007cba;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 124, 186, 0.15);
}

.tvk-add-video-choice:active {
    transform: translateY(0);
}

.tvk-choice-icon {
    font-size: 48px;
    margin-bottom: 15px;
    display: block;
}

.tvk-add-video-choice h3 {
    color: #333;
    margin: 0 0 10px 0;
    font-size: 18px;
    font-weight: 600;
}

.tvk-add-video-choice p {
    color: #666;
    margin: 0 0 15px 0;
    font-size: 14px;
    line-height: 1.4;
}

.tvk-add-video-choice ul {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: left;
}

.tvk-add-video-choice li {
    color: #555;
    font-size: 13px;
    padding: 3px 0;
    position: relative;
    padding-left: 15px;
}

.tvk-add-video-choice li:before {
    content: "✓";
    color: #0073aa;
    position: absolute;
    left: 0;
    font-weight: bold;
}

/* Form Containers - Make them smaller to match cards */
.tvk-form-container {
    background: #ffffff;
    border: 2px solid #e9ecef;
    border-radius: 12px; /* Reduced from 16px */
    padding: 20px; /* Reduced from 25px */
    margin: 15px 0; /* Reduced from 20px */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-width: 500px; /* Reduced from 600px */
    margin-left: auto;
    margin-right: auto;
    display: none; /* Ensure forms are hidden by default */
}

.tvk-form-container h4 {
    margin: 0 0 15px 0; /* Reduced from 20px */
    color: #495057;
    font-size: 18px; /* Reduced from 20px */
    text-align: center;
}

/* Form Groups - Smaller spacing */
.tvk-form-group {
    margin-bottom: 15px; /* Reduced from 20px */
}

.tvk-form-group label {
    display: block;
    margin-bottom: 5px; /* Reduced from 8px */
    font-weight: 600;
    color: #495057;
    font-size: 14px; /* Reduced from 16px */
}

.tvk-form-group input,
.tvk-form-group textarea,
.tvk-form-group select {
    width: 100%;
    padding: 8px 12px; /* Reduced from 10px 15px */
    border: 1px solid #ced4da;
    border-radius: 6px; /* Reduced from 8px */
    font-size: 14px; /* Reduced from 16px */
    transition: border-color 0.3s ease;
}

.tvk-form-group input:focus,
.tvk-form-group textarea:focus,
.tvk-form-group select:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}

.tvk-form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.tvk-form-help {
    display: block;
    margin-top: 5px;
    color: #6c757d;
    font-size: 12px;
    font-style: italic;
}

/* Submit Button - Smaller size */
.tvk-submit-btn {
    background: #007cba;
    color: white;
    border: none;
    padding: 10px 20px; /* Reduced from 12px 24px */
    border-radius: 6px; /* Reduced from 8px */
    font-size: 14px; /* Reduced from 16px */
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    margin-top: 15px; /* Reduced from 20px */
}

.tvk-submit-btn:hover {
    background: #005a87;
    transform: translateY(-1px);
}

/* Form Header and Back Button */
.tvk-add-video-forms {
    display: none;
}

.tvk-form-header {
    display: flex;
    align-items: center;
    margin-bottom: 20px; /* Reduced from 25px */
    gap: 12px; /* Reduced from 15px */
}

.tvk-back-to-choices {
    background: #6c757d;
    color: white;
    border: none;
    padding: 6px 12px; /* Reduced from 8px 16px */
    border-radius: 4px; /* Reduced from 6px */
    cursor: pointer;
    font-size: 12px; /* Reduced from 14px */
    transition: background-color 0.3s ease;
}

.tvk-back-to-choices:hover {
    background: #5a6268;
}

.tvk-form-header h3 {
    margin: 0;
    color: #333;
    font-size: 18px; /* Reduced from 20px */
}

/* Form Messages */
.tvk-form-message {
    margin-top: 20px;
    padding: 15px;
    border-radius: 6px;
    font-weight: 500;
}

.tvk-message-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.tvk-message-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Resource Loading Status */
.tvk-resource-status {
    position: fixed;
    top: 20px;
    right: 20px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 10px 15px;
    border-radius: 4px;
    font-size: 12px;
    z-index: 999999999;
    display: none;
}

.tvk-resource-status.show {
    display: block;
}

.tvk-resource-status.success {
    background: rgba(40, 167, 69, 0.9);
}

.tvk-resource-status.error {
    background: rgba(220, 53, 69, 0.9);
}

.tvk-resource-status.warning {
    background: rgba(255, 193, 7, 0.9);
}

/* Error Handling Styles */
.tvk-error-handled {
    opacity: 0.5;
}

.tvk-iframe-error,
.tvk-video-error {
    margin: 10px 0;
    border-radius: 4px;
}

.tvk-iframe-error button,
.tvk-video-error button {
    margin-top: 10px;
    padding: 8px 16px;
    background: #721c24;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.tvk-iframe-error button:hover,
.tvk-video-error button:hover {
    background: #5a1c24;
}

/* Loading Spinner */
.tvk-loading-spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: tvk-spin 1s linear infinite;
    margin-right: 10px;
}

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

/* Resource Loading Progress */
.tvk-resource-progress {
    width: 100%;
    height: 4px;
    background: #e9ecef;
    border-radius: 2px;
    overflow: hidden;
    margin: 10px 0;
}

.tvk-resource-progress-bar {
    height: 100%;
    background: #007cba;
    width: 0%;
    transition: width 0.3s ease;
}

.tvk-resource-progress-bar.loading {
    width: 100%;
    animation: tvk-progress-loading 2s ease-in-out infinite;
}

@keyframes tvk-progress-loading {
    0% { width: 0%; }
    50% { width: 70%; }
    100% { width: 100%; }
}

/* Responsive Design */
@media (max-width: 768px) {
    .tvk-modal {
        margin: 10px;
        max-width: calc(100vw - 20px);
        max-height: calc(100vh - 20px);
    }
    
    .tvk-modal-header {
        padding: 15px;
    }
    
    .tvk-modal-header h2 {
        font-size: 20px;
    }
    
    .tvk-modal-content {
        padding: 15px;
    }
    
    .tvk-add-video-choices {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .tvk-add-video-choice {
        padding: 20px;
    }
    
    .tvk-choice-icon {
        font-size: 36px;
    }
}

@media (max-width: 480px) {
    .tvk-modal-header {
        padding: 12px;
    }
    
    .tvk-modal-header h2 {
        font-size: 18px;
    }
    
    .tvk-modal-content {
        padding: 12px;
    }
    
    .tvk-form-group input,
    .tvk-form-group textarea,
    .tvk-form-group select {
        padding: 10px;
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Animation Classes */
.tvk-modal-overlay {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.tvk-modal {
    animation: slideIn 0.3s ease-out;
}

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

/* Loading States */
.tvk-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: #666;
}

.tvk-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #e9ecef;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 10px;
}

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

/* Accessibility */
.tvk-modal:focus {
    outline: none;
}

.tvk-modal-close:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* High Contrast Mode Support - Modern Standards */
@media (forced-colors: active) {
    .tvk-modal-overlay {
        border: 2px solid CanvasText;
        background: Canvas;
    }
    
    .tvk-modal {
        border: 2px solid CanvasText;
        background: Canvas;
    }
    
    .tvk-modal-header {
        border-bottom: 2px solid CanvasText;
        background: Canvas;
        color: CanvasText;
    }
    
    .tvk-modal-close {
        border: 2px solid CanvasText;
        background: Canvas;
        color: CanvasText;
    }
    
    .tvk-submit-btn {
        border: 2px solid CanvasText;
        background: Canvas;
        color: CanvasText;
    }
    
    .tvk-cancel-btn {
        border: 2px solid CanvasText;
        background: Canvas;
        color: CanvasText;
    }
}

/* Video Preview Grid Styles */
.tvk-video-preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 20px 0;
}

.tvk-video-preview {
    position: relative;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tvk-video-preview:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.tvk-video-preview.clickable {
    cursor: pointer;
}

.tvk-video-preview img {
    width: 100%;
    height: 120px;
    object-fit: cover;
}

.tvk-video-placeholder {
    width: 100%;
    height: 120px;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
}

.tvk-video-placeholder .dashicons {
    font-size: 48px;
}

.tvk-video-preview h5 {
    margin: 10px;
    font-size: 14px;
    text-align: center;
}

.tvk-video-preview-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tvk-video-preview:hover .tvk-video-preview-overlay {
    opacity: 1;
}

.tvk-video-preview-overlay .dashicons {
    color: white;
    font-size: 48px;
}

/* Video Action Buttons */
.tvk-video-actions {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.tvk-video-preview:hover .tvk-video-actions {
    opacity: 1;
}

.tvk-edit-video-btn,
.tvk-delete-video-btn {
    background: rgba(0, 0, 0, 0.8);
    border: none;
    border-radius: 4px;
    color: white;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tvk-edit-video-btn:hover {
    background: rgba(40, 167, 69, 0.9);
    transform: scale(1.1);
}

.tvk-delete-video-btn:hover {
    background: rgba(220, 53, 69, 0.9);
    transform: scale(1.1);
}

.tvk-edit-video-btn .dashicons,
.tvk-delete-video-btn .dashicons {
    font-size: 16px;
    color: white;
}

/* Playlist Item Styles */
.tvk-playlist-item.clickable {
    cursor: pointer;
    transition: all 0.3s ease;
}

.tvk-playlist-item.clickable:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

/* Video Player Wrapper Styles */
.tvk-video-player-wrapper.clickable {
    position: relative;
    cursor: pointer;
}

.tvk-video-player-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    color: white;
    text-align: center;
}

.tvk-video-player-wrapper:hover .tvk-video-player-overlay {
    opacity: 1;
}

.tvk-video-player-overlay .dashicons {
    font-size: 48px;
    margin-bottom: 10px;
}

.tvk-overlay-text {
    font-size: 14px;
    font-weight: 500;
}

/* Player Modal Styles */
.tvk-player-modal {
    --grid-columns: 250px 1fr 150px 150px;
    --sidebar-width: 250px;
    --right-panel-width: 150px;
}

.tvk-player-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
}

.tvk-template-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tvk-template-label {
    font-weight: 500;
    color: #6c757d;
}

.tvk-template-name {
    font-weight: 600;
    color: #495057;
    padding: 4px 8px;
    background: #e9ecef;
    border-radius: 4px;
}

.tvk-player-content {
    display: grid;
    grid-template-columns: var(--grid-columns);
    gap: 20px;
    padding: 20px;
    min-height: 500px;
}

.tvk-video-player-container {
    grid-column: 2;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    min-height: 400px;
}

.tvk-video-player {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tvk-player-sidebar {
    grid-column: 1;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
}

.tvk-video-info h4 {
    margin: 0 0 15px 0;
    color: #495057;
}

.tvk-video-info p {
    margin: 0 0 10px 0;
    font-size: 14px;
}

.tvk-template-switcher {
    margin-top: 30px;
}

.tvk-template-switcher h4 {
    margin: 0 0 15px 0;
    color: #495057;
}

.tvk-template-selector {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    background: white;
    font-size: 14px;
}

/* Template-specific styles */
.tvk-template-full-feature .tvk-player-content {
    grid-template-columns: 250px 1fr 150px 150px;
}

.tvk-template-compact .tvk-player-content {
    grid-template-columns: 200px 1fr 120px 120px;
}

.tvk-template-full-width .tvk-player-content {
    grid-template-columns: 250px 1fr 150px 150px;
}

.tvk-template-sleek .tvk-player-content {
    grid-template-columns: 280px 1fr 160px 160px;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .tvk-player-content {
        grid-template-columns: 200px 1fr 120px 120px !important;
        gap: 16px;
    }
}

@media (max-width: 768px) {
    .tvk-player-content {
        grid-template-columns: 1fr !important;
        gap: 16px;
    }
    
    .tvk-player-sidebar {
        grid-column: 1;
        order: 2;
    }
    
    .tvk-video-player-container {
        grid-column: 1;
        order: 1;
    }
    
    .tvk-player-header {
        flex-direction: column;
        gap: 15px;
        text-align: center;
    }
}

/* Test Modal Debug Styles */
.tvk-test-modal-container {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
}

.tvk-test-modal-btn {
    background: #007cba;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    margin-bottom: 20px;
}

.tvk-test-modal-btn:hover {
    background: #005a87;
}

.tvk-test-info {
    background: white;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 15px;
}

.tvk-test-info p {
    margin: 8px 0;
    font-family: monospace;
    font-size: 14px;
}

.tvk-test-info strong {
    color: #495057;
}

/* Error display styles */
.tvk-modal-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    padding: 15px;
    margin: 20px 0;
    text-align: center;
}

.tvk-modal-error:before {
    content: "⚠️ ";
    font-size: 18px;
}

/* Edit Video Form Styles */
.tvk-edit-video-form {
    padding: 20px;
}

.tvk-edit-video-form .tvk-form-group {
    margin-bottom: 20px;
}

.tvk-edit-video-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #495057;
}

.tvk-edit-video-form input[type="text"],
.tvk-edit-video-form input[type="url"],
.tvk-edit-video-form textarea,
.tvk-edit-video-form select {
    width: 100%;
    padding: 10px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
}

.tvk-edit-video-form textarea {
    resize: vertical;
    min-height: 80px;
}

/* Delete Video Form Styles */
.tvk-delete-video-form {
    padding: 20px;
    text-align: center;
}

.tvk-delete-warning {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    padding: 20px;
    margin-bottom: 20px;
    color: #856404;
}

.tvk-delete-warning p {
    margin: 10px 0;
    font-size: 16px;
}

.tvk-delete-warning strong {
    color: #721c24;
}

/* Form Actions */
.tvk-form-actions {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 30px;
}

.tvk-submit-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 4px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
}

.tvk-update-btn {
    background: #28a745;
    color: white;
}

.tvk-update-btn:hover {
    background: #218838;
}

.tvk-delete-btn {
    background: #dc3545;
    color: white;
}

.tvk-delete-btn:hover {
    background: #c82333;
}

.tvk-cancel-btn {
    background: #6c757d;
    color: white;
}

.tvk-cancel-btn:hover {
    background: #5a6268;
}

/* Form Messages */
.tvk-form-message {
    margin: 20px 0;
    padding: 15px;
    border-radius: 4px;
    text-align: center;
    font-weight: 500;
}

.tvk-message-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.tvk-message-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}
