/* Content Studio Styles - Enhanced Design */

/* Hide elements when x-cloak is present (Alpine.js) */
[x-cloak] {
    display: none !important;
}

/* Studio Column Styles */
.studio-column {
    min-height: 400px;
    border-radius: 8px;
    overflow: hidden;
}

/* Custom Scrollbar - Minimal dark theme */
.studio-column .overflow-y-auto {
    scrollbar-width: thin;
    scrollbar-color: #3a3a3a transparent;
}

.studio-column .overflow-y-auto::-webkit-scrollbar {
    width: 6px;
}

.studio-column .overflow-y-auto::-webkit-scrollbar-track {
    background: transparent;
}

.studio-column .overflow-y-auto::-webkit-scrollbar-thumb {
    background-color: #3a3a3a;
    border-radius: 3px;
}

.studio-column .overflow-y-auto::-webkit-scrollbar-thumb:hover {
    background-color: #5a5a5a;
}

/* Studio Item Base Styles */
.studio-item {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 6px;
}

.studio-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

/* Form Animations */
#course-form-container,
#module-form-container,
#lesson-form-container,
#section-form-container {
    animation: slideDown 0.2s ease-out;
}

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

/* Column Header Gradients */
.column-header {
    position: relative;
    overflow: hidden;
}

.column-header::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 40%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1));
    pointer-events: none;
}

/* Don't show gradient when collapsed */
.studio-column.collapsed .column-header::after {
    display: none;
}

/* Collapse button styling - ensure visibility and consistency */
.collapse-btn {
    min-width: 32px;
    min-height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 0;
}

.studio-column.collapsed .collapse-btn {
    width: 36px;
    height: 36px;
    border-radius: 0;
    background-color: transparent;
}

.studio-column.collapsed .collapse-btn:hover {
    background-color: #2d2d2d !important;
}

.studio-column.collapsed .collapse-btn:active {
    background-color: #3a3a3a !important;
}

/* Make collapse button more visible */
.collapse-btn:hover {
    background-color: #2d2d2d;
}

.collapse-btn:active {
    background-color: #3a3a3a;
}

/* Ensure collapse button icon is always visible and transitions smoothly */
.collapse-btn .material-symbols-outlined {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), color 0.15s ease;
    color: #b0b0b0;
}

.collapse-btn:hover .material-symbols-outlined {
    color: #e0e0e0;
}

.studio-column.collapsed .collapse-btn .material-symbols-outlined {
    color: #b0b0b0;
}

.studio-column.collapsed .collapse-btn:hover .material-symbols-outlined {
    color: #e0e0e0;
}

/* Ensure collapse button is always on top when collapsed */
.studio-column.collapsed .column-header {
    position: relative;
    z-index: 10;
}

/* JSON Editor Styles */
textarea[name="content_json"],
textarea[name="evaluation_json"] {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    line-height: 1.5;
    tab-size: 2;
}

/* Modal Animation */
.fixed.inset-0 {
    animation: fadeIn 0.15s ease-out;
}

.fixed.inset-0 > div:not(.bg-black\/50) {
    animation: scaleIn 0.2s ease-out;
}

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

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Schema Form Field Styles - Minimal Dark Theme */
#generated-form .form-field {
    margin-bottom: 0.375rem;
}

/* Style all labels in generated form */
#generated-form label,
#generated-form .form-field label,
#schema-form-container label {
    font-size: 0.75rem !important;
    font-weight: 400;
    color: #858585 !important;
    margin-bottom: 0.25rem;
}

/* Ensure labels that use flex still display properly */
#generated-form label.flex,
#generated-form .form-field label.flex {
    display: flex;
    align-items: center;
}

/* Style all inputs, selects, and textareas in generated form - High specificity to override everything */
#generated-form input:not([type="checkbox"]):not([type="radio"]),
#generated-form input[type="url"],
#generated-form input[type="email"],
#generated-form input[type="text"],
#generated-form input[type="number"],
#generated-form select,
#generated-form textarea,
#generated-form .form-field input:not([type="checkbox"]):not([type="radio"]),
#generated-form .form-field input[type="url"],
#generated-form .form-field input[type="email"],
#generated-form .form-field input[type="text"],
#generated-form .form-field input[type="number"],
#generated-form .form-field select,
#generated-form .form-field textarea,
#generated-form .form-input,
#schema-form-container input:not([type="checkbox"]):not([type="radio"]),
#schema-form-container input[type="url"],
#schema-form-container input[type="email"],
#schema-form-container input[type="text"],
#schema-form-container input[type="number"],
#schema-form-container select,
#schema-form-container textarea {
    width: 100% !important;
    padding: 0.25rem 0.5rem !important;
    background-color: #252526 !important;
    border: 1px solid #2d2d2d !important;
    color: #d4d4d4 !important;
    font-size: 0.75rem !important;
    font-family: inherit !important;
    box-sizing: border-box !important;
    border-radius: 0 !important;
}

#generated-form input:not([type="checkbox"]):not([type="radio"]):focus,
#generated-form input[type="url"]:focus,
#generated-form input[type="email"]:focus,
#generated-form input[type="text"]:focus,
#generated-form input[type="number"]:focus,
#generated-form select:focus,
#generated-form textarea:focus,
#generated-form .form-field input:not([type="checkbox"]):not([type="radio"]):focus,
#generated-form .form-field input[type="url"]:focus,
#generated-form .form-field input[type="email"]:focus,
#generated-form .form-field input[type="text"]:focus,
#generated-form .form-field input[type="number"]:focus,
#generated-form .form-field select:focus,
#generated-form .form-field textarea:focus,
#generated-form .form-input:focus,
#schema-form-container input:not([type="checkbox"]):not([type="radio"]):focus,
#schema-form-container input[type="url"]:focus,
#schema-form-container input[type="email"]:focus,
#schema-form-container input[type="text"]:focus,
#schema-form-container input[type="number"]:focus,
#schema-form-container select:focus,
#schema-form-container textarea:focus {
    outline: none !important;
    border-color: #3a3a3a !important;
    background-color: #252526 !important;
}

/* Checkbox styling */
#generated-form input[type="checkbox"],
#generated-form .form-field input[type="checkbox"],
#generated-form .form-checkbox {
    width: 0.75rem;
    height: 0.75rem;
    margin-right: 0.375rem;
    cursor: pointer;
    accent-color: #858585;
}

/* Textarea specific styling */
#generated-form textarea,
#generated-form .form-field textarea {
    resize: vertical;
    min-height: 3rem;
}

/* Select dropdown styling */
#generated-form select,
#generated-form .form-field select {
    cursor: pointer;
}

#generated-form select option,
#generated-form .form-field select option {
    background-color: #252526;
    color: #d4d4d4;
}

/* Nested Array/Object Styles */
#generated-form .nested-array,
#generated-form .nested-object {
    border-left: 1px solid #2d2d2d;
    padding-left: 0.75rem;
    margin-left: 0.5rem;
    margin-top: 0.5rem;
}

#generated-form .array-item {
    position: relative;
    padding: 0.5rem;
    background-color: #252526;
    border: 1px solid #2d2d2d;
    margin-bottom: 0.375rem;
}

#generated-form .array-item .remove-btn {
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    padding: 0.125rem;
    color: #858585;
    cursor: pointer;
    font-size: 0.875rem;
    opacity: 0.6;
    transition: opacity 0.15s, color 0.15s;
}

#generated-form .array-item .remove-btn:hover {
    opacity: 1;
    color: #d4d4d4;
}

/* Add Button Styles */
#generated-form .add-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
    color: #858585;
    background-color: #252526;
    border: 1px solid #2d2d2d;
    cursor: pointer;
    transition: all 0.15s;
    margin-top: 0.25rem;
}

#generated-form .add-btn:hover {
    background-color: #2d2d2d;
    color: #d4d4d4;
    border-color: #3a3a3a;
}

#generated-form .add-btn .material-symbols-outlined {
    font-size: 0.875rem;
}

/* Progress Indicators */
.progress-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    z-index: 9999;
    background: transparent;
}

.progress-indicator .progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #6366f1, #8b5cf6, #ec4899);
    width: 0%;
    transition: width 0.3s ease;
    animation: progress-shimmer 2s ease-in-out infinite;
}

@keyframes progress-shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Loading Skeletons */
.skeleton {
    background: linear-gradient(90deg, #252526 25%, #2d2d2d 50%, #252526 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Better Loading States */
.loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(30, 30, 30, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    border: 3px solid #2d2d2d;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Responsive Adjustments */
@media (max-width: 1280px) {
    .studio-column {
        min-height: 350px;
    }
}

@media (max-width: 768px) {
    .studio-column {
        min-height: 300px;
    }
}

/* Loading States */
.htmx-request {
    opacity: 0.5;
    pointer-events: none;
}

.htmx-request::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 2px solid #e5e7eb;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

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

/* Validation Status Colors */
.validation-success {
    color: #059669;
}

.validation-error {
    color: #dc2626;
}

/* Sequence Badge */
.sequence-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5rem;
    height: 1.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    font-family: 'Monaco', 'Menlo', monospace;
    background-color: #374151;
    color: #9ca3af;
    border-radius: 6px;
}

/* Enhanced Selection States */
.studio-item.selected-course,
.studio-item.selected-module,
.studio-item.selected-lesson,
.studio-item.selected-section {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.1);
}

/* Smooth transitions for all interactive elements */
.studio-item,
.quick-action-btn,
.column-add-btn,
.collapse-btn {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Focus visible states for accessibility */
.studio-item:focus-visible,
.quick-action-btn:focus-visible,
button:focus-visible {
    outline: 2px solid #6366f1;
    outline-offset: 2px;
}

/* Animation for loading states */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.loading-shimmer {
    background: linear-gradient(90deg, #252526 25%, #2d2d2d 50%, #252526 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
}

/* Toast notification styles */
.toast {
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Improved form input styles */
.studio-column input,
.studio-column select,
.studio-column textarea {
    font-size: 0.8125rem;
}

/* Print styles */
@media print {
    .studio-column {
        break-inside: avoid;
    }
    
    .collapse-btn,
    .quick-actions {
        display: none !important;
    }
}
