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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1e1e1e;
    color: #e0e0e0;
    overflow: hidden;
    height: 100vh;
}

.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
}

/* Barra superior */
.top-bar {
    background: #2d2d2d;
    border-bottom: 1px solid #404040;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 50px;
    flex-shrink: 0;
}

.top-bar h1 {
    font-size: 16px;
    font-weight: 500;
    color: #e0e0e0;
}

.top-actions {
    display: flex;
    gap: 10px;
}

.btn-icon {
    background: #3d3d3d;
    border: 1px solid #505050;
    color: #e0e0e0;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.2s;
}

.btn-icon:hover:not(:disabled) {
    background: #4d4d4d;
    border-color: #606060;
}

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

/* Layout principal */
.main-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 220px; /* Reducido de 250px */
    background: #252526;
    border-right: 1px solid #3e3e42;
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-section {
    padding: 15px 0;
    border-bottom: 1px solid #3e3e42;
}

.sidebar-section:last-child {
    border-bottom: none;
}

.sidebar-section h3 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #858585;
    padding: 0 15px 10px;
    letter-spacing: 0.5px;
}

.menu-item {
    width: 100%;
    background: transparent;
    border: none;
    color: #cccccc;
    padding: 10px 15px;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    transition: all 0.2s;
}

.menu-item:hover:not(:disabled) {
    background: #2a2d2e;
    color: #ffffff;
}

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

.menu-item .icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
}

/* Área de canvas */
.canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #1e1e1e;
    overflow: hidden;
    min-width: 0; /* Permite que se reduzca cuando el panel está visible */
}

.canvas-container {
    flex: 1;
    display: flex;
    gap: 10px; /* Reducido aún más */
    padding: 8px; /* Reducido aún más */
    overflow: auto;
    align-items: flex-start;
    justify-content: center;
}

.canvas-wrapper {
    display: flex;
    flex-direction: column;
    background: #252526;
    border: 1px solid #3e3e42;
    border-radius: 4px;
    overflow: hidden;
    min-width: 350px; /* Reducido de 400px */
    max-width: 100%;
}

.canvas-header {
    background: #2d2d2d;
    border-bottom: 1px solid #3e3e42;
    padding: 8px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}

.canvas-label {
    font-weight: 500;
    color: #cccccc;
}

.canvas-info {
    color: #858585;
    font-size: 11px;
}

.canvas-wrapper canvas {
    display: block;
    background: #1e1e1e;
    max-width: 100%;
    height: auto;
    cursor: crosshair;
}

/* Panel de información */
.info-panel {
    background: #252526;
    border-top: 1px solid #3e3e42;
    padding: 15px 20px;
    max-height: 200px;
    overflow-y: auto;
    flex-shrink: 0;
}

.info-panel h3 {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    color: #858585;
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

#imageInfo {
    font-size: 12px;
    line-height: 1.6;
    color: #cccccc;
}

#imageInfo p {
    margin: 5px 0;
}

#imageInfo strong {
    color: #4ec9b0;
    font-weight: 500;
}

/* Loading y errores */
.loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(30, 30, 30, 0.95);
    padding: 30px;
    border-radius: 8px;
    border: 1px solid #3e3e42;
    text-align: center;
    z-index: 1000;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.spinner {
    border: 3px solid #3e3e42;
    border-top: 3px solid #4ec9b0;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto 15px;
}

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

.error {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #f44336;
    color: white;
    padding: 15px 20px;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(244, 67, 54, 0.3);
    z-index: 1000;
    max-width: 400px;
    font-size: 13px;
}

/* Scrollbar personalizado */
.sidebar::-webkit-scrollbar,
.canvas-container::-webkit-scrollbar,
.info-panel::-webkit-scrollbar,
.tools-content::-webkit-scrollbar,
.histogram-content::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

.sidebar::-webkit-scrollbar-track,
.canvas-container::-webkit-scrollbar-track,
.info-panel::-webkit-scrollbar-track,
.tools-content::-webkit-scrollbar-track,
.histogram-content::-webkit-scrollbar-track {
    background: #1e1e1e;
}

.sidebar::-webkit-scrollbar-thumb,
.canvas-container::-webkit-scrollbar-thumb,
.info-panel::-webkit-scrollbar-thumb,
.tools-content::-webkit-scrollbar-thumb,
.histogram-content::-webkit-scrollbar-thumb {
    background: #424242;
    border-radius: 5px;
}

.sidebar::-webkit-scrollbar-thumb:hover,
.canvas-container::-webkit-scrollbar-thumb:hover,
.info-panel::-webkit-scrollbar-thumb:hover,
.tools-content::-webkit-scrollbar-thumb:hover,
.histogram-content::-webkit-scrollbar-thumb:hover {
    background: #4e4e4e;
}

/* Panel de herramientas lateral derecho */
.tools-panel {
    width: 0;
    background: #252526;
    border-left: 1px solid #3e3e42;
    overflow: hidden;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: width 0.3s ease;
    opacity: 0;
    visibility: hidden;
}

.tools-panel.visible {
    width: 420px;
    opacity: 1;
    visibility: visible;
    overflow-y: auto;
}

.tools-panel-header {
    background: #2d2d2d;
    border-bottom: 1px solid #3e3e42;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
}

.tools-panel-header h3 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    color: #cccccc;
    margin: 0;
    letter-spacing: 0.5px;
}

.tools-tabs {
    display: flex;
    gap: 5px;
    padding: 0 10px;
    background: #2d2d2d;
    border-bottom: 1px solid #3e3e42;
    flex-shrink: 0;
}

.tool-tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #858585;
    padding: 8px 12px;
    cursor: pointer;
    font-size: 11px;
    text-transform: uppercase;
    transition: all 0.2s;
}

.tool-tab:hover {
    color: #cccccc;
    background: #3d3d3d;
}

.tool-tab.active {
    color: #4ec9b0;
    border-bottom-color: #4ec9b0;
    background: #2d2d2d;
}

.tools-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
}

.tool-section {
    display: none;
}

.tool-section.active {
    display: block;
}

/* Mantener compatibilidad con histogram-panel */
.histogram-panel {
    width: 420px;
    background: #252526;
    border-left: 1px solid #3e3e42;
    overflow-y: auto;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.histogram-header {
    background: #2d2d2d;
    border-bottom: 1px solid #3e3e42;
    padding: 12px 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 10;
    flex-shrink: 0;
}

.histogram-header h3 {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    color: #cccccc;
    margin: 0;
    letter-spacing: 0.5px;
}

.close-btn {
    background: transparent;
    border: none;
    color: #cccccc;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
    transition: all 0.2s;
}

.close-btn:hover {
    background: #3d3d3d;
    color: #ffffff;
}

.histogram-content {
    padding: 15px;
    flex: 1;
    overflow-y: auto;
}

/* Controles de histogramas */
.histogram-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 15px;
    padding: 12px;
    background: #1e1e1e;
    border: 1px solid #3e3e42;
    border-radius: 4px;
}

.histogram-checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    user-select: none;
    font-size: 12px;
    color: #cccccc;
    transition: color 0.2s;
}

.histogram-checkbox:hover {
    color: #4ec9b0;
}

.histogram-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #4ec9b0;
    margin: 0;
}

.histogram-checkbox input[type="checkbox"]:checked {
    accent-color: #4ec9b0;
}

.histogram-checkbox span {
    font-size: 12px;
    font-weight: 500;
}

/* Comparación de histogramas - dos columnas */
.histograms-comparison {
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.histogram-column.hidden {
    display: none;
}

.histogram-column {
    flex: 1;
    min-width: 0;
}

.histogram-column-header {
    background: #2d2d2d;
    border: 1px solid #3e3e42;
    border-radius: 4px;
    padding: 8px 12px;
    margin-bottom: 15px;
    text-align: center;
}

.histogram-column-header h4 {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    color: #4ec9b0;
    margin: 0;
    letter-spacing: 0.5px;
}

.histogram-section {
    margin-bottom: 15px;
}

.histogram-section:last-child {
    margin-bottom: 0;
}

.histogram-section h4,
.histogram-section h5 {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    color: #858585;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.histogram-section h5 {
    font-size: 9px;
    margin-bottom: 6px;
}

.histogram-section canvas {
    width: 100%;
    height: auto;
    background: #1e1e1e;
    border: 1px solid #3e3e42;
    border-radius: 4px;
    display: block;
    max-width: 100%;
}

.tool-section canvas {
    width: 100%;
    height: auto;
    background: #1e1e1e;
    border: 1px solid #3e3e42;
    border-radius: 4px;
    display: block;
    max-width: 100%;
}

.histogram-legend {
    display: flex;
    gap: 15px;
    margin-top: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #cccccc;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 2px;
    display: inline-block;
}

/* Modal de conversión */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: #252526;
    border: 1px solid #3e3e42;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.modal-header {
    background: #2d2d2d;
    border-bottom: 1px solid #3e3e42;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.modal-header h3 {
    font-size: 14px;
    font-weight: 600;
    color: #cccccc;
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.modal-description {
    font-size: 12px;
    color: #858585;
    margin-bottom: 20px;
    line-height: 1.5;
}

.conversion-tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 20px;
    border-bottom: 1px solid #3e3e42;
}

.conversion-tab {
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: #858585;
    padding: 10px 15px;
    cursor: pointer;
    font-size: 12px;
    text-transform: uppercase;
    transition: all 0.2s;
}

.conversion-tab:hover {
    color: #cccccc;
    background: #3d3d3d;
}

.conversion-tab.active {
    color: #4ec9b0;
    border-bottom-color: #4ec9b0;
}

.conversion-panel {
    display: none;
}

.conversion-panel.active {
    display: block;
}

.input-group {
    margin-bottom: 20px;
}

.input-group label {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label span {
    font-size: 12px;
    color: #cccccc;
    font-weight: 500;
}

.input-group input[type="number"],
.input-group input[type="color"] {
    background: #1e1e1e;
    border: 1px solid #3e3e42;
    border-radius: 4px;
    padding: 10px;
    color: #cccccc;
    font-size: 13px;
    font-family: monospace;
    transition: all 0.2s;
}

.input-group input[type="number"]:focus,
.input-group input[type="color"]:focus {
    outline: none;
    border-color: #4ec9b0;
    box-shadow: 0 0 0 2px rgba(78, 201, 176, 0.2);
}

.input-group input[type="number"] {
    width: 100%;
}

.input-group input[type="color"] {
    width: 100%;
    height: 50px;
    cursor: pointer;
}

.input-info {
    font-size: 11px;
    color: #858585;
    margin-top: 5px;
}

.color-preview {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background: #1e1e1e;
    border-radius: 4px;
    border: 1px solid #3e3e42;
}

.preview-box {
    width: 60px;
    height: 60px;
    border-radius: 4px;
    border: 1px solid #3e3e42;
}

.preview-info {
    display: flex;
    flex-direction: column;
    gap: 5px;
    font-size: 12px;
    color: #cccccc;
}

.preview-info span {
    font-family: monospace;
}

.weight-summary {
    padding: 12px;
    background: #1e1e1e;
    border-radius: 4px;
    border: 1px solid #3e3e42;
    font-size: 12px;
    color: #cccccc;
    text-align: center;
    margin-top: 10px;
}

.weight-summary span {
    font-family: monospace;
    color: #4ec9b0;
    font-weight: 600;
}

.modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #3e3e42;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

.modal-footer .btn-primary,
.modal-footer .btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.modal-footer .btn-primary {
    background: #4ec9b0;
    color: #1e1e1e;
    font-weight: 600;
}

.modal-footer .btn-primary:hover {
    background: #5dd9c4;
}

.modal-footer .btn-secondary {
    background: #3d3d3d;
    color: #cccccc;
}

.modal-footer .btn-secondary:hover {
    background: #4d4d4d;
}

/* Responsive */
@media (max-width: 1200px) {
    .canvas-container {
        flex-direction: column;
        align-items: center;
    }
    
    .canvas-wrapper {
        width: 100%;
        max-width: 800px;
    }
    
    .histogram-panel {
        width: 100%;
        max-width: 350px;
    }
    
    .modal-content {
        width: 95%;
        max-height: 95vh;
    }
}
