/**
 * Lead CRM Pro – Public-facing stylesheet.
 * Forms, popups, fields, animations.
 *
 * @package LeadCRMPro
 */

/* ── Design tokens ──────────────────────────────────────────────────────────── */
:root {
    --lcrm-primary:       #4f46e5;
    --lcrm-primary-dark:  #3730a3;
    --lcrm-accent:        #06b6d4;
    --lcrm-success:       #22c55e;
    --lcrm-error:         #ef4444;
    --lcrm-text:          #1e293b;
    --lcrm-muted:         #64748b;
    --lcrm-border:        #e2e8f0;
    --lcrm-bg:            #ffffff;
    --lcrm-radius:        8px;
    --lcrm-shadow:        0 4px 24px rgba(0,0,0,.12);
    --lcrm-transition:    .2s ease;
    --lcrm-overlay-bg:    rgba(0,0,0,0.6);
}

/* ── Form Wrapper ───────────────────────────────────────────────────────────── */
.lcrm-form-wrap {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', sans-serif;
    background: var(--lcrm-bg);
    border-radius: var(--lcrm-radius);
    padding: 24px;
    box-sizing: border-box;
    color: var(--lcrm-text);
}

.lcrm-fields-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
}

/* ── Field width classes ────────────────────────────────────────────────────── */
.lcrm-field-w25  { flex: 0 0 calc(25% - 12px);  min-width: 120px; }
.lcrm-field-w33  { flex: 0 0 calc(33.33% - 11px); min-width: 150px; }
.lcrm-field-w50  { flex: 0 0 calc(50% - 8px);   min-width: 180px; }
.lcrm-field-w100 { flex: 0 0 100%; }

@media (max-width: 600px) {
    .lcrm-field-w25,
    .lcrm-field-w33,
    .lcrm-field-w50 { flex: 0 0 100%; }
}

/* ── Field wrap ─────────────────────────────────────────────────────────────── */
.lcrm-field-wrap {
    display: flex;
    flex-direction: column;
    gap: 6px;
    position: relative;
}

/* ── Labels ─────────────────────────────────────────────────────────────────── */
.lcrm-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--lcrm-text);
    letter-spacing: .01em;
}

.lcrm-required { color: var(--lcrm-error); margin-left: 2px; }

/* Floating labels */
.lcrm-label-floating .lcrm-field-wrap { padding-top: 14px; }
.lcrm-floating-label {
    position: absolute;
    top: 22px;
    left: 12px;
    font-size: 14px;
    color: var(--lcrm-muted);
    pointer-events: none;
    transition: all var(--lcrm-transition);
}
.lcrm-input:focus ~ .lcrm-floating-label,
.lcrm-input:not(:placeholder-shown) ~ .lcrm-floating-label,
.lcrm-textarea:focus ~ .lcrm-floating-label,
.lcrm-textarea:not(:placeholder-shown) ~ .lcrm-floating-label {
    top: 2px;
    font-size: 11px;
    color: var(--lcrm-primary);
    font-weight: 600;
}

/* ── Inputs ─────────────────────────────────────────────────────────────────── */
.lcrm-input,
.lcrm-textarea,
.lcrm-select {
    width: 100%;
    padding: 10px 14px;
    font-size: 14px;
    border: 1.5px solid var(--lcrm-border);
    border-radius: var(--lcrm-radius);
    background: #fafbfc;
    color: var(--lcrm-text);
    transition: border-color var(--lcrm-transition), box-shadow var(--lcrm-transition);
    box-sizing: border-box;
    font-family: inherit;
}

.lcrm-input:focus,
.lcrm-textarea:focus,
.lcrm-select:focus {
    outline: none;
    border-color: var(--lcrm-primary);
    box-shadow: 0 0 0 3px rgba(79,70,229,.15);
    background: #fff;
}

.lcrm-textarea { resize: vertical; min-height: 100px; }

/* ── Phone ──────────────────────────────────────────────────────────────────── */
.lcrm-phone-wrap { display: flex; gap: 8px; }
.lcrm-country-code { width: 120px; flex-shrink: 0; }
.lcrm-phone-input  { flex: 1; }

/* ── Radio & Checkbox ───────────────────────────────────────────────────────── */
.lcrm-radio-label,
.lcrm-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    cursor: pointer;
    margin-bottom: 4px;
}
.lcrm-radio-label input,
.lcrm-checkbox-label input {
    width: 16px; height: 16px;
    accent-color: var(--lcrm-primary);
    cursor: pointer;
}

/* ── GDPR ───────────────────────────────────────────────────────────────────── */
.lcrm-gdpr-label {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    font-size: 12px;
    color: var(--lcrm-muted);
    line-height: 1.5;
}
.lcrm-gdpr-checkbox {
    margin-top: 2px;
    width: 16px; height: 16px;
    accent-color: var(--lcrm-primary);
    flex-shrink: 0;
}

/* ── Rating / Stars ─────────────────────────────────────────────────────────── */
.lcrm-rating { display: flex; gap: 4px; }
.lcrm-star {
    font-size: 28px;
    color: #d1d5db;
    cursor: pointer;
    transition: color var(--lcrm-transition), transform var(--lcrm-transition);
    user-select: none;
}
.lcrm-star-active,
.lcrm-star-hover { color: #f59e0b; transform: scale(1.1); }

/* ── Signature Pad ──────────────────────────────────────────────────────────── */
.lcrm-signature-pad-wrap {
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.lcrm-signature-canvas {
    border: 1.5px solid var(--lcrm-border);
    border-radius: var(--lcrm-radius);
    background: #fff;
    touch-action: none;
    cursor: crosshair;
}
.lcrm-sig-clear {
    align-self: flex-start;
    font-size: 12px;
    color: var(--lcrm-muted);
    background: none;
    border: 1px solid var(--lcrm-border);
    border-radius: 4px;
    padding: 4px 10px;
    cursor: pointer;
}

/* ── File upload ────────────────────────────────────────────────────────────── */
.lcrm-input-file {
    font-size: 13px;
    padding: 8px;
    border: 1.5px dashed var(--lcrm-border);
    border-radius: var(--lcrm-radius);
    background: #f8fafc;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
}

/* ── Section divider ────────────────────────────────────────────────────────── */
.lcrm-section-divider hr { margin: 4px 0; border-color: var(--lcrm-border); }
.lcrm-section-label { margin: 4px 0 0; font-size: 15px; color: var(--lcrm-text); font-weight: 600; }

/* ── Validation errors ──────────────────────────────────────────────────────── */
.lcrm-field-error {
    font-size: 12px;
    color: var(--lcrm-error);
    min-height: 16px;
}
.lcrm-field-invalid .lcrm-input,
.lcrm-field-invalid .lcrm-textarea,
.lcrm-field-invalid .lcrm-select {
    border-color: var(--lcrm-error);
    box-shadow: 0 0 0 3px rgba(239,68,68,.12);
}

/* ── Submit button ──────────────────────────────────────────────────────────── */
.lcrm-form-footer { margin-top: 16px; }
.lcrm-submit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 28px;
    font-size: 15px;
    font-weight: 600;
    border: none;
    border-radius: var(--lcrm-radius);
    cursor: pointer;
    transition: opacity var(--lcrm-transition), transform var(--lcrm-transition);
    letter-spacing: .02em;
}
.lcrm-submit-btn:hover  { opacity: .9; transform: translateY(-1px); }
.lcrm-submit-btn:active { transform: translateY(0); }
.lcrm-submit-btn:disabled { opacity: .6; cursor: not-allowed; }

/* ── Form messages ──────────────────────────────────────────────────────────── */
.lcrm-form-msg {
    margin-top: 12px;
    padding: 10px 14px;
    border-radius: var(--lcrm-radius);
    font-size: 14px;
    display: none;
}
.lcrm-msg-success { background: #dcfce7; color: #166534; border-left: 4px solid var(--lcrm-success); }
.lcrm-msg-error   { background: #fee2e2; color: #991b1b; border-left: 4px solid var(--lcrm-error); }

/* ═══════════════════════════════════════════════════════════════════════════════
   POPUP ENGINE
   ═══════════════════════════════════════════════════════════════════════════════ */

.lcrm-popup-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    background: var(--lcrm-overlay-bg);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Position variants */
.lcrm-popup-pos-top    { align-items: flex-start; }
.lcrm-popup-pos-bottom { align-items: flex-end; }
.lcrm-popup-pos-left   { justify-content: flex-start; }
.lcrm-popup-pos-right  { justify-content: flex-end; }
.lcrm-popup-pos-fullscreen .lcrm-popup-inner { width: 100%; height: 100vh; border-radius: 0; max-height: 100vh; overflow-y: auto; }

.lcrm-popup-inner {
    position: relative;
    background: #fff;
    border-radius: 12px;
    box-shadow: var(--lcrm-shadow);
    max-width: 560px;
    width: calc(100% - 32px);
    max-height: 90vh;
    overflow-y: auto;
    animation-duration: .3s;
    animation-fill-mode: both;
}

/* Animations */
.lcrm-popup-anim-fade   .lcrm-popup-inner { animation-name: lcrmFadeIn; }
.lcrm-popup-anim-slide  .lcrm-popup-inner { animation-name: lcrmSlideUp; }
.lcrm-popup-anim-zoom   .lcrm-popup-inner { animation-name: lcrmZoomIn; }

@keyframes lcrmFadeIn   { from { opacity: 0; }                   to { opacity: 1; } }
@keyframes lcrmSlideUp  { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }
@keyframes lcrmZoomIn   { from { opacity: 0; transform: scale(.85); }      to { opacity: 1; transform: scale(1); } }

/* Slide-in variants override inner position */
.lcrm-popup-pos-left  .lcrm-popup-inner,
.lcrm-popup-pos-right .lcrm-popup-inner {
    border-radius: 0;
    max-width: 400px;
    height: 100vh;
    max-height: 100vh;
}

.lcrm-popup-close {
    position: absolute;
    top: 12px; right: 14px;
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--lcrm-muted);
    transition: color var(--lcrm-transition);
    z-index: 1;
    line-height: 1;
}
.lcrm-popup-close:hover { color: var(--lcrm-text); }
