/**
 * DB CRM - Embed Form Styles
 * Stili standalone per form embeddabile
 * 
 * @package DB_CRM
 * @since 1.4.0
 */

/* ============================================
   RESET E BASE
   ============================================ */
.db-crm-embed-form {
    --embed-primary: #2563eb;
    --embed-primary-dark: #1d4ed8;
    --embed-success: #16a34a;
    --embed-danger: #dc2626;
    --embed-gray-50: #f9fafb;
    --embed-gray-100: #f3f4f6;
    --embed-gray-200: #e5e7eb;
    --embed-gray-300: #d1d5db;
    --embed-gray-400: #9ca3af;
    --embed-gray-500: #6b7280;
    --embed-gray-600: #4b5563;
    --embed-gray-700: #374151;
    --embed-gray-800: #1f2937;
    --embed-gray-900: #111827;
    --embed-radius: 8px;
    --embed-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --embed-shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
    
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--embed-gray-800);
    box-sizing: border-box;
    max-width: 480px;
    margin: 0 auto;
    padding: 24px;
}

.db-crm-embed-form *,
.db-crm-embed-form *::before,
.db-crm-embed-form *::after {
    box-sizing: border-box;
}

/* ============================================
   HEADER
   ============================================ */
.db-crm-embed-header {
    text-align: center;
    margin-bottom: 24px;
}

.db-crm-embed-header h3 {
    margin: 0 0 8px 0;
    font-size: 24px;
    font-weight: 700;
    color: var(--embed-gray-900);
}

.db-crm-embed-header p {
    margin: 0;
    color: var(--embed-gray-500);
    font-size: 14px;
}

/* ============================================
   HONEYPOT (nascosto)
   ============================================ */
.db-crm-hp-field {
    position: absolute;
    left: -9999px;
    top: -9999px;
    opacity: 0;
    height: 0;
    width: 0;
    overflow: hidden;
}

/* ============================================
   ERRORI E MESSAGGI
   ============================================ */
.db-crm-embed-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: var(--embed-danger);
    padding: 12px 16px;
    border-radius: var(--embed-radius);
    margin-bottom: 16px;
    font-size: 14px;
}

.db-crm-embed-field-error {
    display: block;
    color: var(--embed-danger);
    font-size: 12px;
    margin-top: 4px;
}

/* ============================================
   CAMPI
   ============================================ */
.db-crm-embed-fields {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.db-crm-embed-field {
    display: flex;
    flex-direction: column;
}

.db-crm-embed-field-full {
    grid-column: 1 / -1;
}

.db-crm-embed-field label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--embed-gray-700);
    margin-bottom: 6px;
}

.db-crm-embed-field label .required {
    color: var(--embed-danger);
}

.db-crm-embed-field label .optional {
    color: var(--embed-gray-400);
    font-weight: 400;
    font-size: 12px;
}

.db-crm-embed-field input[type="text"],
.db-crm-embed-field input[type="email"],
.db-crm-embed-field input[type="tel"] {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--embed-gray-300);
    border-radius: var(--embed-radius);
    font-size: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: white;
}

.db-crm-embed-field input:focus {
    outline: none;
    border-color: var(--embed-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.db-crm-embed-field input.error {
    border-color: var(--embed-danger);
}

.db-crm-embed-field input::placeholder {
    color: var(--embed-gray-400);
}

/* ============================================
   CONSENSI
   ============================================ */
.db-crm-embed-consents {
    margin-bottom: 24px;
}

.db-crm-embed-consent {
    margin-bottom: 12px;
}

.db-crm-embed-consent label {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--embed-gray-600);
    line-height: 1.4;
}

.db-crm-embed-consent label.error {
    color: var(--embed-danger);
}

.db-crm-embed-consent input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--embed-primary);
}

.db-crm-embed-consent .consent-text {
    flex: 1;
}

.db-crm-embed-consent .consent-text a {
    color: var(--embed-primary);
    text-decoration: none;
}

.db-crm-embed-consent .consent-text a:hover {
    text-decoration: underline;
}

.db-crm-embed-consent .required {
    color: var(--embed-danger);
}

/* ============================================
   BOTTONE SUBMIT
   ============================================ */
.db-crm-embed-submit {
    margin-bottom: 16px;
}

.db-crm-embed-btn {
    width: 100%;
    padding: 14px 24px;
    background: var(--embed-primary);
    color: white;
    border: none;
    border-radius: var(--embed-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.db-crm-embed-btn:hover:not(:disabled) {
    background: var(--embed-primary-dark);
}

.db-crm-embed-btn:active:not(:disabled) {
    transform: scale(0.98);
}

.db-crm-embed-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Spinner */
.db-crm-embed-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: embed-spin 0.8s linear infinite;
}

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

/* ============================================
   FOOTER
   ============================================ */
.db-crm-embed-footer {
    text-align: center;
}

.db-crm-embed-footer p {
    margin: 0;
    font-size: 12px;
    color: var(--embed-gray-400);
}

/* ============================================
   SUCCESSO
   ============================================ */
.db-crm-embed-success {
    text-align: center;
    padding: 40px 20px;
}

.db-crm-embed-success-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    background: #dcfce7;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.db-crm-embed-success-icon svg {
    width: 32px;
    height: 32px;
    color: var(--embed-success);
}

.db-crm-embed-success h3 {
    margin: 0 0 8px 0;
    font-size: 20px;
    font-weight: 600;
    color: var(--embed-gray-900);
}

.db-crm-embed-success p {
    margin: 0;
    color: var(--embed-gray-500);
    font-size: 14px;
}

/* ============================================
   UTILITY
   ============================================ */
[x-cloak] {
    display: none !important;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 480px) {
    .db-crm-embed-form {
        padding: 16px;
    }
    
    .db-crm-embed-fields {
        grid-template-columns: 1fr;
    }
    
    .db-crm-embed-header h3 {
        font-size: 20px;
    }
}
