/* --- Global Styles & Reset --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: #111827; /* bg-gray-900 */
    color: #ffffff; /* text-white */
    overflow: hidden; /* overflow-hidden */
    height: 100vh; /* h-screen */
}

.hidden {
    display: none!important;
}

/* --- Layout Principal (Mobile First) --- */
.container {
    display: flex;
    flex-direction: column; /* Apilado vertical en móviles */
    height: 100vh; /* Ocupa toda la altura de la ventana */
}

.main-content {
    height: 50%; /* Mitad superior para la imagen */
    width: 100%;
    background-color: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem; /* p-4 */
    position: relative;
    overflow: hidden;
}

.sidebar {
    height: 50%; /* Mitad inferior para los controles */
    width: 100%;
    background-color: #1f2937; /* bg-gray-800 */
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.75rem; 
    overflow-y: auto; /* Scroll como último recurso en pantallas muy pequeñas */
}

/* --- Main Content & Canvas --- */
#upload-prompt {
    text-align: center;
    color: #6b7280; /* text-gray-500 */
    border: 3px dashed transparent;
    padding: 2rem;
    border-radius: 0.75rem;
    transition: background-color 200ms, border-color 200ms;
    cursor: pointer;
}

#upload-prompt.dragging {
    background-color: #374151; /* bg-gray-700 */
    border-color: #4f46e5; /* border-indigo-600 */
}

#upload-prompt svg { margin: 0 auto 1rem; }
#upload-prompt h2 { font-size: 1.5rem; font-weight: 700; margin-bottom: 0.5rem; }
#main-canvas { max-width: 100%; max-height: 100%; object-fit: contain; border-radius: 0.5rem; box-shadow: 0 25px 50px -12px rgba(99, 102, 241, 0.2); }

/* --- Sidebar Header & Upload --- */
.sidebar-header {
    border-bottom: 1px solid #374151;
    padding-bottom: 1rem;
    flex-shrink: 0;
    /* Centrar el contenido del header */
    display: flex;
    flex-direction: column;
    align-items: center;
}
.logo-container { display: flex; align-items: center; gap: 0.7rem; margin-bottom: 0.5rem; }
.logo-container .logo { width: 40px; height: 40px; }
.logo-container h1 { font-size: 1.5rem; font-weight: 700; }
.sidebar-header p { font-size: 0.875rem; color: #9ca3af; }

/* --- Secciones de la Sidebar --- */
.sidebar-section { padding-top: 1rem; border-top: 1px solid #374151; display: flex; flex-direction: column; gap: 1rem; }
.section-title { font-size: 1.125rem; font-weight: 600; display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0; }
.subsection-title { font-size: 1rem; font-weight: 500; color: #d1d5db; margin-bottom: 0.75rem; }

/* --- Contenedor principal de controles --- */
.main-controls-container {
    display: flex;
    flex-direction: column; /* Apilado en móvil */
    gap: 1rem;
    margin-bottom: 1rem;
}
.section-title-small { font-size: 1rem; font-weight: 600; margin-bottom: 0.75rem; color: #e5e7eb; }
.controls-left, .controls-right { display: flex; flex-direction: column; }
.actions-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.75rem; }
.sliders-wrapper { display: flex; flex-direction: column; gap: 1rem; }

.upload-label {
    background-color: #22c55e;
    padding: 0.75rem 1rem;
    text-align: center;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: background-color 200ms;
    color: #ffffff;
    font-weight: 700;
    font-size: 0.875rem;
}
.upload-label:hover {
    background-color: #16a34a;
}
.btn.btn-rose { padding: 0.75rem 1rem; }

/* --- Filtros --- */
.filters-card { background-color: rgba(55, 65, 81, 0.5); border-radius: 0.75rem; padding: 1rem; border: 1px solid #374151; }
#effects-grid, #video-filters-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 0.5rem; }

/* --- Estilos para alinear las tarjetas de exportación --- */
.export-options-wrapper { display: grid; grid-template-columns: 1fr; gap: 1rem; }
.export-card {
    background-color: rgba(55, 65, 81, 0.5);
    border-radius: 0.75rem;
    padding: 1rem;
    border: 1px solid #374151;
    display: flex; /* Habilitar Flexbox */
    flex-direction: column; /* Apilar contenido verticalmente */
    height: 100%; /* Asegura que la tarjeta ocupe toda la altura de la celda de la cuadrícula */
}
.card-content-wrapper {
    flex-grow: 1; /* Hace que este contenedor crezca para ocupar el espacio disponible */
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding-bottom: 1rem; /* Espacio antes del botón */
}

/* --- Form Elements & Buttons --- */
.btn-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.5rem; }
.btn { width: 100%; color: #ffffff; font-weight: 700; padding: 0.75rem 1rem; border-radius: 0.5rem; transition: background-color 200ms; border: none; cursor: pointer; font-size: 0.875rem; }
.upload-label, .btn { display: flex; align-items: center; justify-content: center; } /* Centrar texto en botones y label */
.btn-blue { background-color: #3b82f6; } .btn-blue:hover { background-color: #2563eb; }
.btn-green { background-color: #22c55e; } .btn-green:hover { background-color: #16a34a; }
.btn-rose { background-color: #f43f5e; } .btn-rose:hover { background-color: #e11d48; }

.slider-label { display: block; margin-bottom: 0.5rem; font-size: 0.875rem; font-weight: 500; color: #d1d5db; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 100%; height: 8px; border-radius: 4px; background: #4a5568; outline: none; opacity: 0.7; transition: opacity .2s; }
input[type="range"]:hover { opacity: 1; }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 20px; height: 20px; border-radius: 50%; background: #818cf8; cursor: pointer; }
input[type="range"]::-moz-range-thumb { width: 20px; height: 20px; border-radius: 50%; background: #818cf8; cursor: pointer; }

input[type="color"] { width: 100%; height: 2.5rem; padding: 0.25rem; background-color: #374151; border-radius: 0.375rem; cursor: pointer; border: 1px solid #4b5563; }
.fx-btn { background-color: #374151; color: #ffffff; font-size: 0.875rem; font-weight: 500; padding: 0.5rem; border-radius: 0.375rem; transition: background-color 200ms; border: none; cursor: pointer; width: 100%; }
.fx-btn:hover { background-color: #4b5563; } .fx-btn.active { background-color: #4f46e5; } .fx-btn.active:hover { background-color: #4338ca; }

.form-select { width: 100%; background-color: #374151; border: 1px solid #4b5563; color: #ffffff; border-radius: 0.5rem; padding: 0.75rem; background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%239ca3af' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e"); background-repeat: no-repeat; background-position: right 0.5rem center; background-size: 1.5em 1.5em; -webkit-appearance: none; -moz-appearance: none; appearance: none; }
.form-select:focus { outline: none; border-color: #4f46e5; box-shadow: 0 0 0 2px #4f46e5; }
.compress-toggle-container { padding-top: 0.5rem; } .checkbox-label { display: flex; align-items: center; gap: 0.75rem; cursor: pointer; } .checkbox-text { font-size: 0.875rem; font-weight: 500; color: #e5e7eb; }
.form-checkbox { -webkit-appearance: none; -moz-appearance: none; appearance: none; display: inline-block; vertical-align: middle; background-origin: border-box; user-select: none; flex-shrink: 0; height: 1.25rem; width: 1.25rem; color: #4f46e5; background-color: #4a5568; border-color: #6b7280; border-width: 1px; border-radius: 0.25rem; }
.form-checkbox:checked { background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e"); border-color: transparent; background-color: currentColor; background-size: 100% 100%; background-position: center; background-repeat: no-repeat; }

#compression-options { padding-top: 0.5rem; display: flex; flex-direction: column; gap: 0.5rem; }
.compression-labels { display: flex; justify-content: space-between; font-size: 0.75rem; color: #9ca3af; margin-top: 0.25rem; padding: 0 0.25rem; }
.recording, .processing { cursor: not-allowed; opacity: 0.7; }

/* --- Responsive Design para pantallas grandes (Desktop) --- */
@media (min-width: 1024px) { /* lg breakpoint */
    .container {
        flex-direction: row; /* Lado a lado en desktop */
    }
    .main-content {
        height: 100%;
        width: 50%;
    }
    .sidebar {
        height: 100%;
        width: 50%;
        overflow-y: auto;
        padding: 1.5rem;
    }
    .main-controls-container {
        flex-direction: row;
        align-items: flex-start; /* Alinear arriba */
        gap: 3.5rem; 
    }
    .controls-left, .controls-right {
        flex: 1; /* Ambas columnas toman el mismo espacio */
    }
    .export-options-wrapper {
        grid-template-columns: repeat(2, 1fr);
    }
}

.processing {
    opacity: 0.7;
    cursor: wait !important;
    pointer-events: none;
}

.span-2-cols {
    grid-column: span 2;
}

/* --- CONVERSOR PRO STYLES 2.0 --- */

.converter-section {
    width: 100%;
    padding: 60px 20px;
    display: flex;
    justify-content: center;
}

.converter-wrapper {
    width: 100%;
    max-width: 650px;
    background: #2b3544;
    backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1); /* Borde sutil para separarlo del fondo */
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 25px 60px rgba(0,0,0,0.5);
}

.converter-title {
    text-align: center;
    color: #fff;
    margin-bottom: 25px;
    font-weight: 300;
    letter-spacing: 1.5px;
    font-size: 1.4rem;
    text-transform: uppercase;
}

.converter-tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 25px;
    background: rgba(0,0,0,0.4);
    padding: 5px;
    border-radius: 12px;
}

.tab-btn {
    flex: 1;
    background: transparent;
    border: none;
    color: #94a3b8;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 500;
}

.tab-btn.active {
    background: #3b82f6;
    color: white;
}

.tab-content { display: none; animation: fadeIn 0.4s ease; }
.tab-content.active { display: block; }

/* Upload Area */
.drop-area {
    border: 2px dashed #475569;
    border-radius: 15px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255,255,255,0.02);
}
.drop-area:hover { border-color: #3b82f6; background: rgba(59, 130, 246, 0.05); }
.icon-upload { font-size: 2.5rem; margin-bottom: 10px; display: block; }

/* Settings Grid */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin: 20px 0;
}
.setting-group { display: flex; flex-direction: column; gap: 5px; }
.setting-group.full { grid-column: 1 / -1; }

.setting-group label {
    font-size: 0.85rem;
    color: #cbd5e1;
    font-weight: 500;
}

.modern-select, .slider {
    width: 100%;
    padding: 8px 12px;
    background: #1e293b;
    border: 1px solid #475569;
    color: white;
    border-radius: 8px;
    outline: none;
}
.slider { padding: 0; cursor: pointer; height: 6px; margin-top: 8px; }

.action-btn {
    padding: 12px 20px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 10px;
}
.action-btn.full-width { width: 100%; }
.action-btn:hover { transform: translateY(-2px); box-shadow: 0 5px 15px rgba(16, 185, 129, 0.3); }
.action-btn:disabled { background: #64748b; transform: none; cursor: not-allowed; }

/* Progress Bar */
.progress-bar {
    width: 100%;
    height: 6px;
    background: #334155;
    border-radius: 3px;
    margin-top: 15px;
    overflow: hidden;
}
#progress-fill {
    height: 100%;
    background: #3b82f6;
    transition: width 0.3s ease;
}
.status-text { margin-top: 8px; font-size: 0.8rem; color: #94a3b8; text-align: center; }

@keyframes fadeIn { from { opacity: 0; transform: translateY(5px); } to { opacity: 1; transform: translateY(0); } }

.size-estimate {
    text-align: center;
    margin-bottom: 15px;
    font-size: 0.95rem;
    color: #cbd5e1;
    background: rgba(0,0,0,0.2);
    padding: 8px;
    border-radius: 8px;
    border: 1px dashed #475569;
}

/* Botón de borrar archivo */
.remove-btn {
    background: rgba(239, 68, 68, 0.15); /* Rojo transparente */
    color: #fca5a5; /* Rojo claro texto */
    border: 1px solid rgba(239, 68, 68, 0.5);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: all 0.2s;
    margin-left: 10px;
}

.remove-btn:hover {
    background: rgba(239, 68, 68, 0.4);
    color: white;
    transform: scale(1.1);
}

/* --- ESTILOS DEL MÓDULO IA --- */
#ai-widget-wrapper {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999; /* Por encima de todo */
    font-family: 'Inter', sans-serif;
}

#ai-launcher {
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: white;
    border: none;
    padding: 14px 24px;
    border-radius: 50px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    transition: transform 0.2s, box-shadow 0.2s;
    font-size: 1rem;
}

#ai-launcher:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

#ai-container {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 350px;
    height: 500px;
    background: #1f2937; /* Gris oscuro a juego con tu app */
    border: 1px solid #374151;
    border-radius: 16px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    overflow: hidden;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: translateY(0); } }

.ai-header {
    background: #111827;
    padding: 15px;
    border-bottom: 1px solid #374151;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

#ai-close { background: none; border: none; color: #9ca3af; cursor: pointer; font-size: 1.2rem; z-index: 10000;
    pointer-events: auto;
    padding: 5px 10px;}
#ai-close:hover { color: white; }

#ai-chat-history {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ai-msg { padding: 10px 14px; border-radius: 12px; font-size: 0.9rem; line-height: 1.5; max-width: 85%; }
.ai-msg-bot { background: #374151; color: #e5e7eb; align-self: flex-start; border-bottom-left-radius: 2px; }
.ai-msg-user { background: #2563eb; color: white; align-self: flex-end; border-bottom-right-radius: 2px; }

.ai-input-box {
    padding: 15px;
    background: #111827;
    border-top: 1px solid #374151;
    display: flex;
    gap: 10px;
}

#ai-user-input {
    flex: 1;
    background: #374151;
    border: 1px solid #4b5563;
    color: white;
    padding: 10px;
    border-radius: 8px;
    outline: none;
}
#ai-user-input:focus { border-color: #2563eb; }

#ai-send-btn {
    background: #2563eb;
    color: white;
    border: none;
    width: 40px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.2rem;
}
#ai-send-btn:hover { background: #1d4ed8; }
#ai-send-btn:disabled { background: #4b5563; cursor: not-allowed; }