/**
 * Pipedrive Lead Form - Style Sheet
 *
 * This stylesheet implements the Unciphered brand design for the intake form.
 * Design based on Figma mockups with orange accent color (#FF5722).
 *
 * Color Palette:
 * - Primary (Orange): #FF5722
 * - Dark Orange (Hover): #E64A19
 * - Gray Background: #D3D3D3
 * - Dark Text: #1a202c, #333
 * - Light Gray: #999
 */

/* ===================================
   Layout & Container Styles
   =================================== */

/**
 * Body - Global page layout
 * - White background for clean appearance
 * - Responsive padding for mobile and desktop
 * - System font stack for native look and fast loading
 */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 2rem 1rem;
    background-color: #ffffff;
    color: #333;
}

/**
 * Container - Centers content with max-width
 * - 750px max width matches design mockup
 * - Auto margins for horizontal centering
 */
.container {
    max-width: 750px;
    margin: 0 auto;
}

/* ===================================
   Header Styles
   =================================== */

/**
 * Form Header - Centered header section above the gray form container
 * Contains title, subtitle, and decorative divider
 */
.form-header {
    text-align: center;
    margin-bottom: 2rem;
}

/**
 * Main Title (h1)
 * - "Unciphered Case" in black, "Intake Form" in orange
 * - Orange accent applied via .form-title-accent span
 */
h1 {
    color: #1a202c;
    font-size: 2rem;
    font-weight: 700;
    margin: 0 0 1rem 0;
}

h1 .form-title-accent {
    color: #FF5722;  /* Brand orange for "Intake Form" */
}

/**
 * Subtitle Text
 * - Instructions and warning about sensitive data
 * - Displayed below the title
 */
.form-subtitle {
    color: #666;
    font-size: 0.95rem;
    line-height: 1.6;
    margin: 0 0 0.5rem 0;
}

/**
 * Decorative Divider
 * - Orange horizontal line below header
 * - Matches brand color and design mockup
 */
.form-divider {
    width: 120px;
    height: 3px;
    background-color: #FF5722;
    margin: 1.5rem auto;
    border: none;
}

/* ===================================
   Form Container
   =================================== */

/**
 * Form Wrapper - Gray background container
 * - Contains all form fields and submit button
 * - Light gray background (#D3D3D3) as per design
 * - Rounded corners for modern appearance
 */
.form-wrapper {
    background: #D3D3D3;
    padding: 2.5rem 2rem;
    border-radius: 16px;
}
/* ===================================
   Form Structure
   =================================== */

/**
 * Form Element
 * - Flexbox layout for vertical field stacking
 * - Spacing handled by margin-bottom on field-container (not gap)
 */
form {
    display: flex;
    flex-direction: column;
}

/**
 * Section Header - Visible section titles
 * - Example: "Contact Info"
 * - Used to separate different parts of the form
 * - Rendered via generateFormFieldset() in index.ts
 */
.section-header {
    font-weight: 600;
    font-size: 1.05rem;
    color: #1a202c;
    margin: 0 0 1.25rem 0;
    padding: 0;
}

/**
 * Field Label
 * - Lighter weight than section headers for visual hierarchy
 * - Positioned above each input field
 * - Contains tooltip icon when applicable
 */
label {
    font-weight: 400;
    margin-bottom: 0.5rem;
    display: block;
    color: #333;
    font-size: 0.9rem;
}

/**
 * Field Container - White card for each form field
 * - White background creates visual separation from gray form wrapper
 * - Rounded corners match overall design
 * - Contains label and input element
 * - Smooth transitions for conditional field visibility
 * - overflow: visible allows tooltips to extend beyond container boundaries
 */
.field-container {
    margin-bottom: 1.25rem;
    background: white;
    padding: 1.25rem;
    border-radius: 8px;
    max-height: 1000px;
    opacity: 1;
    overflow: visible;
    transition: max-height 0.4s ease-in-out, opacity 0.4s ease-in-out, margin 0.4s ease-in-out, padding 0.4s ease-in-out;
}

/**
 * Hidden Field State - Collapsed conditional fields
 * - Smoothly collapses when visibility condition is not met
 * - Animates height, opacity, and spacing to 0
 * - Uses max-height for smooth height transition
 * - Removes all spacing with margin: 0 and padding: 0
 * - overflow: hidden needed for smooth collapse animation
 */
.field-container.field-hidden {
    max-height: 0;
    opacity: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
    pointer-events: none;
}
/* ===================================
   Form Inputs
   =================================== */

/**
 * Text Inputs, Selects, and Textareas
 * - Consistent styling across all input types
 * - Subtle border that changes to orange on focus
 * - Smooth transitions for better UX
 * - Full width within field container
 */
input[type="text"],
input[type="email"],
input[type="tel"],
input[type="date"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 0.85rem;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 0.95rem;
    background-color: #fff;
    line-height: 1.5;
    transition: border-color 0.2s, box-shadow 0.2s;
}

/**
 * Textarea - Multi-line text input
 * - Minimum height for comfortable input
 * - Vertical resize only (prevents horizontal overflow)
 */
textarea {
    min-height: 120px;
    resize: vertical;
}

/**
 * Multi-Select Dropdown
 * - Auto height to show selected options
 */
select[multiple] {
    height: auto;
    padding: 0.85rem;
}

/**
 * Focus State - Orange brand color
 * - Removes default browser outline
 * - Orange border and subtle shadow for accessibility
 * - Applied to all input types
 */
input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #FF5722;
    box-shadow: 0 0 0 2px rgba(255, 87, 34, 0.1);
}

/* ===================================
   Submit Button
   =================================== */

/**
 * Submit Button - Primary call-to-action
 * - Orange brand color (#FF5722)
 * - Centered with max-width for better mobile/desktop appearance
 * - Smooth hover transition to darker orange
 */
button {
    background-color: #FF5722;
    color: white;
    padding: 1rem 3rem;
    border: none;
    border-radius: 8px;
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s;
    margin: 1.5rem auto 0;
    display: block;
    width: auto;
    max-width: 320px;
}

/**
 * Button Hover State
 * - Darker orange for visual feedback
 * - Only applies to enabled buttons
 */
button:hover:not(:disabled) {
    background-color: #E64A19;
}

/**
 * Button Disabled State
 * - Gray color to indicate unavailability
 * - Cursor changed to not-allowed
 */
button:disabled {
    background-color: #a0aec0;
    cursor: not-allowed;
}

/* ===================================
   Tooltips
   =================================== */

/**
 * Tooltip Container
 * - Positioned inline with label text
 * - Uses relative positioning for tooltip popup placement
 */
.tooltip {
    position: relative;
    display: inline-block;
    margin-left: 6px;
    vertical-align: middle;
}

/**
 * Tooltip Icon - Question mark in circle
 * - Gray background with white text
 * - Cursor changes to 'help' to indicate interactivity
 * - Small size to not overwhelm the label
 */
.tooltip .tooltip-icon {
    background-color: #999;
    color: white;
    border-radius: 50%;
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
    cursor: help;
}

/**
 * Tooltip Text Popup
 * - Hidden by default, shown on hover
 * - Dark background for good contrast
 * - Positioned above the icon
 * - Smooth fade-in transition
 * - High z-index ensures it appears above all other elements
 */
.tooltip .tooltip-text {
    visibility: hidden;
    width: 220px;
    background-color: #2d3748;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 8px;
    position: absolute;
    z-index: 9999;
    bottom: 125%;  /* Position above icon */
    left: 50%;
    margin-left: -110px;  /* Center horizontally */
    opacity: 0;
    transition: opacity 0.3s;
    font-weight: normal;
    font-size: 0.875rem;
}

/**
 * Tooltip Arrow - Points down to icon
 * - CSS triangle using borders
 * - Matches tooltip background color
 */
.tooltip .tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #2d3748 transparent transparent transparent;
}

/**
 * Tooltip Hover State
 * - Makes tooltip visible on hover
 * - Fade-in animation via opacity transition
 */
.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* ===================================
   Checkbox Groups
   =================================== */

/**
 * Checkbox Group Container
 * - No visual borders, relies on field-container styling
 * - Max height with scrolling for long lists
 * - Generated via generateCheckboxGroup() in index.ts
 */
.checkbox-group {
    border: none;
    padding: 0;
    max-height: 200px;
    overflow-y: auto;
}

/**
 * Individual Checkbox Item
 * - Flexbox layout for horizontal alignment
 * - Checkbox appears before label (inline)
 * - Spacing between items
 */
.checkbox-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.75rem;
}

.checkbox-item:last-child {
    margin-bottom: 0;
}

/**
 * Checkbox Input
 * - Orange accent color matches brand
 * - Fixed size for consistency
 * - Flex-shrink prevents squishing on long labels
 * - Cursor pointer for better UX
 */
.checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 0.75rem;
    flex-shrink: 0;
    accent-color: #FF5722;
    cursor: pointer;
}

/**
 * Checkbox Label
 * - Normal weight (not bold)
 * - Clickable (cursor pointer)
 * - Margin 0 to prevent extra spacing from flexbox
 */
.checkbox-item label {
    font-weight: normal;
    cursor: pointer;
    font-size: 0.95rem;
    margin: 0;
}

/* ===================================
   Radio Button Groups
   =================================== */

/**
 * Radio Group Container
 * - Similar to checkbox group but no max-height
 * - Generated via generateRadioGroup() in index.ts
 */
.radio-group {
    border: none;
    padding: 0;
}

/**
 * Individual Radio Item
 * - Flexbox layout for horizontal alignment
 * - Radio button appears before label (inline)
 * - Spacing between items
 */
.radio-item {
    display: flex;
    align-items: center;
    margin-bottom: 0.75rem;
}

.radio-item:last-child {
    margin-bottom: 0;
}

/**
 * Radio Input
 * - Orange accent color matches brand
 * - Fixed size for consistency
 * - Flex-shrink prevents squishing on long labels
 * - Cursor pointer for better UX
 */
.radio-item input[type="radio"] {
    width: 18px;
    height: 18px;
    margin-right: 0.75rem;
    flex-shrink: 0;
    accent-color: #FF5722;
    cursor: pointer;
}

/**
 * Radio Label
 * - Normal weight (not bold)
 * - Clickable (cursor pointer)
 * - Margin 0 to prevent extra spacing from flexbox
 */
.radio-item label {
    font-weight: normal;
    cursor: pointer;
    font-size: 0.95rem;
    margin: 0;
}

/* ===================================
   Success/Error Pages
   =================================== */

/**
 * Feedback Page Layout
 * - Full viewport height with centered content
 * - Used for both success and error pages
 * - Grid layout for vertical and horizontal centering
 */
.feedback-page {
    display: grid;
    place-content: center;
    min-height: 100vh;
    text-align: center;
    margin: 0;
}

/**
 * Success Page - Green color scheme
 * - Light green background (#f0fdf4)
 * - Dark green text for good contrast
 * - Displayed after successful form submission
 */
.success-page {
    background-color: #f0fdf4;
    color: #166534;
}

/**
 * Error Page - Red color scheme
 * - Light red background (#fef2f2)
 * - Dark red text for good contrast
 * - Displayed when form submission fails
 */
.error-page {
    background-color: #fef2f2;
    color: #b91c1c;
}

/**
 * Message Box - Container for feedback message
 * - Rounded corners for modern appearance
 * - Generous padding for readability
 * - Border style varies by page type (success/error)
 */
.message-box {
    padding: 2rem 3rem;
    border-radius: 8px;
    border: 1px solid;
}

/**
 * Success Message Box Styling
 * - Light green background with darker border
 * - Layered shades of green for visual depth
 */
.success-page .message-box {
    background-color: #dcfce7;
    border-color: #bbf7d0;
}

/**
 * Error Message Box Styling
 * - Light red background with darker border
 * - Layered shades of red for visual depth
 */
.error-page .message-box {
    background-color: #fee2e2;
    border-color: #fecaca;
}

/**
 * Message Box Title
 * - Large, prominent heading
 * - Example: "Success!" or "Error"
 */
.message-box h1 {
    font-size: 2.5rem;
    margin: 0 0 0.5rem 0;
}

/**
 * Message Box Body Text
 * - Slightly larger than normal text
 * - Contains the main success/error message
 */
.message-box p {
    font-size: 1.125rem;
    margin: 0;
}

/**
 * Error Details Section
 * - Displays technical error information
 * - Monospace font for code/error messages
 * - Dashed border distinguishes from main message
 * - Only appears on error pages
 */
.error-details {
    font-family: monospace;
    padding: 1rem;
    border-radius: 8px;
    margin-top: 1.5rem;
    text-align: left;
    border: 1px dashed #fca5a5;
    background-color: #fee2e2;
    color: #991b1b;
}

/* ===================================
   Validation Error Display
   =================================== */

/**
 * Validation Summary Box
 * - Displayed at the top of the form when client-side validation fails
 * - Light red background with red border for visibility
 * - Thick left border draws attention to errors
 * - Generated dynamically by JavaScript on validation failure
 */
.validation-summary {
    background-color: #fff5f5;
    color: #c53030;
    border: 1px solid #fc8181;
    border-left-width: 4px;
    padding: 1rem;
    border-radius: 4px;
    margin-bottom: 1.5rem;
}

/**
 * Validation Error List
 * - Bulleted list of specific validation errors
 * - Each error describes which field needs correction
 * - Minimal margins to keep summary compact
 */
.validation-summary ul {
    margin: 0;
    padding-left: 1.25rem;
}

/* ===================================
   Loading Spinner
   =================================== */

/**
 * Loader Overlay - Full-screen loading indicator
 * - Covers entire viewport during form submission
 * - Semi-transparent white background prevents interaction
 * - Hidden by default, shown via JavaScript when form is submitted
 * - Flexbox centers the spinner both vertically and horizontally
 * - High z-index ensures it appears above all other content
 */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.9);
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

/**
 * Loader Spinner - Animated circular spinner
 * - Circular shape using border-radius: 50%
 * - Light gray border with orange top border
 * - Orange top border rotates via animation to create spinning effect
 * - Uses brand orange color (#FF5722)
 */
.loader {
    border: 8px solid #f3f3f3;
    border-top: 8px solid #FF5722;
    border-radius: 50%;
    width: 60px;
    height: 60px;
    animation: spin 1s linear infinite;
}

/**
 * Spin Animation - Continuous rotation
 * - Linear timing function for smooth, constant rotation
 * - Infinite loop keeps spinning until form response received
 * - 360-degree rotation completes in 1 second
 */
@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
