/* assets/css/designer.css - Styling for Survey-Style Proposal Builder, Tables, Formulas & Signature Pad */

/* Builder Layout Split */
.builder-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 28px;
    align-items: start;
}

@media (max-width: 1200px) {
    .builder-layout {
        grid-template-columns: 1fr;
    }
}

.builder-main {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.builder-sidebar {
    display: flex;
    flex-direction: column;
    gap: 24px;
    position: sticky;
    top: 90px;
}

/* Builder Section Header */
.builder-section-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-md);
}

.section-title-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
}

.section-title {
    font-size: 16px;
    font-weight: 700;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Block Creator Toolbar (Survey Designer style) */
.blocks-toolbar {
    background: rgba(15, 23, 42, 0.6);
    border: 1px dashed var(--slate-700);
    border-radius: var(--radius-lg);
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}

.blocks-toolbar-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--slate-300);
    display: flex;
    align-items: center;
    gap: 8px;
}

.blocks-btn-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.btn-add-block {
    background: rgba(79, 70, 229, 0.15);
    color: var(--primary-200);
    border: 1px solid rgba(99, 102, 241, 0.35);
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-add-block:hover {
    background: var(--primary-600);
    color: #ffffff;
    border-color: var(--primary-600);
    transform: translateY(-1px);
}

/* Survey Block Cards */
.blocks-container {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.survey-block-card {
    background: #182234;
    border: 1px solid #2d3b55;
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: all var(--transition-normal);
}

.survey-block-card:hover {
    border-color: rgba(99, 102, 241, 0.5);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
}

.block-top-handle {
    background: rgba(15, 23, 42, 0.7);
    padding: 12px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.block-left-meta {
    display: flex;
    align-items: center;
    gap: 10px;
}

.block-drag-indicator {
    color: var(--slate-500);
    cursor: grab;
    font-size: 14px;
}

.block-type-pill {
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.pill-texto-corto { background: rgba(14, 165, 233, 0.2); color: #38bdf8; }
.pill-texto-largo { background: rgba(168, 85, 247, 0.2); color: #c084fc; }
.pill-tabla { background: rgba(16, 185, 129, 0.2); color: #34d399; }

.block-card-body {
    padding: 18px 20px;
}

.block-actions {
    display: flex;
    gap: 6px;
}

/* Dynamic Table Designer */
.dynamic-table-builder {
    background: #0f172a;
    border: 1px solid var(--slate-700);
    border-radius: var(--radius-md);
    overflow: hidden;
    margin-top: 14px;
}

.table-toolbar-bar {
    padding: 10px 14px;
    background: rgba(30, 41, 59, 0.7);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--slate-700);
}

.dynamic-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12.5px;
}

.dynamic-table th {
    background: #1e293b;
    color: var(--slate-300);
    padding: 10px 12px;
    font-weight: 600;
    border-bottom: 1px solid var(--slate-700);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    text-align: left;
}

.dynamic-table td {
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.table-input {
    width: 100%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    padding: 6px 8px;
    color: #ffffff;
    font-size: 12.5px;
    font-family: inherit;
}

.table-input:focus {
    outline: none;
    border-color: var(--primary-500);
    background: #0f172a;
}

.table-cell-calculated {
    background: rgba(16, 185, 129, 0.08);
    color: #6ee7b7;
    font-weight: 700;
    text-align: right;
    padding: 6px 8px;
    border-radius: 4px;
}

/* Rich Text WYSIWYG Editor */
.wysiwyg-wrapper {
    background: #0f172a;
    border: 1px solid var(--slate-700);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.wysiwyg-toolbar {
    background: #1e293b;
    padding: 8px 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    border-bottom: 1px solid var(--slate-700);
}

.wysiwyg-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--slate-300);
    padding: 5px 8px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all var(--transition-fast);
}

.wysiwyg-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ffffff;
}

.wysiwyg-editor-area {
    min-height: 180px;
    padding: 16px;
    color: #f1f5f9;
    font-size: 13.5px;
    line-height: 1.7;
    outline: none;
    background: #0b0f19;
}

.wysiwyg-editor-area:focus {
    box-shadow: inset 0 0 0 1px var(--primary-500);
}

/* Conditions & Milestones Breakdown */
.payment-methods-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 18px;
}

.payment-tab {
    flex: 1;
    padding: 12px;
    border-radius: var(--radius-md);
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--slate-700);
    color: var(--slate-300);
    text-align: center;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all var(--transition-fast);
}

.payment-tab.active {
    background: rgba(79, 70, 229, 0.2);
    border-color: var(--primary-500);
    color: #ffffff;
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.25);
}

.milestones-progress-wrap {
    margin: 16px 0;
    background: #0f172a;
    border-radius: var(--radius-md);
    padding: 14px;
    border: 1px solid var(--slate-700);
}

.milestones-bar-outer {
    height: 10px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    overflow: hidden;
    margin: 8px 0;
    display: flex;
}

.milestone-seg-initial { background: #3b82f6; height: 100%; }
.milestone-seg-mid { background: #8b5cf6; height: 100%; }
.milestone-seg-final { background: #10b981; height: 100%; }

.milestone-row-item {
    display: flex;
    gap: 10px;
    align-items: center;
    margin-bottom: 10px;
    background: rgba(255, 255, 255, 0.02);
    padding: 8px 12px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* User Signature Module & Pad */
.signature-status-card {
    background: #0f172a;
    border: 1px solid var(--slate-700);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-top: 14px;
}

.sig-preview-box {
    background: #ffffff;
    border-radius: var(--radius-md);
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 90px;
    margin-bottom: 10px;
    border: 1px solid var(--slate-300);
}

.sig-preview-img {
    max-height: 80px;
    max-width: 100%;
    object-fit: contain;
}

/* HTML5 Signature Pad Canvas */
.canvas-signature-wrap {
    background: #ffffff;
    border: 2px dashed #94a3b8;
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

#signatureCanvas {
    width: 100%;
    height: 180px;
    display: block;
    cursor: crosshair;
}

.canvas-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

/* Theme Selector Radio Cards */
.theme-presets-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.theme-preset-card {
    background: #0f172a;
    border: 2px solid var(--slate-700);
    border-radius: var(--radius-md);
    padding: 10px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.theme-preset-card.active {
    border-color: var(--primary-500);
    background: rgba(79, 70, 229, 0.1);
}

.theme-color-dots {
    display: flex;
    gap: 6px;
    margin-bottom: 6px;
}

.theme-color-dot {
    width: 14px;
    height: 14px;
    border-radius: 50%;
}

/* Unsaved Changes Indicator */
.dirty-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-weight: 600;
    color: #fbbf24;
    background: rgba(245, 158, 11, 0.14);
    border: 1px solid rgba(245, 158, 11, 0.35);
    padding: 3px 9px;
    border-radius: 999px;
}

/* Drag & Drop Block Feedback */
.survey-block-card.dragging {
    opacity: 0.45;
    transform: scale(0.99);
}

.survey-block-card.drag-over {
    border-color: var(--primary-400);
    box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.45);
}

/* Column Config Row & ID Badge */
.col-config-row {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.07);
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 10px;
}

.col-id-badge {
    font-family: monospace;
    font-size: 11px;
    font-weight: 700;
    color: #38bdf8;
    background: rgba(14, 165, 233, 0.14);
    border: 1px solid rgba(14, 165, 233, 0.3);
    padding: 4px 8px;
    border-radius: 5px;
    cursor: pointer;
    user-select: all;
    white-space: nowrap;
}

.col-id-badge:hover {
    background: rgba(14, 165, 233, 0.25);
}

.milestone-amount-pill {
    font-size: 12px;
    font-weight: 700;
    color: #e2e8f0;
    background: rgba(168, 85, 247, 0.14);
    border: 1px solid rgba(168, 85, 247, 0.3);
    padding: 4px 10px;
    border-radius: 6px;
    white-space: nowrap;
    min-width: 115px;
    text-align: right;
}
