/* ==========================================================================
   Pedido de Cotação — Painel flutuante, Modal e Botões
   ========================================================================== */

/* --- Botão flutuante -------------------------------------------------- */
.cl-cotacao-toggle {
    position: fixed;
    bottom: 32px;
    right: 32px;
    z-index: 9990;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #e87722;
    color: #fff;
    border: none;
    border-radius: 50px;
    padding: 12px 20px 12px 16px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(232, 119, 34, 0.45);
    transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}

.cl-cotacao-toggle:hover {
    background: #cf6710;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(232, 119, 34, 0.55);
}

.cl-cotacao-badge {
    background: #1a1a2e;
    color: #fff;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* --- Painel lateral --------------------------------------------------- */
.cl-cotacao-panel {
    position: fixed;
    top: 0;
    right: -420px;
    width: 400px;
    max-width: 95vw;
    height: 100vh;
    background: #fff;
    z-index: 9995;
    display: flex;
    flex-direction: column;
    box-shadow: -4px 0 24px rgba(0,0,0,0.18);
    transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.cl-cotacao-panel.is-open {
    right: 0;
}

.cl-cotacao-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e5e5;
    background: #1a1a2e;
    color: #fff;
}

.cl-cotacao-panel-header h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: #fff;
}

.cl-cotacao-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.15s;
}

.cl-cotacao-close:hover {
    opacity: 1;
}

.cl-cotacao-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

.cl-cotacao-vazio {
    color: #888;
    text-align: center;
    margin-top: 40px;
    font-size: 14px;
}

/* --- Lista de peças no painel ---------------------------------------- */
.cl-cotacao-lista {
    list-style: none;
    padding: 0;
    margin: 0;
}

.cl-cotacao-lista li {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 0;
    border-bottom: 1px solid #f0f0f0;
}

.cl-cotacao-lista li:last-child {
    border-bottom: none;
}

.cl-cotacao-item-thumb {
    width: 52px;
    height: 52px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.cl-cotacao-item-thumb-placeholder {
    width: 52px;
    height: 52px;
    background: #f4f4f4;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #bbb;
    font-size: 22px;
    flex-shrink: 0;
}

.cl-cotacao-item-info {
    flex: 1;
    min-width: 0;
}

.cl-cotacao-item-titulo {
    font-size: 13px;
    font-weight: 600;
    color: #1a1a2e;
    margin: 0 0 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cl-cotacao-item-codigo {
    font-size: 11px;
    color: #888;
    font-family: monospace;
}

.cl-cotacao-item-remove {
    background: none;
    border: none;
    color: #ccc;
    font-size: 18px;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    line-height: 1;
    flex-shrink: 0;
    transition: color 0.15s;
}

.cl-cotacao-item-remove:hover {
    color: #e53935;
}

/* --- Rodapé do painel ------------------------------------------------ */
.cl-cotacao-panel-footer {
    padding: 16px 20px;
    border-top: 1px solid #e5e5e5;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.cl-cotacao-btn-enviar {
    width: 100%;
    background: #e87722;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 13px 20px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.cl-cotacao-btn-enviar:hover {
    background: #cf6710;
}

.cl-cotacao-btn-limpar {
    background: none;
    border: 1px solid #ddd;
    border-radius: 6px;
    color: #888;
    padding: 8px 20px;
    font-size: 13px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s;
}

.cl-cotacao-btn-limpar:hover {
    border-color: #e53935;
    color: #e53935;
}

/* --- Overlay ---------------------------------------------------------- */
.cl-cotacao-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 9985;
}

/* --- Modal de formulário --------------------------------------------- */
.cl-cotacao-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.cl-cotacao-modal-inner {
    background: #fff;
    border-radius: 12px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 8px 40px rgba(0,0,0,0.25);
    animation: cl-modal-in 0.2s ease;
}

@keyframes cl-modal-in {
    from { opacity: 0; transform: scale(0.95) translateY(-10px); }
    to   { opacity: 1; transform: scale(1) translateY(0); }
}

.cl-cotacao-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e5e5;
}

.cl-cotacao-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
    color: #1a1a2e;
}

.cl-cotacao-modal-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    color: #999;
    border-radius: 4px;
    line-height: 1;
    transition: color 0.15s;
}

.cl-cotacao-modal-close:hover {
    color: #333;
}

.cl-cotacao-modal-body {
    padding: 24px;
}

/* --- Formulário ------------------------------------------------------- */
.cl-form-group {
    margin-bottom: 16px;
}

.cl-form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin-bottom: 6px;
}

.cl-form-group input,
.cl-form-group textarea {
    width: 100%;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 14px;
    color: #222;
    background: #fafafa;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
    font-family: inherit;
}

.cl-form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.cl-form-group input:focus,
.cl-form-group textarea:focus {
    outline: none;
    border-color: #e87722;
    box-shadow: 0 0 0 3px rgba(232, 119, 34, 0.15);
    background: #fff;
}

.cl-form-group input.cl-input-error,
.cl-form-group textarea.cl-input-error {
    border-color: #e53935;
    box-shadow: 0 0 0 3px rgba(229, 57, 53, 0.12);
}

/* --- Secção do formulário -------------------------------------------- */
.cl-form-section {
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    padding: 16px 16px 8px;
    margin-bottom: 16px;
    background: #fafafa;
}

.cl-form-section-titulo {
    font-size: 13px;
    font-weight: 700;
    color: #1a1a2e;
    margin: 0 0 14px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cl-form-section .cl-form-group:last-child {
    margin-bottom: 8px;
}

/* --- Área de upload de ficheiros ------------------------------------- */
.cl-file-upload-area {
    position: relative;
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 20px 16px 12px;
    background: #fff;
    transition: border-color 0.2s, background 0.2s;
    cursor: pointer;
}

.cl-file-upload-area:hover,
.cl-file-upload-area:focus-within {
    border-color: #e87722;
    background: #fff8f3;
}

.cl-file-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.cl-file-upload-label {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    pointer-events: none;
    text-align: center;
}

.cl-file-icon {
    font-size: 24px;
    margin-bottom: 2px;
}

.cl-file-text {
    font-size: 13px;
    color: #555;
    font-weight: 500;
}

.cl-file-hint {
    font-size: 11px;
    color: #aaa;
}

/* --- Lista de pré-visualização de ficheiros -------------------------- */
.cl-file-preview-list {
    list-style: none;
    padding: 0;
    margin: 10px 0 0;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.cl-file-preview-item {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f0f7ff;
    border: 1px solid #c8dfff;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
}

.cl-file-preview-icon {
    flex-shrink: 0;
    font-size: 14px;
}

.cl-file-preview-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #1a1a2e;
    font-weight: 500;
}

.cl-file-preview-size {
    flex-shrink: 0;
    color: #888;
}

.cl-file-preview-note {
    font-size: 12px;
    color: #e87722;
    font-style: italic;
    padding: 4px 0;
}

.cl-form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.cl-obrig {
    color: #e53935;
    margin-left: 2px;
}

.cl-opcional {
    color: #aaa;
    font-size: 11px;
    font-weight: 400;
    margin-left: 4px;
}

.cl-form-obrig-note {
    font-size: 12px;
    color: #888;
    margin: 0 0 16px;
}

/* --- Mensagem de feedback -------------------------------------------- */
.cl-form-msg {
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 14px;
    margin-bottom: 16px;
}

.cl-form-msg.is-success {
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #a5d6a7;
}

.cl-form-msg.is-error {
    background: #ffebee;
    color: #c62828;
    border: 1px solid #ef9a9a;
}

/* --- Ações do formulário --------------------------------------------- */
.cl-form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 8px;
}

.cl-btn-cancelar {
    background: none;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 10px 20px;
    font-size: 14px;
    color: #666;
    cursor: pointer;
    transition: border-color 0.15s;
}

.cl-btn-cancelar:hover {
    border-color: #999;
}

.cl-btn-submit {
    background: #e87722;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

.cl-btn-submit:hover:not(:disabled) {
    background: #cf6710;
}

.cl-btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* --- Botão "Adicionar ao Pedido" nas cards e single page ------------- */
.cl-btn-adicionar-cotacao {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #1a1a2e;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.15s;
    white-space: nowrap;
}

.cl-btn-adicionar-cotacao:hover {
    background: #e87722;
    transform: translateY(-1px);
}

.cl-btn-adicionar-cotacao.is-added {
    background: #2e7d32;
}

.cl-btn-adicionar-cotacao.is-added:hover {
    background: #1b5e20;
}

/* Botão na grelha (abaixo do item) */
.cl-grelha-item .cl-btn-adicionar-cotacao {
    width: 100%;
    justify-content: center;
    border-radius: 0 0 7px 7px;
    margin-top: -1px;
}

/* Botão na página single */
.cl-single-cotacao-wrap {
    margin: 24px 0;
}

.cl-single-cotacao-wrap .cl-btn-adicionar-cotacao {
    padding: 12px 24px;
    font-size: 15px;
}

/* --- Popover de quantidade -------------------------------------------- */
.cl-qty-popover {
    position: absolute;
    z-index: 9998;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 16px 18px 14px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.16);
    min-width: 200px;
    text-align: center;
}

.cl-qty-popover-label {
    font-size: 13px;
    font-weight: 600;
    color: #333;
    margin: 0 0 12px;
}

.cl-qty-controls {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 12px;
}

.cl-qty-btn {
    width: 32px;
    height: 32px;
    border: 1px solid #ddd;
    background: #f5f5f5;
    border-radius: 6px;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    color: #333;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cl-qty-btn:hover {
    background: #e0e0e0;
}

.cl-qty-input {
    width: 56px;
    height: 32px;
    border: 1px solid #ddd;
    border-radius: 6px;
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    color: #1a1a2e;
    -moz-appearance: textfield;
}

.cl-qty-input::-webkit-inner-spin-button,
.cl-qty-input::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.cl-qty-input:focus {
    outline: none;
    border-color: #e87722;
    box-shadow: 0 0 0 2px rgba(232, 119, 34, 0.18);
}

.cl-qty-actions {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.cl-qty-cancelar {
    background: none;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 6px 14px;
    font-size: 13px;
    color: #888;
    cursor: pointer;
    transition: border-color 0.15s;
}

.cl-qty-cancelar:hover {
    border-color: #bbb;
    color: #555;
}

.cl-qty-confirmar {
    background: #e87722;
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 18px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
}

.cl-qty-confirmar:hover {
    background: #cf6710;
}

/* Seta decorativa do popover */
.cl-qty-arrow {
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-bottom: 8px solid #fff;
    filter: drop-shadow(0 -1px 0 #e0e0e0);
}

/* --- Controlos de quantidade no painel -------------------------------- */
.cl-cotacao-item-qty {
    display: flex;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
    margin-right: 4px;
}

.cl-qty-mini-btn {
    width: 24px;
    height: 24px;
    border: 1px solid #e0e0e0;
    background: #f5f5f5;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    cursor: pointer;
    color: #555;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    padding: 0;
}

.cl-qty-mini-btn:hover {
    background: #e0e0e0;
}

.cl-qty-mini-val {
    min-width: 24px;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    color: #1a1a2e;
}

/* --- Responsive ------------------------------------------------------- */
@media (max-width: 600px) {
    .cl-cotacao-toggle-label {
        display: none;
    }

    .cl-cotacao-toggle {
        padding: 14px;
        border-radius: 50%;
    }

    .cl-form-row {
        grid-template-columns: 1fr;
    }

    .cl-cotacao-panel {
        width: 100vw;
        right: -100vw;
    }
}
