/* ========================================
   Init Pricing Table — Components
   ======================================== */

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 7px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    font-family: inherit;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    background: transparent;
    color: var(--text);
    white-space: nowrap;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }

.btn-primary {
    background: var(--gradient-green);
    color: #000;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(16,185,129,0.25);
    border: none;
}
.btn-primary:hover { box-shadow: 0 4px 14px rgba(16,185,129,0.35); }

.btn-secondary {
    background: var(--surface-raised);
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-secondary:hover { background: rgba(255,255,255,0.04); }

.btn-ghost {
    color: var(--text-muted);
    padding: 6px;
    width: 32px;
    height: 32px;
    font-size: 13px;
}
.btn-ghost:hover { color: var(--text); background: rgba(255,255,255,0.04); }

.btn-danger {
    background: rgba(239,68,68,0.08);
    border: 1px solid rgba(239,68,68,0.15);
    color: var(--danger);
}
.btn-danger:hover { background: rgba(239,68,68,0.12); }

.btn-block { width: 100%; margin-bottom: 6px; }
.btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none !important; }

#langToggle {
    width: auto;
    padding: 6px 10px;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0.5px;
    color: var(--primary-light);
    border: 1px solid rgba(16,185,129,0.2);
    border-radius: 6px;
}
#langToggle:hover { background: rgba(16,185,129,0.1); }

/* Controls */
.control-group { margin-bottom: 10px; }
.control-group label {
    display: block;
    font-size: 10px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.input, .select {
    width: 100%;
    padding: 6px 9px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 12px;
    transition: all var(--transition);
}
.input:focus, .select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(16,185,129,0.12);
}

.range {
    width: 100%;
    -webkit-appearance: none;
    height: 3px;
    border-radius: 2px;
    background: var(--surface-raised);
    outline: none;
}
.range::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 13px;
    height: 13px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    border: 2px solid var(--surface);
    box-shadow: var(--shadow-sm);
}

.color-input {
    width: 100%;
    height: 28px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: none;
    cursor: pointer;
    margin-top: 3px;
}

.color-presets {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 3px;
}
.color-preset {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s;
}
.color-preset:hover { transform: scale(1.15); }
.color-preset.active { border-color: var(--text); }

.gradient-presets {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
    margin-bottom: 3px;
}
.gradient-preset {
    width: 28px;
    height: 20px;
    border-radius: 4px;
    cursor: pointer;
    border: 2px solid transparent;
    transition: transform 0.15s;
}
.gradient-preset:hover { transform: scale(1.1); }
.gradient-preset.active { border-color: var(--text); }

.radio-group { display: flex; gap: 10px; }
.radio { display: flex; align-items: center; gap: 3px; font-size: 11px; cursor: pointer; }
.radio input { accent-color: var(--primary); }
.checkbox { display: flex; align-items: center; gap: 5px; font-size: 11px; cursor: pointer; }
.checkbox input { accent-color: var(--primary); }

/* Template Grid */
.template-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 5px;
}

.template-card {
    aspect-ratio: 4/3;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border);
    background: var(--bg);
    cursor: pointer;
    overflow: hidden;
    position: relative;
    transition: all var(--transition);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 5px;
}
.template-card:hover {
    border-color: var(--primary-light);
    transform: translateY(-2px);
}
.template-card.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(16,185,129,0.15);
}
.template-preview {
    width: 100%;
    height: 55%;
    border-radius: 4px;
    position: relative;
    overflow: hidden;
}
.template-name {
    font-size: 9px;
    font-weight: 600;
    color: var(--text-muted);
    text-align: center;
}
.template-card.active .template-name { color: var(--primary-light); }

/* Pricing Table Container */
.pricing-table-container {
    position: relative;
    z-index: 1;
    max-width: 100%;
    min-width: 0;
}

/* Inline Editing */
[contenteditable="true"] {
    outline: none;
    border-radius: 3px;
    padding: 1px 3px;
    margin: -1px -3px;
    transition: background 0.15s;
    cursor: text;
}
[contenteditable="true"]:hover { background: rgba(16,185,129,0.06); }
[contenteditable="true"]:focus {
    background: rgba(16,185,129,0.1);
    box-shadow: 0 0 0 2px rgba(16,185,129,0.15);
}

/* Drag & Drop */
.pt-card.dragging {
    opacity: 0.5;
    transform: scale(0.95);
}
.pt-card.drag-over {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 3px rgba(16,185,129,0.15);
}

/* Delete Buttons */
.pt-feature-item { position: relative; }
.pt-delete-feature {
    position: absolute;
    right: -16px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--danger);
    color: white;
    border: none;
    font-size: 8px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}
.pt-feature-item:hover .pt-delete-feature { opacity: 1; }

.pt-delete-plan {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: rgba(239,68,68,0.85);
    color: white;
    border: none;
    font-size: 10px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    line-height: 1;
}
.pt-card:hover .pt-delete-plan { opacity: 1; }

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal.active { display: flex; }

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.75);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    width: 92%;
    max-width: 720px;
    max-height: 94vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalIn 0.25s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: translateY(16px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 7px; }

.modal-close {
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 16px;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.15s;
}
.modal-close:hover { background: var(--surface-raised); color: var(--text); }

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

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 6px;
    padding: 12px 18px;
    border-top: 1px solid var(--border);
}

.export-preview-wrapper {
    background: var(--bg);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    padding: 14px;
    margin-bottom: 14px;
    overflow: auto;
    max-height: 340px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}
.export-preview-wrapper > div { max-width: 100%; }

.export-options { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.export-options .control-group { margin-bottom: 0; }

.range-value {
    display: inline-block;
    margin-left: 5px;
    font-size: 10px;
    color: var(--text-muted);
    font-weight: 600;
    min-width: 20px;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 18px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--surface-raised);
    color: var(--text);
    padding: 9px 18px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    font-size: 11px;
    font-weight: 500;
    z-index: 2000;
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 7px;
}
.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}
.toast i { font-size: 12px; color: var(--success); }

/* Responsive Components */
@media (max-width: 700px) {
    .export-options { grid-template-columns: 1fr; }
}