:root {
    --bg-grad: #003A5D;
    --sidebar-bg: #003A5D;
    --sidebar-border: rgba(0, 102, 255, 0.3);
    --card-bg: rgba(255, 255, 255, 0.03);
    --card-border: rgba(255, 255, 255, 0.06);
    --primary: #0066FF;
    --secondary: #FF6B35;
    --success: #00C853;
    --warning: #FFD600;
    --danger: #FF1744;
    --text-main: #e0e0e0;
    --text-heading: #ffffff;
    --text-muted: #888888;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', sans-serif;
}

body {
    background: var(--bg-grad);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

#app-header {
    background: var(--bg-grad);
    border-bottom: 1px solid var(--sidebar-border);
    padding: 10px 20px;
    display: flex;
    align-items: center;
}
#app-header img {
    height: 60px;
    width: auto;
    display: block;
}

#app-container {
    display: flex;
    min-height: calc(100vh - 81px);
}

/* Sidebar */
#sidebar {
    width: 250px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    padding-top: 20px;
    transition: transform 0.3s ease;
}

.sidebar-sync {
    padding: 0 20px 15px;
    margin-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.sidebar-sync-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    margin-bottom: 4px;
}
.sidebar-sync-date {
    font-size: 12px;
    color: var(--text-main);
    margin-bottom: 6px;
}
.sidebar-sync-status {
    font-size: 11px;
    margin-top: 6px;
    line-height: 1.4;
}

.sidebar-btn {
    width: 100%;
    text-align: left;
    padding: 15px 20px;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 15px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.sidebar-btn.active {
    background: rgba(0, 102, 255, 0.1);
    border-left: 3px solid var(--primary);
    box-shadow: inset 5px 0 10px -5px var(--primary);
    color: var(--text-heading);
}

.sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 10px 20px;
}

/* Main Content */
#main-content {
    flex: 1;
    padding: 30px;
    animation: fadeIn 0.4s ease forwards;
}

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

h1, h2, h3 {
    color: var(--text-heading);
    margin-bottom: 20px;
    font-weight: 600;
}

/* Layout */
.page-layout {
    display: flex;
    gap: 20px;
    align-items: flex-start;
}
.form-panel {
    flex: 1;
}
.table-panel {
    flex: 2;
}

/* Glass Panels */
.glass-panel {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

/* Form Elements */
.form-group {
    margin-bottom: 15px;
}
.form-group label {
    display: block;
    margin-bottom: 5px;
    color: var(--text-muted);
    font-size: 14px;
}
select, input[type="number"], input[type="text"], input[type="password"] {
    width: 100%;
    padding: 10px;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--card-border);
    border-radius: 6px;
    color: var(--text-main);
    transition: all 0.3s ease;
}
select:focus, input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 5px rgba(0, 102, 255, 0.3);
}
select option {
    color: #000;
    background: #fff;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.3s ease;
}
.btn-primary {
    background: linear-gradient(90deg, var(--primary), #004ecc);
    color: white;
}
.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 102, 255, 0.4);
}
.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}
.btn-danger {
    background: var(--danger);
    color: white;
    padding: 5px 10px;
}

/* Diálogo de confirmación (ej. "Limpiar todo") */
.confirm-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}
.confirm-modal-box {
    max-width: 420px;
    margin: 0;
}
.confirm-modal-message {
    margin-bottom: 20px;
    line-height: 1.5;
}

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}
.data-table th, .data-table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.data-table th {
    background: rgba(0, 0, 0, 0.3);
    color: var(--text-muted);
    font-weight: 500;
}
.data-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.03);
}
.table-footer {
    font-weight: 700;
    background: rgba(0, 102, 255, 0.1);
}

/* Diseño CCM */
.legend-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-muted);
    margin-right: 15px;
}
.legend-swatch {
    display: inline-block;
    width: 14px;
    height: 14px;
    border-radius: 3px;
}
.ccm-design-wrap {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}
.ccm-ruler {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    margin-top: 26px; /* alinea con el inicio de los bloques, debajo de la etiqueta de columna */
}
.ccm-ruler-tick {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 6px;
    font-size: 10px;
    color: var(--text-muted);
    border-right: 2px solid var(--card-border);
    box-sizing: border-box;
}
.ccm-design-columns {
    display: flex;
    gap: 15px;
    overflow-x: auto;
    padding-bottom: 20px;
    align-items: flex-start;
}
.ccm-column {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--card-border);
    border-radius: 8px;
    overflow: hidden;
}
.ccm-column-label {
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    padding: 6px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid var(--card-border);
}
.ccm-block {
    border-bottom: 1px solid rgba(0, 0, 0, 0.4);
    padding: 6px 10px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    overflow: hidden;
    color: #10131f;
    transition: filter 0.15s ease;
}
.ccm-block[draggable="true"] {
    cursor: grab;
}
.ccm-block.dragging {
    opacity: 0.4;
}
.ccm-block.drag-over {
    filter: brightness(1.25);
    outline: 2px dashed #fff;
}
.ccm-block-topbar {
    display: flex;
    align-items: stretch;
    gap: 2px;
    height: 42px;
    flex-shrink: 0;
    margin-bottom: 4px;
}
.ccm-topbar-swatch {
    width: 16px;
    flex-shrink: 0;
    border-radius: 2px;
    background: linear-gradient(to bottom,
        #ff3b30 0%, #ff3b30 33.33%,
        #ffd60a 33.33%, #ffd60a 66.66%,
        #2ecc71 66.66%, #2ecc71 100%);
}
.ccm-topbar-tab {
    flex: 1;
    background: rgba(0, 0, 0, 0.55);
    border-radius: 2px;
}
.ccm-block-drive-icon-wrap {
    display: flex;
    justify-content: flex-start;
    flex-shrink: 0;
    margin-top: 8px;
    margin-left: 8px;
    margin-bottom: 4px;
}
.ccm-block-drive-icon-wrap svg {
    flex-shrink: 0;
}
.ccm-block-body {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}
.ccm-block-info {
    display: flex;
    flex-direction: column;
    font-size: 11px;
    line-height: 1.3;
    overflow: hidden;
    flex: 1;
    min-width: 0;
}
.ccm-block-info strong {
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ccm-block-info span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ccm-block-size {
    flex-shrink: 0;
    align-self: center;
}
.ccm-block-size .ccm-size-input {
    width: 30px;
    padding: 2px 0 2px 4px;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.6);
    color: #10131f;
    border: 1px solid rgba(0, 0, 0, 0.3);
}
.ccm-block-kit-wrap {
    display: flex;
    flex-direction: column;
    cursor: grab;
    transition: filter 0.15s ease;
}
.ccm-block-kit-wrap.dragging { opacity: 0.4; }
.ccm-block-kit-wrap.drag-over { filter: brightness(1.25); outline: 2px dashed #fff; }
.bloque-proteccion { background: #6fa8ff; }
.bloque-breaker { background: #4ce08a; }
.bloque-arrancador { background: #ffe066; }
.bloque-drive { background: #ff9d73; }
.bloque-fuente { background: #b57af2; }
.bloque-metalmecanico-adicional { background: #c9955a; }
.bloque-otro { background: #b8bfc9; }
.bloque-puerta-ciega {
    background: repeating-linear-gradient(45deg, rgba(255,255,255,0.08), rgba(255,255,255,0.08) 6px, rgba(255,255,255,0.02) 6px, rgba(255,255,255,0.02) 12px);
    color: var(--text-muted);
}

/* Utilities */
.flex-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}
.actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
}

/* Cotización para impresión */
#print-area {
    display: none;
}

.quote-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 3px solid #0a3d62;
    padding-bottom: 15px;
    margin-bottom: 20px;
}
.quote-header img {
    height: 70px;
}
.quote-header .quote-meta {
    text-align: right;
    color: #333;
}
.quote-header .quote-meta h1 {
    color: #0a3d62;
    font-size: 20px;
    margin-bottom: 6px;
}
.quote-header .quote-meta p {
    font-size: 13px;
    margin: 2px 0;
}
.quote-item-title {
    color: #0a3d62;
    font-size: 15px;
    margin: 18px 0 8px;
}
.quote-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 6px;
    font-size: 12px;
}
.quote-table th, .quote-table td {
    border: 1px solid #ccc;
    padding: 6px 8px;
    text-align: left;
    color: #222;
}
.quote-table th {
    background: #0a3d62;
    color: #fff;
    font-weight: 600;
}
.quote-subtotal td {
    font-weight: 700;
    background: #f0f2f5;
    text-align: right;
    color: #0a3d62;
}
.quote-grand-total {
    margin-top: 20px;
    text-align: right;
    font-size: 18px;
    font-weight: 700;
    color: #0a3d62;
    border-top: 2px solid #0a3d62;
    padding-top: 10px;
}
.quote-footer {
    margin-top: 40px;
    font-size: 11px;
    color: #888;
    text-align: center;
}

@media print {
    /* Antes se ocultaba todo con "visibility: hidden", pero eso deja el
       layout de la app (barra lateral + contenido) ocupando su espacio
       normal aunque sea invisible; si esa área resultaba más alta que la
       cotización, sobraban hojas en blanco al final. Con "display: none" el
       contenedor de la app no ocupa nada y la impresión mide solo el alto
       real de #print-area. */
    #app-header, #app-container {
        display: none;
    }
    #print-area, #print-area * {
        /* Los navegadores omiten fondos de color al imprimir por default. */
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
        color-adjust: exact;
    }
    #print-area {
        display: block;
        background: #fff;
        color: #000;
        padding: 20px;
    }
    /* "Diseño CCM" completo (todas las columnas) casi nunca cabe en una sola
       hoja, así que NO se marca como "break-inside: avoid" a ese nivel: eso
       forzaba al navegador a cortar una columna a la mitad porque el bloque
       entero no cabía en ninguna página. En vez de eso, cada columna (y cada
       bloque dentro de ella) evita partirse — el salto de página cae entre
       columnas completas.
       El resto de estos ajustes (colores/bordes) son solo para que se lean
       bien sobre la hoja blanca; en pantalla usan el tema oscuro. */
    .quote-design-section .ccm-column {
        break-inside: avoid;
        page-break-inside: avoid;
        background: #f5f6f8;
        border-color: #999;
    }
    .quote-design-section .ccm-block,
    .quote-design-section .ccm-block-kit-wrap {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    .quote-design-section .ccm-column-label {
        background: #0a3d62;
        color: #fff;
        border-bottom-color: #999;
    }
    .quote-design-section .ccm-ruler-tick {
        color: #555;
        border-right-color: #999;
    }
    .quote-design-section .legend-item {
        color: #333;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
    background: var(--sidebar-border);
    border-radius: 4px;
}
