/* === Layout: Toolbar a la izquierda, Canvas a la derecha === */
.cfd-designer-layout {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 16px;
    margin: 20px auto;
    padding: 16px;
    background-color: #f7f7f7;
    border-radius: 8px;
    max-width: 864px;
    width: 100%;
    box-sizing: border-box;
}

/* === Toolbar Lateral (Izquierda) === */
.cfd-toolbar {
    flex: 0 0 210px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 16px;
    background: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    box-sizing: border-box;
}

.cfd-toolbar-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
}

.cfd-actions-bottom {
    margin-top: auto;
    padding-top: 4px;
}

.cfd-section-title {
    font-size: 12px;
    text-transform: uppercase;
    font-weight: bold;
    color: #646970;
    margin-bottom: 2px;
}

/* === View Toggle (Frente / Espalda) === */
.cfd-view-toggle {
    display: flex;
    gap: 8px;
    width: 100%;
}

.cfd-view-toggle .cfd-btn {
    flex: 1;
    padding: 6px 12px;
    font-size: 13px;
    background: #f0f0f1;
    border: 1px solid #8c8f94;
    color: #2c3338;
}

.cfd-view-toggle .cfd-btn.active {
    background: #2271b1;
    color: #ffffff;
    border-color: #2271b1;
}

/* === Selector de Color de Camiseta === */
.cfd-shirt-colors {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-top: 5px;
}

.color-dot {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.15);
}

.color-dot:hover {
    transform: scale(1.15);
}

.color-dot.active {
    transform: scale(1.1);
    box-shadow: 0 0 0 2px #fff, 0 0 0 4px #2271b1;
}

/* === Divisor === */
.cfd-divider {
    border: 0;
    border-top: 1px solid #dcdcde;
    margin: 12px 0;
    width: 100%;
}

/* === Botón tipo label (para file input) === */
.cfd-btn-file-label {
    cursor: pointer;
}

/* === Color picker inline === */
.cfd-color-picker-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 13px;
}

.cfd-color-picker-wrapper label {
    font-size: 13px;
    color: #555;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    white-space: nowrap;
}

#text-color {
    width: 40px;
    height: 40px;
    padding: 2px;
    border: 1px solid #cccccc;
    border-radius: 4px;
    cursor: pointer;
    background: none;
    box-sizing: border-box;
}

/* === Canvas Wrapper (Derecha) === */
.cfd-canvas-wrapper {
    flex: 0 0 auto;
    width: 600px;
    max-width: 100%;
    border: 1px dashed #ccc;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    background-color: #ffffff;
    border-radius: 4px;
    overflow: hidden;
    line-height: 0;
}

.cfd-canvas-wrapper canvas {
    display: block;
    width: 100% !important;
    height: auto !important;
}

/* === Botones genéricos === */
.cfd-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 10px 14px;
    background-color: #ffffff;
    border: 1px solid #cccccc;
    border-radius: 4px;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s;
    user-select: none;
    white-space: nowrap;
    box-sizing: border-box;
}

.cfd-btn:hover {
    background-color: #e8e8e8;
    border-color: #999999;
}

.cfd-btn:active {
    background-color: #d4d4d4;
}

/* === Variantes de botones === */
.cfd-btn-primary {
    background-color: #2271b1;
    border-color: #2271b1;
    color: #ffffff;
}

.cfd-btn-primary:hover {
    background-color: #135e96;
    border-color: #135e96;
    color: #ffffff;
}

.cfd-btn-danger {
    color: #b32d2e;
    border-color: #b32d2e;
}

.cfd-btn-danger:hover {
    background-color: #fce8e8;
    border-color: #b32d2e;
}

.cfd-btn-secondary {
    background: #f6f7f7 !important;
    color: #2271b1 !important;
    border: 1px solid #2271b1 !important;
}

.cfd-btn-secondary:hover {
    background: #f0f6fa !important;
}

/* === Responsive === */
@media (max-width: 880px) {
    .cfd-designer-layout {
        flex-direction: column;
        align-items: center;
        max-width: 100%;
        padding: 12px;
    }

    .cfd-canvas-wrapper {
        width: 100%;
        max-width: 600px;
    }

    .cfd-toolbar {
        flex: 1 1 auto;
        width: 100%;
        max-width: 600px;
        flex-direction: row;
        flex-wrap: wrap;
        gap: 4px;
        padding: 12px;
    }

    .cfd-toolbar-section {
        flex: 1 1 auto;
        min-width: 120px;
    }

    .cfd-actions-bottom {
        margin-top: 0;
        flex-direction: row;
        flex-wrap: wrap;
    }

    .cfd-divider {
        display: none;
    }

    .cfd-btn {
        width: auto;
        padding: 8px 12px;
        font-size: 13px;
    }

    .cfd-view-toggle .cfd-btn {
        font-size: 12px;
        padding: 6px 8px;
    }
}

/* === FASE 2: Panel de Exploración de Artes === */

.cfd-arts-panel {
    background: #f8f9fa;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    padding: 10px;
    margin-top: 6px;
    max-height: 400px;
    overflow-y: auto;
}

.cfd-arts-search {
    width: 100%;
    padding: 8px;
    border: 1px solid #dcdcde;
    border-radius: 3px;
    font-size: 13px;
    box-sizing: border-box;
    margin-bottom: 6px;
}

.cfd-arts-filter-row {
    margin-bottom: 8px;
}

.cfd-arts-category {
    width: 100%;
    padding: 6px;
    border: 1px solid #dcdcde;
    border-radius: 3px;
    font-size: 12px;
    background: #fff;
    box-sizing: border-box;
}

.arts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
}

.arts-grid-item {
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 6px;
    cursor: pointer;
    transition: border-color 0.15s, box-shadow 0.15s;
    text-align: center;
}

.arts-grid-item:hover {
    border-color: #2271b1;
    box-shadow: 0 1px 4px rgba(34, 113, 177, 0.2);
}

.arts-grid-item img {
    max-width: 100%;
    height: auto;
    border-radius: 2px;
    margin-bottom: 4px;
}

.arts-item-name {
    font-size: 11px;
    font-weight: 600;
    color: #2c3338;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.arts-item-price {
    font-size: 11px;
    color: #2271b1;
    font-weight: 500;
}

.arts-loader {
    text-align: center;
    padding: 12px;
    font-size: 12px;
    color: #787c82;
    display: none;
}

.arts-empty {
    text-align: center;
    padding: 20px;
    font-size: 13px;
    color: #787c82;
}

#btn-toggle-arts.active {
    background: #f0f6fa !important;
    border-color: #2271b1 !important;
}

/* Responsive: panel full width en mobile */
@media (max-width: 880px) {
    .arts-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .cfd-arts-panel {
        max-height: 300px;
    }
}

/* === FASE 3: Botón Añadir al Carrito y Feedback === */

.cfd-btn-cart {
    font-size: 16px;
    font-weight: 700;
    padding: 14px 14px;
    background-color: #2c6f2c;
    border-color: #1e5a1e;
    color: #ffffff;
    transition: background-color 0.2s, opacity 0.2s;
}

.cfd-btn-cart:hover {
    background-color: #1e5a1e;
    border-color: #164516;
    color: #ffffff;
}

.cfd-btn-cart:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background-color: #8c8f94;
    border-color: #787c82;
    color: #ffffff;
}

.cfd-btn-cart:disabled:hover {
    background-color: #8c8f94;
    border-color: #787c82;
}

.cfd-cart-feedback {
    text-align: center;
    padding: 8px 10px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    margin-top: 6px;
    line-height: 1.4;
}

.cfd-cart-feedback-info {
    background-color: #e5f5fa;
    color: #1a6b7a;
    border: 1px solid #b3e0ed;
}

.cfd-cart-feedback-success {
    background-color: #edfaef;
    color: #1e7e34;
    border: 1px solid #b8e6c0;
}

.cfd-cart-feedback-error {
    background-color: #fce8e8;
    color: #b32d2e;
    border: 1px solid #f5baba;
}

/* === Carrito Agrupado: Lista de artes dentro del ítem base === */

.cfd-cart-arts-list {
    margin-top: 8px;
    padding: 8px 10px;
    background: #f8f9fa;
    border-radius: 3px;
    border-left: 3px solid #2271b1;
}

.cfd-cart-arts-list small {
    color: #555;
}

.cfd-cart-arts-list strong {
    color: #2c3338;
}
