/* ==================== CRM ADD MODULE ==================== */
/* Original modal styles (kept for constructor) */
.crm-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
.crm-modal.visible {
    opacity: 1;
    visibility: visible;
}
.crm-modal-content {
    background: white;
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
}
.crm-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-bottom: 1px solid #eee;
}
.crm-modal-header h3 {
    margin: 0;
    color: var(--text-dark);
    font-size: 1.2rem;
}
.crm-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-light);
    transition: color 0.2s;
}
.crm-modal-close:hover {
    color: var(--theme-accent);
}
.crm-modal-body {
    padding: 16px;
}
.crm-form-group {
    margin-bottom: 12px;
}
.crm-form-group label {
    display: block;
    margin-bottom: 4px;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-dark);
}
.crm-form-group input {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    transition: border-color 0.2s;
}
.crm-form-group input:focus {
    outline: none;
    border-color: var(--theme-accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--theme-accent) 20%, transparent);
}
.crm-form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 16px;
}
.crm-btn-cancel,
.crm-btn-save {
    padding: 6px 14px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
}
.crm-btn-cancel {
    background: #f0f0f0;
    color: var(--text-dark);
}
.crm-btn-cancel:hover {
    background: #e0e0e0;
}
.crm-btn-save {
    background: var(--theme-accent);
    color: white;
}
.crm-btn-save:hover {
    background: var(--theme-accent-light);
    box-shadow: none;
}

/* New Add Panel (sub‑overlay inside manual search) */
.crm-add-panel {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fef3e9;
    backdrop-filter: blur(8px);
    z-index: 1500;
    flex-direction: column;
    padding: 22px;
    overflow: hidden;
    border-radius: var(--radius-lg);
    border: 1px solid var(--theme-card-border);
}

.crm-add-panel.visible {
    display: flex;
}

.crm-add-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-shrink: 0;
}

.crm-add-panel-header h3 {
    margin: 0;
    font-size: 1.6rem;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.crm-add-panel-header h3 i {
    color: var(--theme-accent);
    font-size: 2.5rem;
}

.crm-add-panel-header .crm-add-cancel-btn {
    background: transparent;
    color: var(--theme-accent);
    border: 2px solid var(--theme-accent);
    border-radius: var(--radius-sm);
    padding: 8px 20px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.crm-add-panel-header .crm-add-cancel-btn:hover {
    background: var(--theme-accent);
    color: white;
    box-shadow: var(--theme-glow-box-hover);
}

.crm-add-panel-content {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    min-height: 0;
    overflow: hidden;
}

.crm-add-panel-content.constructor-mode {
    display: block !important;
}

.crm-add-section {
    background: white;
    border-radius: var(--radius-sm);
    padding: 25px 20px 20px;
    border: 1px solid color-mix(in srgb, var(--theme-accent) 20%, transparent);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 10px;
    overflow-y: auto;
    min-height: 350px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.crm-add-section:hover {
    border-color: var(--theme-accent);
    box-shadow: var(--theme-glow-box-hover);
}

.crm-add-section-icon {
    margin-bottom: 5px;
}

.crm-add-section-icon i {
    color: var(--theme-accent);
    font-size: 6rem;
    display: block;
}

.crm-add-section h4 {
    margin: 0 0 5px 0;
    font-size: 1.3rem;
    color: var(--text-dark);
    border-bottom: 1px solid color-mix(in srgb, var(--theme-accent) 30%, transparent);
    padding-bottom: 10px;
    width: 100%;
}

.crm-add-section p {
    font-size: 1rem;
    color: var(--text-light);
    margin: 0 0 auto 0;
    line-height: 1.5;
    flex: 0 1 auto;
}

.crm-add-action-btn {
    background: var(--theme-accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    width: 100%;
    max-width: 250px;
    margin-top: 35%;
    align-self: center;
    pointer-events: auto;
}

.crm-add-action-btn:hover {
    background: var(--theme-accent-light);
    box-shadow: var(--theme-glow-box-hover);
    transform: none;
}

/* Small button for "Use this device" */
.crm-add-small-btn {
    background: transparent;
    color: var(--theme-accent);
    border: 1px solid var(--theme-accent);
    border-radius: var(--radius-sm);
    padding: 6px 12px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 8px;
    width: auto;
    align-self: center;
}

.crm-add-small-btn:hover {
    background: var(--theme-accent);
    color: white;
    box-shadow: var(--theme-glow-box-hover);
}

/* Business card sub‑panel (two‑column layout) */
.crm-add-bc-subpanel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    height: 100%;
    overflow: hidden;
}

.crm-add-bc-section {
    background: white;
    border-radius: var(--radius-sm);
    padding: 25px 20px 20px;
    border: 1px solid color-mix(in srgb, var(--theme-accent) 20%, transparent);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 15px;
    overflow-y: auto;
}

.crm-add-bc-icon i {
    color: var(--theme-accent);
    font-size: 5rem;
    display: block;
    margin-bottom: 10px;
}

.crm-add-bc-section h4 {
    margin: 0;
    font-size: 1.3rem;
    color: var(--text-dark);
    border-bottom: 1px solid color-mix(in srgb, var(--theme-accent) 30%, transparent);
    padding-bottom: 8px;
    width: 100%;
}

.crm-add-bc-section p {
    font-size: 1rem;
    color: var(--text-light);
    margin: 0 0 auto 0;
    line-height: 1.5;
}

.crm-add-bc-section .crm-add-action-btn {
    margin-top: 20px;
    max-width: 200px;
}

/* Signature / email sub‑panel (two‑column layout) */
.crm-add-sig-subpanel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    height: 100%;
    overflow: hidden;
}

/* Common styles for both signature sections */
.crm-add-sig-section,
.crm-add-sig-imp-section {
    background: white;
    border-radius: var(--radius-sm);
    padding: 25px 20px 20px;
    border: 1px solid color-mix(in srgb, var(--theme-accent) 20%, transparent);
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 15px;
    overflow-y: auto;
    min-height: 300px;
}

.crm-add-sig-icon i {
    color: var(--theme-accent);
    font-size: 5rem;
    display: block;
    margin-bottom: 10px;
}

.crm-add-sig-section h4,
.crm-add-sig-imp-section h4 {
    margin: 0;
    font-size: 1.3rem;
    color: var(--text-dark);
    border-bottom: 1px solid color-mix(in srgb, var(--theme-accent) 30%, transparent);
    padding-bottom: 8px;
    width: 100%;
}

.crm-add-sig-section p,
.crm-add-sig-imp-section p {
    font-size: 1rem;
    color: var(--text-light);
    margin: 0 0 10px 0;
    line-height: 1.5;
    flex: 0 1 auto;
}

.crm-add-sig-section textarea,
.crm-add-sig-imp-section textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: var(--radius-sm);
    font-family: inherit;
    resize: vertical;
    margin-bottom: 10px;
}

.crm-add-sig-section textarea:focus,
.crm-add-sig-imp-section textarea:focus {
    outline: none;
    border-color: var(--theme-accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--theme-accent) 20%, transparent);
}

.crm-add-sig-section .crm-add-action-btn,
.crm-add-sig-imp-section .crm-add-action-btn {
    margin-top: auto;
    max-width: 200px;
}

/* Responsive adjustments */
@media (max-width: 991px) {
    .crm-add-panel-content {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(3, auto);
        overflow-y: auto;
    }

    .crm-add-section-icon i {
        font-size: 4rem;
    }

    .crm-add-section {
        min-height: auto;
    }

    .crm-add-action-btn {
        margin-top: 20px;
    }

    .crm-add-bc-subpanel,
    .crm-add-sig-subpanel {
        grid-template-columns: 1fr;
        overflow-y: auto;
    }
}

/* ==================== CONSTRUCTOR GRID ==================== */
.constructor-grid {
    display: grid;
    grid-template-columns: 1fr 5fr;
    gap: 20px;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.constructor-left {
    display: flex;
    flex-direction: column;
    gap: 15px;
    overflow-y: auto;
    padding-right: 5px;
    max-height: 100%;
    height: 100%; /* ensure full height for flex children */
}

.constructor-type-toggle {
    display: flex;
    gap: 8px;
    background: white;
    border-radius: var(--radius-sm);
    padding: 8px;
    border: 1px solid color-mix(in srgb, var(--theme-accent) 20%, transparent);
    flex-shrink: 0;
}

.constructor-type-btn {
    flex: 1;
    padding: 8px 4px;
    border: none;
    border-radius: var(--radius-sm);
    background: #f0f0f0;
    color: var(--text-dark);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 0.8rem;
}

.constructor-type-btn i {
    font-size: 1.2rem;
    margin-bottom: 1px;
}

.constructor-type-btn span {
    font-size: 0.7rem;
}

.constructor-type-btn.active {
    background: var(--theme-accent);
    color: white;
    box-shadow: var(--theme-glow-box-hover);
}

.constructor-type-btn:hover:not(.active) {
    background: #e0e0e0;
}

/* Renamed from .constructor-dummy-section to .cnstrctr-data-section */
.cnstrctr-data-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: white;
    border-radius: var(--radius-sm);
    padding: 12px;
    border: 1px solid color-mix(in srgb, var(--theme-accent) 20%, transparent);
    overflow-y: auto;
    flex: 0 1 auto;
    max-height: 360px;
    transition: opacity 0.3s ease;
}

.cnstrctr-data-section.reordering {
    opacity: 0.7;
}

.constructor-divider {
    margin: 6px 0;
    border: none;
    border-top: 1px solid color-mix(in srgb, var(--theme-accent) 30%, transparent);
}

.constructor-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0 0 2px 0;
    padding-bottom: 2px;
    border-bottom: 1px solid color-mix(in srgb, var(--theme-accent) 30%, transparent);
}

.constructor-dummy-btn {
    padding: 8px 10px;
    border: none;
    border-radius: var(--radius-sm);
    background: #4a4a4a;
    color: white;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    border: 1px solid color-mix(in srgb, var(--theme-accent) 15%, transparent);
    font-weight: normal;
}

.constructor-dummy-btn:hover {
    background: #5e5e5e;
}

.constructor-dummy-btn.dummy-btn-active {
    background: var(--theme-accent);
    color: white;
    font-weight: 700;
    border-color: var(--theme-accent);
    box-shadow: var(--theme-glow-box-hover);
}

.constructor-dummy-btn.dummy-btn-active:hover {
    background: var(--theme-accent-light);
}

.constructor-scrap-paper {
    background: white;
    border-radius: var(--radius-sm);
    padding: 12px;
    border: 1px solid color-mix(in srgb, var(--theme-accent) 20%, transparent);
    flex: 1; /* fill remaining space */
    min-height: 0; /* allow shrinking */
    display: flex;
    flex-direction: column;
}

.constructor-scrap-paper h4 {
    margin: 0 0 8px 0;
    font-size: 0.95rem;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.constructor-scrap-paper h4 i {
    color: var(--theme-accent);
    font-size: 0.95rem;
}

.constructor-scrap-paper textarea {
    width: 100%;
    min-height: 70px;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.85rem;
    resize: vertical;
    background: #fffaf0;
    flex: 1; /* take remaining height */
}

.constructor-scrap-paper textarea:focus {
    outline: none;
    border-color: var(--theme-accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--theme-accent) 20%, transparent);
}

.constructor-right {
    display: flex;
    flex-direction: column;
    gap: 20px;
    overflow: hidden;
    min-height: 0;
}

.constructor-progress {
    background: white;
    border-radius: var(--radius-sm);
    padding: 15px;
    border: 1px solid color-mix(in srgb, var(--theme-accent) 20%, transparent);
    flex-shrink: 0;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.constructor-progress h4 {
    margin: 0;
    font-size: 1rem;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 6px;
}

.constructor-progress h4 i {
    color: var(--theme-accent);
    font-size: 1.1rem;
}

.progress-controls {
    display: flex;
    align-items: center;
    gap: 8px;
}

.progress-btn {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid var(--theme-accent);
    background: white;
    color: var(--theme-accent);
    font-size: 1.2rem;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.progress-btn:hover {
    background: var(--theme-accent);
    color: white;
}

#progress-counter {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-dark);
    min-width: 40px;
    text-align: center;
}

.progress-bars {
    display: flex;
    gap: 4px;
    height: 20px;
    align-items: flex-end;
}

.progress-bar {
    flex: 1;
    height: 100%;
    min-width: 8px;
    border-radius: 2px;
    background-color: #e0e0e0;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
}

.progress-bar.filled {
    background-color: #ff8c00 !important;
    box-shadow: 0 0 8px #ff8c00;
}

.constructor-content-area {
    flex: 1;
    background: white;
    border-radius: var(--radius-sm);
    border: 1px solid color-mix(in srgb, var(--theme-accent) 20%, transparent);
    padding: 15px;
    overflow-y: auto;
    min-height: 0;
    display: flex;
    gap: 15px;
}

/* Editor and Preview split – adjusted ratio: editor 3.24, preview 1 (≈ 76.4% / 23.6%) */
.constructor-editor {
    flex: 3.24;
    overflow-y: auto;
    padding-right: 5px;
    /* Redesigned editor */
    background: #fafafa;
    border-radius: var(--radius-lg);
    padding: 15px;
    box-shadow: inset 2px 2px 5px rgba(0,0,0,0.02), inset -2px -2px 5px rgba(255,255,255,0.8);
    transition: all 0.2s ease;
}

.constructor-editor:hover {
    background: #ffffff;
    box-shadow: inset 1px 1px 3px rgba(0,0,0,0.05), inset -1px -1px 3px rgba(255,255,255,0.9);
}

.constructor-preview {
    flex: 1;
    overflow-y: auto;
    padding-left: 5px;
    /* Soft card styling (aligned with main.css) */
    background: var(--theme-card-bg);        /* uses theme background */
    border-radius: var(--radius-lg);          /* consistent with soft-card */
    box-shadow: 5px 5px 11px var(--theme-shadow-dark), -5px -5px 11px var(--shadow-light);
    border: 1px solid var(--theme-card-border);
    transition: all var(--transition-normal);
    background-color: #ffffff;                 /* fallback, but theme will apply */
}

/* Preview header outside the card (above preview) */
.preview-header-outside {
    font-size: 0.6rem;            /* 50% smaller than typical 1.2rem */
    font-weight: 600;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
    padding-left: 5px;
}

/* Preview cards (inside the preview) – no orange border */
.preview-card {
    background: #f9f9f9;
    border-radius: var(--radius-sm);
    padding: 15px;
    margin: 10px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}

.preview-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
}

.preview-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: color-mix(in srgb, var(--theme-accent) 15%, white);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    color: var(--theme-accent);
    border: 2px solid white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.preview-fields {
    margin-top: 10px;
}

.preview-note {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 15px;
    text-align: center;
    font-style: italic;
    border-top: 1px dashed #ddd;
    padding-top: 10px;
}

/* Dummy card styles for editor – without orange left border */
.dummy-card {
    background: #f9f9f9;
    border-radius: var(--radius-sm);
    padding: 15px;
    margin-bottom: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}

.dummy-card h3 {
    margin: 0 0 12px 0;
    color: var(--theme-accent);
    font-size: 1.1rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 6px;
}

.dummy-field {
    margin-bottom: 12px;
    font-size: 0.9rem;
}

.dummy-field label {
    font-weight: 600;
    color: var(--text-dark);
    display: inline-block;
    width: 80px;
    vertical-align: top;
    margin-top: 6px;
}

.dummy-input {
    width: calc(100% - 90px);
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: var(--radius-xs);
    font-family: inherit;
    font-size: 0.85rem;
    background: white;
    transition: border 0.2s, box-shadow 0.2s;
}

.dummy-input:focus {
    outline: none;
    border-color: var(--theme-accent);
    box-shadow: 0 0 0 2px color-mix(in srgb, var(--theme-accent) 20%, transparent);
}

.dummy-update-btn {
    background: var(--theme-accent);
    color: white;
    border: none;
    border-radius: var(--radius-xs);
    padding: 8px 16px;
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    margin-top: 10px;
    transition: background 0.2s;
}

.dummy-update-btn:hover {
    background: var(--theme-accent-light);
}

.dummy-product-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.dummy-product-list li {
    padding: 6px 0;
    border-bottom: 1px dashed #eee;
    color: #555;
}

.dummy-product-list li:last-child {
    border-bottom: none;
}

/* ==================== CONSTRUCTOR PANEL ==================== */
.crm-constructor-panel {
    display: none;
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #fef3e9;
    backdrop-filter: blur(8px);
    z-index: 1500;
    flex-direction: column;
    padding: 22px;
    overflow: hidden;
    border-radius: var(--radius-lg);
    border: 1px solid var(--theme-card-border);
}

.crm-constructor-panel.visible {
    display: flex;
}

.crm-constructor-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    flex-shrink: 0;
    padding: 4px 0;
}

.crm-constructor-panel-header h3 {
    margin: 0;
    font-size: 1.2rem;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 6px;
}

.crm-constructor-panel-header h3 i {
    color: var(--theme-accent);
    font-size: 1.5rem;
}

.constructor-header-buttons {
    display: flex;
    gap: 8px;
}

.crm-constructor-cancel-btn,
.crm-constructor-save-btn {
    padding: 6px 16px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: var(--radius-sm);
}

.crm-constructor-cancel-btn {
    background: transparent;
    color: var(--theme-accent);
    border: 2px solid var(--theme-accent);
}

.crm-constructor-cancel-btn:hover {
    background: var(--theme-accent);
    color: white;
    box-shadow: var(--theme-glow-box-hover);
}

.crm-constructor-save-btn {
    background: var(--theme-accent);
    color: white;
    border: none;
}

.crm-constructor-save-btn:hover {
    background: var(--theme-accent-light);
    box-shadow: var(--theme-glow-box-hover);
}

.crm-constructor-panel-content {
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

/* Responsive adjustments */
@media (max-width: 991px) {
    .constructor-grid {
        grid-template-columns: 1fr;
        grid-template-rows: auto 1fr;
        gap: 15px;
    }

    .constructor-left {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .constructor-type-toggle {
        flex: 1 1 200px;
    }

    .cnstrctr-data-section {
        flex: 1 1 200px;
        max-height: 300px;
    }

    .constructor-scrap-paper {
        flex: 1 1 200px;
    }

    .progress-bars {
        height: 25px;
    }

    .constructor-content-area {
        flex-direction: column;
    }
    .constructor-editor,
    .constructor-preview {
        flex: auto;
        width: 100%;
    }
    .constructor-preview {
        border-left: none;
        border-top: 2px solid var(--theme-accent);
        padding-left: 0;
        padding-top: 10px;
        border-radius: 0;
    }
}