/* ========================================
   IMPROVED CONTENT STUDIO DESIGN
   Modern, clean, with better UX
   ======================================== */

/* Color-coded column themes */
:root {
    --col-courses: #3b82f6;    /* Blue */
    --col-modules: #22c55e;    /* Green */
    --col-lessons: #a855f7;    /* Purple */
    --col-sections: #f59e0b;   /* Amber */
}

/* Base Studio Column Styles */
.studio-column {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 280px;
    background: #1e1e1e;
    border: 1px solid #2d2d2d;
    border-radius: 8px;
    overflow: hidden;
}

/* Color-coded column top borders */
.studio-column.col-courses { border-top: 3px solid var(--col-courses); }
.studio-column.col-modules { border-top: 3px solid var(--col-modules); }
.studio-column.col-lessons { border-top: 3px solid var(--col-lessons); }
.studio-column.col-sections { border-top: 3px solid var(--col-sections); }

/* Column header icon colors */
.studio-column.col-courses .column-header-icon { color: var(--col-courses) !important; }
.studio-column.col-modules .column-header-icon { color: var(--col-modules) !important; }
.studio-column.col-lessons .column-header-icon { color: var(--col-lessons) !important; }
.studio-column.col-sections .column-header-icon { color: var(--col-sections) !important; }

.studio-column.collapsed {
    min-width: 48px;
    max-width: 48px;
    flex: 0 0 48px !important;
    border-radius: 8px;
}

.studio-column.collapsed .column-content,
.studio-column.collapsed .column-header-text,
.studio-column.collapsed .column-badge,
.studio-column.collapsed .column-add-btn {
    opacity: 0;
    visibility: hidden;
    width: 0;
    overflow: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
}

/* Hide other buttons in the header when collapsed */
.studio-column.collapsed .column-header > div:first-child {
    display: none;
}

/* Hide all buttons except collapse button when collapsed */
.studio-column.collapsed .column-header > div:last-child > button:not(.collapse-btn) {
    display: none;
}

.studio-column.collapsed .column-header {
    justify-content: center;
    padding: 0.5rem 0;
    transition: padding 0.3s ease;
}

.studio-column.collapsed .column-header > div:last-child {
    justify-content: center;
    width: 100%;
}

.studio-column.collapsed .column-header-icon {
    display: none;
}

.collapse-btn {
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 1 !important;
    visibility: visible !important;
    width: auto !important;
    border-radius: 6px;
}

.studio-column.collapsed .collapse-btn {
    transform: rotate(180deg);
    opacity: 1 !important;
    visibility: visible !important;
    width: auto !important;
    display: flex !important;
    align-items: center;
    justify-content: center;
}

[dir="rtl"] .studio-column.collapsed .collapse-btn {
    transform: rotate(0deg);
}

/* Ensure collapse button is always visible and properly styled */
.studio-column.collapsed .collapse-btn:hover {
    background-color: #2d2d2d;
}

/* Minimal scrollbar */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: #3a3a3a;
    border-radius: 3px;
    transition: background 0.2s ease;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: #5a5a5a;
}

/* Form container scrollable */
.form-container-scrollable {
    max-height: 50vh;
    overflow-y: auto;
    overflow-x: hidden;
}

/* ========================================
   IMPROVED ITEM CARDS
   Better spacing, hover effects, depth
   ======================================== */
.studio-item {
    font-size: 0.8125rem;
    padding: 0.75rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    position: relative;
    background: #1e1e1e;
    border: 1px solid transparent;
    border-inline-start: 3px solid transparent;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

.studio-item:hover {
    background: #262626;
    border-color: #3a3a3a;
    border-inline-start-color: #3a3a3a;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.studio-item:active {
    transform: translateY(0);
    transition: transform 0.1s ease;
}

/* Selected state with column colors */
.studio-item.selected-course {
    background: #1e293b;
    border-color: var(--col-courses);
    border-inline-start-color: var(--col-courses);
}
.studio-item.selected-module {
    background: #14261a;
    border-color: var(--col-modules);
    border-inline-start-color: var(--col-modules);
}
.studio-item.selected-lesson {
    background: #2d1f3d;
    border-color: var(--col-lessons);
    border-inline-start-color: var(--col-lessons);
}
.studio-item.selected-section {
    background: #2d2510;
    border-color: var(--col-sections);
    border-inline-start-color: var(--col-sections);
}

/* Fallback for Alpine.js dynamic classes */
.studio-item.bg-\[#2d2d2d\] {
    background: #262626;
    border-color: #3a3a3a;
}

.studio-item.border-l-\[#d4d4d4\] {
    border-inline-start-color: #d4d4d4;
}

.studio-item h3 {
    font-size: 0.8125rem;
    font-weight: 500;
    line-height: 1.4;
    transition: color 0.2s ease;
    color: #e4e4e4;
}

.studio-item p {
    font-size: 0.75rem;
    line-height: 1.3;
    transition: color 0.2s ease;
    color: #9a9a9a;
}

/* Item count badges */
.item-count-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.125rem 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid #3a3a3a;
    border-radius: 12px;
    font-size: 0.6875rem;
    color: #9a9a9a;
}

.item-count-badge .material-symbols-outlined {
    font-size: 0.75rem;
}

/* Loading state */
.htmx-request {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

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

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

/* Smooth fade-in for new content */
.studio-item,
#course-list > *,
#module-list > *,
#lesson-list > *,
#section-list > * {
    animation: fadeSlideIn 0.3s ease-out;
}

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

/* Highlight animation for newly added items */
.studio-item.highlight-new {
    animation: highlightPulse 1.5s ease-out;
}

@keyframes highlightPulse {
    0% {
        background-color: rgba(34, 197, 94, 0.3);
        border-inline-start-color: #22c55e;
        box-shadow: 0 0 20px rgba(34, 197, 94, 0.3);
    }
    50% {
        background-color: rgba(34, 197, 94, 0.15);
    }
    100% {
        background-color: transparent;
        border-inline-start-color: transparent;
        box-shadow: none;
    }
}

@keyframes bounce-subtle {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

.animate-bounce-subtle {
    animation: bounce-subtle 2s infinite ease-in-out;
}

/* Form success pulse */
.form-success-pulse {
    animation: successPulse 0.6s ease-out;
}

@keyframes successPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.02);
        box-shadow: 0 0 20px rgba(88, 204, 2, 0.3);
    }
}

/* Smooth column transitions */
.column-content {
    transition: opacity 0.2s ease;
}

/* Button hover effects - More subtle */
button {
    transition: all 0.15s ease;
}

.action-btn:hover {
    transform: scale(1.05);
}

.action-btn:active {
    transform: scale(0.95);
}

/* Smooth scroll behavior */
.custom-scrollbar {
    scroll-behavior: smooth;
}

/* Selection border animation */
.studio-item[class*="border-"] {
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

/* Drag and drop styles */
.studio-item[draggable="true"] {
    cursor: grab;
}

.studio-item[draggable="true"]:active {
    cursor: grabbing;
}

/* Toast animations */
@keyframes slide-in-right {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.animate-slide-in-right {
    animation: slide-in-right 0.3s ease-out;
}

/* Keyboard shortcut hint */
kbd {
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.625rem;
    padding: 0.125rem 0.375rem;
    background: #2d2d2d;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
}

/* Better focus states */
input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #4a4a4a !important;
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.2);
}

/* Progress indicator */
.progress-bar {
    height: 2px;
    background: linear-gradient(90deg, #6366f1, #8b5cf6, #6366f1);
    background-size: 200% 100%;
    animation: progressShimmer 1.5s ease-in-out infinite;
}

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

/* Selection ring */
.studio-item.ring-2 {
    outline: 2px solid #3b82f6;
    outline-offset: -2px;
}

/* ========================================
   IMPROVED EMPTY STATES
   ======================================== */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    text-align: center;
}

.empty-state-icon {
    width: 64px;
    height: 64px;
    margin-bottom: 1rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #252526 0%, #1e1e1e 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #3a3a3a;
}

.empty-state-icon .material-symbols-outlined {
    font-size: 1.75rem;
    color: #6a6a6a;
}

.empty-state-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: #d4d4d4;
    margin-bottom: 0.25rem;
}

.empty-state-desc {
    font-size: 0.75rem;
    color: #858585;
    max-width: 180px;
    line-height: 1.4;
}

.empty-state-action {
    margin-top: 1rem;
    padding: 0.5rem 1rem;
    background: #2d2d2d;
    border: 1px solid #3a3a3a;
    border-radius: 6px;
    color: #d4d4d4;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.empty-state-action:hover {
    background: #3a3a3a;
    border-color: #4a4a4a;
}

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

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

.skeleton-item {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
    border-radius: 6px;
    background: #1e1e1e;
    border: 1px solid #2d2d2d;
}

.skeleton-line {
    height: 12px;
    margin-bottom: 0.5rem;
}

.skeleton-line:last-child {
    margin-bottom: 0;
}

.skeleton-line.w-3\/4 { width: 75%; }
.skeleton-line.w-1\/2 { width: 50%; }
.skeleton-line.w-1\/3 { width: 33%; }

/* ========================================
   QUICK ACTIONS (hover buttons)
   ======================================== */
.quick-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    opacity: 0;
    transform: translateX(4px);
    transition: all 0.2s ease;
}

.studio-item:hover .quick-actions {
    opacity: 1;
    transform: translateX(0);
}

.lesson-item .lesson-actions-row {
    display: flex;
    justify-content: center;
    border-top: 1px solid #2d2d2d;
    padding-top: 0.5rem;
    margin-top: 0.125rem;
}

#lesson-list .lesson-item {
    border-color: #2f2f2f;
    border-inline-start-color: #4a2d66;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.02);
}

#lesson-list .lesson-item:not(:last-child) {
    margin-bottom: 0.625rem;
}

.lesson-item .quick-actions {
    opacity: 1;
    transform: none;
}

.quick-action-btn {
    padding: 0.375rem;
    border-radius: 4px;
    color: #858585;
    transition: all 0.15s ease;
}

.quick-action-btn:hover {
    background: #3a3a3a;
    color: #e4e4e4;
}

.quick-action-btn.danger:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.quick-action-btn .material-symbols-outlined {
    font-size: 1rem;
    display: block;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */
@media (max-width: 1280px) {
    .studio-column {
        min-width: 240px;
    }
}

@media (max-width: 1024px) {
    .studio-columns-container {
        display: grid;
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1fr 1fr;
        gap: 0.5rem;
    }

    .studio-column {
        min-height: 300px;
    }
}

@media (max-width: 768px) {
    .studio-columns-container {
        display: flex;
        flex-direction: column;
    }

    .studio-column {
        min-height: 250px;
        max-height: 400px;
    }

    .studio-column.collapsed {
        min-height: 48px;
        max-height: 48px;
    }
}

/* ========================================
   COLUMN HEADER IMPROVEMENTS
   ======================================== */
.column-header {
    background: linear-gradient(180deg, #2a2a2a 0%, #252526 100%);
    border-radius: 8px 8px 0 0;
}

.column-badge {
    background: rgba(255, 255, 255, 0.08);
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
    font-size: 0.6875rem;
    font-weight: 500;
}

/* Add button styling */
.column-add-btn {
    border-radius: 4px;
}

.column-add-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}
