/**
 * SmarQuotes - Frontend Styles
 *
 * @package SmarQuotes
 * @since 2.2.0
 */

/* ============================================
   Variáveis de fallback (usadas fora do modal)
   ============================================ */
:root {
    --wsq-primary: var(--e-global-color-primary, #0073aa);
    --wsq-primary-hover: #005a87;
    --wsq-success: #28a745;
    --wsq-danger: #dc3545;
    --wsq-border: rgba(0,0,0,.15);
    --wsq-radius: var(--e-global-border-radius, 4px);
    --wsq-shadow-lg: 0 5px 25px rgba(0,0,0,.15);
}

/* ============================================
   Reset base — não força font-family no modal
   ============================================ */
.wsq-modal-overlay *,
.wsq-quote-widget * {
    box-sizing: border-box;
}

/* ============================================
   Widget Flutuante
   ============================================ */
.wsq-quote-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999998;
}

.wsq-widget-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    background-color: var(--wsq-primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0,0,0,.2);
    transition: transform 0.2s, box-shadow 0.2s;
    position: relative;
}

.wsq-widget-trigger:hover {
    transform: scale(1.07);
    box-shadow: 0 6px 20px rgba(0,0,0,.25);
}

.wsq-widget-icon { width: 24px; height: 24px; }

.wsq-widget-count {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 20px;
    height: 20px;
    background: var(--wsq-danger);
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 5px;
}

.wsq-widget-count[data-count="0"] { display: none; }

/* ============================================
   Modal Overlay
   ============================================ */
.wsq-modal-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, visibility 0.25s;
}

.wsq-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   Modal — herda tipografia e cor do tema ativo
   ============================================ */
.wsq-modal {
    background: #fff;
    color: inherit;
    font-family: inherit;
    font-size: inherit;
    line-height: inherit;
    border-radius: var(--wsq-radius);
    box-shadow: 0 10px 48px rgba(0,0,0,.18);
    width: 92%;
    max-width: 540px;
    max-height: 92vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transform: translateY(-12px);
    transition: transform 0.25s;
}

.wsq-modal-overlay.active .wsq-modal { transform: translateY(0); }

.wsq-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(0,0,0,.1);
}

.wsq-modal-title {
    margin: 0;
    font-size: 1.1em;
    font-weight: 700;
    color: inherit;
    font-family: inherit;
    line-height: 1.3;
}

.wsq-modal-close {
    background: none;
    border: none;
    font-size: 20px;
    line-height: 1;
    color: inherit;
    opacity: .45;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 3px;
    transition: opacity 0.15s;
    flex-shrink: 0;
}

.wsq-modal-close:hover { opacity: .9; }

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

/* ============================================
   Passos do formulário
   ============================================ */
.wsq-form-step { display: none; }
.wsq-form-step.active { display: block; }

.wsq-step-title {
    margin: 0 0 16px;
    font-size: 1em;
    font-weight: 600;
    color: inherit;
    font-family: inherit;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--wsq-primary);
}

/* ============================================
   Itens do carrinho
   ============================================ */
.wsq-cart-items {
    max-height: 220px;
    overflow-y: auto;
    margin-bottom: 12px;
}

.wsq-cart-empty {
    text-align: center;
    padding: 30px 20px;
    opacity: .6;
    font-style: italic;
}

.wsq-cart-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border: 1px solid rgba(0,0,0,.1);
    border-radius: var(--wsq-radius);
    margin-bottom: 8px;
}

.wsq-cart-item-info { flex: 1; min-width: 0; }

.wsq-cart-item-name {
    display: block;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: .95em;
}

.wsq-cart-item-sku {
    display: block;
    font-size: .78em;
    opacity: .55;
}

.wsq-cart-item-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 12px;
    flex-shrink: 0;
}

.wsq-quantity-control {
    display: flex;
    align-items: center;
    border: 1px solid rgba(0,0,0,.15);
    border-radius: var(--wsq-radius);
    overflow: hidden;
}

.wsq-qty-btn {
    width: 28px;
    height: 28px;
    background: rgba(0,0,0,.04);
    border: none;
    font-size: 15px;
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.wsq-qty-btn:hover { background: rgba(0,0,0,.1); }

.wsq-qty-input {
    width: 40px;
    height: 28px;
    border: none;
    border-left: 1px solid rgba(0,0,0,.12);
    border-right: 1px solid rgba(0,0,0,.12);
    text-align: center;
    font-size: .9em;
    background: transparent;
    color: inherit;
    font-family: inherit;
}

.wsq-cart-item-price {
    font-weight: 600;
    font-size: .9em;
    min-width: 70px;
    text-align: right;
    color: var(--wsq-primary);
}

.wsq-remove-item {
    width: 26px;
    height: 26px;
    background: var(--wsq-danger);
    color: #fff;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    opacity: .75;
    transition: opacity 0.15s;
    padding: 0;
}

.wsq-remove-item:hover { opacity: 1; }

/* ============================================
   Resumo do carrinho
   ============================================ */
.wsq-cart-summary {
    border-top: 1px solid rgba(0,0,0,.1);
    padding-top: 12px;
    margin-bottom: 12px;
}

.wsq-cart-total {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
    font-size: 1em;
}

.wsq-cart-total-value {
    color: var(--wsq-primary);
    font-size: 1.1em;
}

/* ============================================
   Grupos de formulário — herda do tema
   ============================================ */
.wsq-form-group { margin-bottom: 14px; }

.wsq-form-label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: .9em;
    color: inherit;
    font-family: inherit;
}

.wsq-form-input,
.wsq-form-select,
.wsq-form-textarea {
    width: 100%;
    padding: .6em .8em;
    border: 1px solid rgba(0,0,0,.2);
    border-radius: var(--wsq-radius);
    background: transparent;
    color: inherit;
    font-family: inherit;
    font-size: 1em;
    line-height: 1.5;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.wsq-form-input:focus,
.wsq-form-select:focus,
.wsq-form-textarea:focus {
    outline: none;
    border-color: var(--wsq-primary);
    box-shadow: 0 0 0 2px rgba(0,0,0,.06);
}

.wsq-form-input.error,
.wsq-form-select.error,
.wsq-form-textarea.error { border-color: var(--wsq-danger); }

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

.wsq-form-hint {
    display: block;
    margin-top: 3px;
    font-size: .78em;
    opacity: .55;
}

/* ============================================
   Telefone (intl-tel-input)
   ============================================ */
.iti { width: 100%; }

.iti__flag {
    background-image: url('https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.15/img/flags.png');
}

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .iti__flag {
        background-image: url('https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.15/img/flags@2x.png');
    }
}

/* ============================================
   Tipo de cliente (radio)
   ============================================ */
.wsq-customer-type {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

.wsq-radio-label {
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    font-size: .95em;
}

.wsq-radio-input { cursor: pointer; }

/* ============================================
   ID Fiscal
   ============================================ */
.wsq-tax-id-wrapper { display: flex; gap: 8px; }
.wsq-tax-type { width: 130px; flex-shrink: 0; }
.wsq-tax-id-input { flex: 1; }

/* ============================================
   Checkbox de privacidade
   ============================================ */
.wsq-privacy-group {
    margin-top: 14px;
    padding: 12px;
    border: 1px solid rgba(0,0,0,.1);
    border-radius: var(--wsq-radius);
    background: rgba(0,0,0,.02);
}

.wsq-checkbox-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
}

.wsq-checkbox-input { margin-top: 2px; cursor: pointer; flex-shrink: 0; }

.wsq-checkbox-text {
    font-size: .9em;
    color: inherit;
    line-height: 1.4;
}

/* ============================================
   Ações do formulário — botões herdam do tema
   ============================================ */
.wsq-form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 18px;
    padding-top: 14px;
    border-top: 1px solid rgba(0,0,0,.08);
}

.wsq-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: .6em 1.3em;
    border-radius: var(--wsq-radius);
    font-family: inherit;
    font-size: .95em;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.4;
    transition: filter 0.15s, opacity 0.15s;
    border: none;
}

.wsq-btn-primary {
    background: var(--wsq-primary);
    color: #fff !important;
}

.wsq-btn-primary:hover { filter: brightness(1.1); }

.wsq-btn-secondary {
    background: transparent;
    color: inherit;
    border: 1px solid currentColor;
    opacity: .65;
}

.wsq-btn-secondary:hover { opacity: 1; }

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

/* ============================================
   Mensagem de sucesso
   ============================================ */
.wsq-success-message { text-align: center; padding: 32px 20px; }

.wsq-success-icon {
    width: 64px; height: 64px;
    margin: 0 auto 16px;
    background: var(--wsq-success);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: bold;
}

.wsq-success-message h3 {
    margin: 0 0 10px;
    color: var(--wsq-success);
    font-family: inherit;
}

.wsq-success-message p {
    opacity: .7;
    margin-bottom: 20px;
    font-family: inherit;
}

/* ============================================
   Botão de orçamento — single product
   ============================================ */
.wsq-add-to-quote-button {
    background: var(--wsq-primary);
    color: #fff !important;
    border: none;
    padding: .7em 1.4em;
    border-radius: var(--wsq-radius);
    font-family: inherit;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s;
    width: 100%;
    margin-top: 10px;
    display: block;
    text-align: center;
}

.wsq-add-to-quote-button:hover { filter: brightness(1.1); }
.wsq-add-to-quote-button.added { background: var(--wsq-success); }

/* ============================================
   Oculta botão nativo (Elementor + temas)
   ============================================ */
.wsq-quotes-active .single_add_to_cart_button,
.wsq-quotes-active .woocommerce-variation-add-to-cart,
.wsq-quotes-active .elementor-add-to-cart .quantity,
.wsq-quotes-active .elementor-add-to-cart .single_add_to_cart_button,
.wsq-quotes-active .add_to_cart_button,
.wsq-quotes-active .product_type_simple.add_to_cart_button,
.wsq-quotes-active .product_type_variable.add_to_cart_button {
    display: none !important;
}

/* ============================================
   Botão em loops e widgets
   ============================================ */
.wsq-add-to-quote-button-loop,
.wsq-add-to-quote-button-widget {
    background: var(--wsq-primary);
    color: #fff !important;
    border: none;
    border-radius: var(--wsq-radius);
    font-family: inherit;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s;
    display: inline-block !important;
    text-align: center;
    text-decoration: none;
    line-height: 1.5;
    visibility: visible !important;
    opacity: 1 !important;
}

.wsq-add-to-quote-button-loop {
    width: 100%;
    padding: .6em 1em;
    font-size: .9em;
    margin-top: 8px;
}

.wsq-add-to-quote-button-widget {
    width: 100%;
    padding: .5em .9em;
    font-size: .85em;
    margin-top: 6px;
}

.wsq-add-to-quote-button-loop:hover,
.wsq-add-to-quote-button-widget:hover { filter: brightness(1.1); }

.wsq-add-to-quote-button-loop.added,
.wsq-add-to-quote-button-widget.added { background: var(--wsq-success); }

/* ============================================
   Página de aceite da proposta
   ============================================ */
.wsq-proposal-container {
    max-width: 900px;
    margin: 40px auto;
    padding: 30px;
    font-family: inherit;
    color: inherit;
}

.wsq-proposal-container * {
    box-sizing: border-box;
}

.wsq-proposal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid rgba(0,0,0,.1);
}

.wsq-proposal-title { margin: 0; font-size: 1.6em; }

.wsq-proposal-status {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: .8em;
    font-weight: 700;
    text-transform: uppercase;
}

.wsq-status-received    { background: #0073aa; color: #fff; }
.wsq-status-draft       { background: #6c757d; color: #fff; }
.wsq-status-proposal_sent  { background: #28a745; color: #fff; }
.wsq-status-in_negotiation { background: #ffc107; color: #333; }
.wsq-status-approved    { background: #28a745; color: #fff; }
.wsq-status-rejected    { background: #dc3545; color: #fff; }
.wsq-status-expired     { background: #6c757d; color: #fff; }
.wsq-status-converted   { background: #17a2b8; color: #fff; }

.wsq-proposal-section { margin-bottom: 28px; }

.wsq-section-title {
    margin: 0 0 14px;
    font-size: 1.1em;
    font-weight: 600;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(0,0,0,.1);
}

.wsq-proposal-info p { margin: 6px 0; }
.wsq-validity-date { font-weight: 500; color: #e67e22; }

.wsq-items-table { width: 100%; border-collapse: collapse; }

.wsq-items-table th,
.wsq-items-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid rgba(0,0,0,.08);
}

.wsq-items-table th { font-weight: 600; background: rgba(0,0,0,.03); }
.wsq-items-table .wsq-quantity { text-align: center; }
.wsq-items-table .wsq-unit-price,
.wsq-items-table .wsq-total-price { text-align: right; white-space: nowrap; }
.wsq-items-table .wsq-empty { text-align: center; opacity: .55; padding: 20px !important; }

.wsq-proposal-totals {
    background: rgba(0,0,0,.03);
    padding: 18px;
    border-radius: var(--wsq-radius);
    border: 1px solid rgba(0,0,0,.08);
}

.wsq-total-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(0,0,0,.07);
}

.wsq-total-row:last-child { border-bottom: none; }
.wsq-total-grand { font-size: 1.15em; font-weight: 700; }
.wsq-grand-total { color: var(--wsq-primary); }

.wsq-proposal-actions {
    display: flex;
    gap: 14px;
    justify-content: center;
    margin-top: 28px;
    padding-top: 28px;
    border-top: 2px solid rgba(0,0,0,.08);
}

/* Botões de ação da proposta — herdam estilo WooCommerce */
.wsq-btn-success {
    background: var(--wsq-success);
    color: #fff !important;
}
.wsq-btn-success:hover { filter: brightness(1.08); }

.wsq-btn-warning {
    background: #e67e22;
    color: #fff !important;
}
.wsq-btn-warning:hover { filter: brightness(1.08); }

.wsq-btn-danger {
    background: var(--wsq-danger);
    color: #fff !important;
}
.wsq-btn-danger:hover { filter: brightness(1.08); }

/* ============================================
   Modais de contra-proposta e recusa
   ============================================ */
#wsq-counter-modal,
#wsq-reject-modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,.65);
    display: none;
    z-index: 999999;
    align-items: center;
    justify-content: center;
}

#wsq-counter-modal.active,
#wsq-reject-modal.active { display: flex; }

#wsq-counter-modal .wsq-modal,
#wsq-reject-modal .wsq-modal {
    background: #fff;
    color: inherit;
    font-family: inherit;
    border-radius: var(--wsq-radius);
    box-shadow: 0 10px 40px rgba(0,0,0,.2);
    max-width: 480px;
    width: 92%;
    max-height: 90vh;
    overflow-y: auto;
}

/* ============================================
   Alertas
   ============================================ */
.wsq-alert { padding: 12px 16px; border-radius: var(--wsq-radius); margin-bottom: 16px; font-size: .9em; }
.wsq-alert-success { background: #d4edda; border: 1px solid #c3e6cb; color: #155724; }
.wsq-alert-warning { background: #fff3cd; border: 1px solid #ffeaa7; color: #856404; }
.wsq-alert-danger  { background: #f8d7da; border: 1px solid #f5c6cb; color: #721c24; }
.wsq-alert-info    { background: #d1ecf1; border: 1px solid #bee5eb; color: #0c5460; }

/* ============================================
   Loading
   ============================================ */
.wsq-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px;
    opacity: .6;
}

.wsq-loading::after {
    content: '';
    width: 26px; height: 26px;
    margin-left: 10px;
    border: 3px solid rgba(0,0,0,.15);
    border-top-color: var(--wsq-primary);
    border-radius: 50%;
    animation: wsq-spin 0.8s linear infinite;
}

@keyframes wsq-spin { to { transform: rotate(360deg); } }

/* ============================================
   Toast Notifications
   ============================================ */
.wsq-toast-notification {
    position: fixed;
    top: 20px; right: 20px;
    max-width: 380px; min-width: 280px;
    padding: 14px 16px;
    background: #fff;
    border-radius: var(--wsq-radius);
    box-shadow: 0 4px 20px rgba(0,0,0,.15);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 9999999;
    opacity: 0;
    transform: translateX(400px);
    transition: opacity 0.25s, transform 0.25s;
    cursor: pointer;
    border-left: 4px solid;
    font-family: inherit;
    color: #333;
}

.wsq-toast-notification.wsq-toast-show { opacity: 1; transform: translateX(0); }
.wsq-toast-success  { border-left-color: var(--wsq-success); }
.wsq-toast-error    { border-left-color: var(--wsq-danger); }
.wsq-toast-warning  { border-left-color: #e67e22; }
.wsq-toast-info     { border-left-color: var(--wsq-primary); }

.wsq-toast-icon { font-size: 18px; font-weight: bold; flex-shrink: 0; }
.wsq-toast-message { flex: 1; font-size: .9em; line-height: 1.4; }

.wsq-toast-close {
    background: transparent; border: none;
    font-size: 18px; opacity: .4; cursor: pointer;
    padding: 0; flex-shrink: 0;
    transition: opacity 0.15s;
}

.wsq-toast-close:hover { opacity: .9; }

@media (max-width: 480px) {
    .wsq-toast-notification {
        top: 10px; right: 10px; left: 10px;
        max-width: none; min-width: auto;
        transform: translateY(-80px);
    }
    .wsq-toast-notification.wsq-toast-show { transform: translateY(0); }
}

/* ============================================
   Utilitários
   ============================================ */
.wsq-hidden { display: none !important; }
.wsq-error { color: var(--wsq-danger); font-size: .8em; margin-top: 4px; }

/* ============================================
   Responsividade
   ============================================ */
@media (max-width: 768px) {
    .wsq-modal { width: 96%; max-height: 96vh; }
    .wsq-proposal-container { margin: 16px; padding: 18px; }
    .wsq-proposal-header { flex-direction: column; gap: 12px; text-align: center; }
    .wsq-proposal-actions { flex-direction: column; }
    .wsq-proposal-actions .wsq-btn { width: 100%; }
    .wsq-tax-id-wrapper { flex-direction: column; }
    .wsq-tax-type { width: 100%; }
    .wsq-cart-item-actions { gap: 6px; }
    .wsq-items-table th, .wsq-items-table td { padding: 7px 6px; font-size: .85em; }
}
