/* ==========================================================================
   Contract Template Generator - Tool-Specific Styles
   
   IMPORTANT: The design system already provides:
   - All colors via CSS variables
   - Nav, hero, buttons, inputs, file upload zones
   - Section spacing and layout
   
   DO NOT:
   - Add background colors to .input-section or .output-section
   - Add borders to sections
   - Add padding to sections (use input-group for internal spacing)
   - Override design system colors
   ========================================================================== */

/* QA Required: Prevent white flash on page load */
body {
    background: #0a0a0a;
}

/* === PREVIEW AREA === */
.preview-container {
    min-height: 400px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow-y: auto;
    max-height: 600px;
}

/* Empty state */
.preview-empty {
    text-align: center;
    color: var(--text-tertiary);
    align-self: center;
}

.preview-empty p {
    font-size: 14px;
}

/* Contract preview */
.contract-preview {
    width: 100%;
    max-width: 100%;
    font-family: 'Inter', sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
}

.contract-header {
    text-align: center;
    margin-bottom: var(--space-xl);
    padding-bottom: var(--space-lg);
    border-bottom: 1px solid var(--border-default);
}

.contract-title {
    font-size: 24px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.contract-section {
    margin-bottom: var(--space-lg);
}

.section-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
}

.section-content {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: var(--space-md);
}

.party-info {
    background: var(--bg-secondary);
    padding: var(--space-md);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
}

.party-label {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-xs);
}

.party-details {
    font-size: 14px;
    color: var(--text-secondary);
    white-space: pre-line;
}

.clause-item {
    margin-bottom: var(--space-md);
    padding: var(--space-md);
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--color-primary);
}

.clause-number {
    font-weight: 600;
    color: var(--color-primary);
    margin-bottom: var(--space-xs);
}

.clause-text {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* === INPUT HELPERS === */
.input-helper {
    color: var(--text-tertiary);
    font-size: 13px;
    margin-top: var(--space-xs);
}

.settings-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-md);
    padding-top: var(--space-md);
    border-top: 1px solid var(--border-default);
}

.settings-title:first-child {
    border-top: none;
    padding-top: 0;
}

/* === PRO FEATURES === */
.pro-features {
    display: flex;
    flex-direction: column;
    gap: var(--space-md);
    padding: var(--space-lg);
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-default);
}

.pro-features h4 {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.pro-feature-buttons {
    display: flex;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.pro-feature-buttons .button-secondary {
    flex: 1;
    min-width: 200px;
}

/* === ERROR STATES === */
.input-error {
    color: var(--color-error, #ef4444);
    font-size: 13px;
    margin-top: var(--space-xs);
}

.input-group.has-error .text-input,
.input-group.has-error .text-area,
.input-group.has-error .select-input {
    border-color: var(--color-error, #ef4444);
}

/* === LOADING STATES === */
.button-primary.is-loading .button-text {
    visibility: hidden;
}

.button-primary.is-loading .button-spinner {
    display: block;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);
}

.button-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.button-primary {
    position: relative;
}

/* === CUSTOM CLAUSES EDITOR (Pro Feature) === */
.custom-clauses-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.custom-clauses-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding: var(--space-xl);
    max-width: 800px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
    border: 1px solid var(--border-default);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-lg);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-default);
}

.modal-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: var(--space-xs);
}

.close-btn:hover {
    color: var(--text-primary);
}

.clause-editor {
    margin-bottom: var(--space-lg);
}

.clause-editor label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
}

.clause-editor textarea {
    width: 100%;
    min-height: 120px;
    padding: var(--space-md);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 14px;
    line-height: 1.6;
    resize: vertical;
}

.clause-editor textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.modal-actions {
    display: flex;
    gap: var(--space-md);
    justify-content: flex-end;
    margin-top: var(--space-lg);
    padding-top: var(--space-lg);
    border-top: 1px solid var(--border-default);
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .pro-feature-buttons {
        flex-direction: column;
    }
    
    .pro-feature-buttons .button-secondary {
        min-width: unset;
    }
    
    .preview-container {
        min-height: 300px;
        max-height: 400px;
    }
    
    .contract-title {
        font-size: 20px;
    }
    
    .section-title {
        font-size: 16px;
    }
    
    .custom-clauses-content {
        width: 95%;
        padding: var(--space-lg);
        max-height: 90vh;
    }
    
    .modal-actions {
        flex-direction: column-reverse;
    }
    
    .modal-actions button {
        width: 100%;
    }
}

/* === PRO GATING === */
.pro-feature:not(.is-pro) {
    position: relative;
    overflow: hidden;
}

.pro-feature:not(.is-pro):hover::after {
    content: '✨ Upgrade to Pro';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: var(--color-primary);
    color: white;
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    font-size: 12px;
    white-space: nowrap;
    z-index: 10;
}

.pro-badge-inline {
    background: var(--color-primary);
    color: white;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    margin-left: var(--space-xs);
}

/* === TEMPLATE STORAGE (Pro Feature) === */
.saved-templates {
    margin-bottom: var(--space-lg);
}

.template-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-md);
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-default);
    margin-bottom: var(--space-sm);
}

.template-name {
    font-weight: 600;
    color: var(--text-primary);
}

.template-actions {
    display: flex;
    gap: var(--space-sm);
}

.template-actions button {
    background: none;
    border: 1px solid var(--border-default);
    color: var(--text-secondary);
    padding: var(--space-xs) var(--space-sm);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 12px;
}

.template-actions button:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}