/* ==================== DATA PROCESSOR STYLES ==================== */

:root {
    --primary: #3b82f6;
    --secondary: #64748b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border: #e2e8f0;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    padding-top: 50px;
}

html.embed-mode body {
    padding-top: 0;
}

html.embed-mode .recuedu-topbar {
    display: none;
}

html.embed-mode .app-header {
    top: 0;
}

html.embed-mode .workspace-new {
    height: calc(100vh - 112px);
}

/* ==================== HEADER ==================== */
.app-header {
    background: white;
    border-bottom: 1px solid var(--border);
    padding: 20px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 50px;
    z-index: 100;
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand i {
    color: var(--primary);
}

.brand h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
}

.subtitle {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
}

.badge {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ==================== BUTTONS ==================== */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-secondary {
    background: var(--secondary);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #475569;
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.btn-outline {
    background: white;
    color: var(--text-primary);
    border: 2px solid var(--border);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* ==================== WORKSPACE NUEVO LAYOUT ==================== */
.workspace-new {
    display: grid;
    grid-template-columns: 120px 350px 4px 1fr;
    height: calc(100vh - 162px);
    overflow: hidden;
}

/* ==================== MENÚ PRINCIPAL LATERAL IZQUIERDO ==================== */
.main-sidebar {
    background: white;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 16px 8px;
    gap: 4px;
    overflow-y: auto;
}

.sidebar-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 12px;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-weight: 500;
    gap: 6px;
}

.sidebar-item i {
    font-size: 1.5rem;
}

.sidebar-item:hover {
    background: var(--bg-secondary);
    color: var(--primary);
}

.sidebar-item.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.sidebar-item.active:hover {
    background: linear-gradient(135deg, #5568d3 0%, #664291 100%);
}

.sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

/* ==================== PANEL DE OPCIONES LATERAL ==================== */
.options-panel {
    background: white;
    overflow-y: auto;
    padding: 20px;
    min-width: 280px;
    max-width: 50vw;
}

/* ==================== DIVISOR REDIMENSIONABLE ==================== */
.panel-resizer {
    background: linear-gradient(to bottom, 
        transparent 0%, 
        transparent 45%, 
        #cbd5e1 45%, 
        #cbd5e1 48%, 
        transparent 48%, 
        transparent 52%, 
        #cbd5e1 52%, 
        #cbd5e1 55%, 
        transparent 55%, 
        transparent 100%
    );
    cursor: col-resize;
    position: relative;
    transition: all 0.2s;
}

.panel-resizer:hover,
.panel-resizer.resizing {
    background: var(--primary);
}

.panel-resizer::before {
    content: '⋮';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #94a3b8;
    font-size: 1rem;
    line-height: 0.5;
    letter-spacing: -2px;
}

.panel-resizer:hover::before,
.panel-resizer.resizing::before {
    color: white;
}

.option-content {
    display: none;
}

.option-content.active {
    display: block;
}

.option-content h3 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 12px;
    border-bottom: 2px solid var(--border);
}

.option-content h3 i {
    color: var(--primary);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-group label i {
    margin-right: 4px;
}

/* ==================== ÁREA PRINCIPAL DE CONTENIDO ==================== */
.main-canvas {
    background: var(--bg-secondary);
    overflow-y: auto;
    padding: 20px;
}

/* ==================== WORKSPACE (old) ==================== */
.workspace {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
    padding: 20px;
    max-width: 1600px;
    margin: 0 auto;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: fit-content;
    position: sticky;
    top: 170px;
    max-height: calc(100vh - 190px);
    overflow-y: auto;
}

.panel {
    background: white;
    border-radius: 12px;
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.panel h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel h3 i {
    color: var(--primary);
}

.divider {
    height: 1px;
    background: var(--border);
    margin: 16px 0;
}

/* ==================== INPUTS ==================== */
.input-field {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    transition: all 0.2s;
    background: white;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

textarea.input-field {
    min-height: 80px;
    resize: vertical;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
}

.helper-text {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 8px 0;
}

/* ==================== TRANSFORM SECTIONS ==================== */
.transform-section {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 10px;
    overflow: hidden;
}

.transform-section summary {
    padding: 12px;
    cursor: pointer;
    font-weight: 500;
    background: var(--bg-secondary);
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.transform-section summary:hover {
    background: #e2e8f0;
}

.transform-section summary i {
    color: var(--primary);
}

.transform-content {
    padding: 12px;
    background: white;
}

/* ==================== SAVED DATASETS ==================== */
.saved-datasets {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.dataset-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
    cursor: pointer;
    transition: all 0.2s;
}

.dataset-card:hover {
    border-color: var(--primary);
    background: white;
    transform: translateX(4px);
}

.dataset-card h4 {
    font-size: 0.9rem;
    margin: 0 0 4px 0;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.dataset-card p {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin: 0;
}

.dataset-card .dataset-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.dataset-card .btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
    transition: all 0.2s;
}

.dataset-card .btn-icon:hover {
    background: var(--bg-secondary);
    color: var(--primary);
}

.dataset-card .btn-delete:hover {
    color: var(--danger);
}

/* ==================== CANVAS ==================== */
.canvas {
    background: white;
    border-radius: 12px;
    border: 1px solid var(--border);
    min-height: 600px;
    padding: 24px;
}

/* ==================== EMPTY STATE ==================== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon-bg {
    width: 120px;
    height: 120px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
}

.empty-icon-bg i {
    font-size: 3.5rem;
    color: white;
}

.empty-state h2 {
    font-size: 1.75rem;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.empty-state p {
    color: var(--text-secondary);
    font-size: 1.1rem;
    margin-bottom: 32px;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-top: 40px;
    max-width: 900px;
    margin-left: auto;
    margin-right: auto;
}

.feature-card {
    background: var(--bg-secondary);
    padding: 20px;
    border-radius: 12px;
    border: 1px solid var(--border);
    transition: all 0.3s;
}

.feature-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    border-color: var(--primary);
}

.feature-card i {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 12px;
}

.feature-card h4 {
    font-size: 1rem;
    margin-bottom: 6px;
    color: var(--text-primary);
}

.feature-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0;
}

/* ==================== DATA VIEW ==================== */
.data-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.stats-bar {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.stat-item i {
    color: var(--primary);
}

.stat-item strong {
    color: var(--text-primary);
    font-weight: 600;
}

/* ==================== TABLE ==================== */
.table-wrapper {
    background: white;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
}

.table-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}

.table-controls h3 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
}

.view-toggle {
    display: flex;
    gap: 4px;
}

.view-toggle .btn {
    border-radius: 6px;
}

.view-toggle .btn.active {
    background: var(--primary);
    color: white;
}

.table-scroll {
    overflow-x: auto;
    max-height: 500px;
    overflow-y: auto;
}

#data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

#data-table thead {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    z-index: 10;
}

#data-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

#data-table td {
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-secondary);
}

#data-table tbody tr:hover {
    background: var(--bg-secondary);
}

#json-view {
    padding: 20px;
    background: var(--bg-secondary);
}

#json-preview {
    background: #1e293b;
    color: #e2e8f0;
    padding: 20px;
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    max-height: 500px;
    overflow-y: auto;
}

/* ==================== COLUMN INFO ==================== */
.column-info {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 20px;
}

.column-info h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

#columns-stats {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
}

.column-stat {
    background: white;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
}

.column-stat h4 {
    font-size: 0.9rem;
    margin-bottom: 8px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.column-stat .stat-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    margin: 4px 0;
    color: var(--text-secondary);
}

.column-stat .stat-row strong {
    color: var(--text-primary);
}

.column-stat .badge-numeric {
    background: #dcfce7;
    color: #166534;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
}

/* ==================== MODALS ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-overlay.hidden {
    display: none !important;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.close-icon {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    transition: all 0.2s;
}

.close-icon:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-body h4 {
    font-size: 1rem;
    font-weight: 600;
    margin: 16px 0 8px 0;
    color: var(--text-primary);
}

.modal-body ul {
    margin: 8px 0 16px 20px;
    color: var(--text-secondary);
}

.modal-body ul li {
    margin: 4px 0;
}

.modal-body pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px;
    border-radius: 6px;
    overflow-x: auto;
    font-size: 0.85rem;
}

.modal-body code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
}

/* ==================== UTILITIES ==================== */
.hidden {
    display: none !important;
}

.source-selector {
    margin: 12px 0;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
    .workspace {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        position: static;
        max-height: none;
    }
    
    .actions {
        flex-wrap: wrap;
    }
}

@media (max-width: 640px) {
    .app-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }
    
    .actions {
        width: 100%;
    }
    
    .btn {
        font-size: 0.85rem;
        padding: 8px 12px;
    }
    
    .features-grid {
        grid-template-columns: 1fr;
    }
}
