/**
 * Oddstories Forms - Frontend Styling
 */

/* Form Container */
.oddb-form-wrapper {
    max-width: 600px;
    margin: 0 auto;
}

.oddb-form {
    background: #fff;
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

/* Form Messages */
.oddb-form-messages {
    margin-bottom: 20px;
}

.oddb-form-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border: 1px solid #28a745;
    color: #155724;
    padding: 15px 20px;
    border-radius: 8px;
    font-weight: 500;
}

.oddb-form-error {
    background: linear-gradient(135deg, #f8d7da 0%, #f5c6cb 100%);
    border: 1px solid #dc3545;
    color: #721c24;
    padding: 15px 20px;
    border-radius: 8px;
    font-weight: 500;
}

/* Form Fields */
.oddb-form-field {
    margin-bottom: 20px;
}

.oddb-form-field label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
    font-size: 14px;
}

.oddb-form-field label .required {
    color: #dc3545;
}

.oddb-form-field input[type="text"],
.oddb-form-field input[type="email"],
.oddb-form-field input[type="tel"],
.oddb-form-field input[type="url"],
.oddb-form-field input[type="number"],
.oddb-form-field textarea,
.oddb-form-field select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background: #fafafa;
    box-sizing:border-box
}

.oddb-form-field input:focus,
.oddb-form-field textarea:focus,
.oddb-form-field select:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    background: #fff;
}

.oddb-form-field input::placeholder,
.oddb-form-field textarea::placeholder {
    color: #9ca3af;
}

.oddb-form-field textarea {
    resize: vertical;
    min-height: 120px;
}

.oddb-form-field select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23666' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
}

/* Checkbox & Radio */
.oddb-form-field input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    accent-color: #6366f1;
}

.oddb-radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.oddb-radio-label {
    display: flex !important;
    align-items: center;
    font-weight: normal !important;
    cursor: pointer;
}

.oddb-radio-label input[type="radio"] {
    width: 18px;
    height: 18px;
    margin-right: 10px;
    accent-color: #6366f1;
}

/* Math Challenge */
.oddb-field-math {
    background: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    border: 1px dashed #dee2e6;
}

.oddb-field-math label {
    color: #495057;
}

.oddb-field-math input {
    max-width: 120px;
}

/* Checkbox Group */
.oddb-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.oddb-checkbox-label {
    display: flex !important;
    align-items: center;
    font-weight: normal !important;
    cursor: pointer;
}

.oddb-checkbox-label input[type="checkbox"] {
    margin-right: 10px;
}

/* Star Rating */
.oddb-rating {
    display: flex;
    flex-direction: row-reverse;
    justify-content: flex-end;
    gap: 4px;
}

.oddb-rating input[type="radio"] {
    display: none;
}

.oddb-rating .oddb-star {
    font-size: 28px;
    color: #ddd;
    cursor: pointer;
    transition: color 0.15s ease, transform 0.15s ease;
}

.oddb-rating .oddb-star:hover,
.oddb-rating .oddb-star:hover ~ .oddb-star,
.oddb-rating input:checked ~ .oddb-star {
    color: #fbbf24;
}

.oddb-rating .oddb-star:hover {
    transform: scale(1.15);
}

/* Likert Scale */
.oddb-scale {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.oddb-scale-label {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
}

.oddb-scale-options {
    display: flex;
    gap: 8px;
}

.oddb-scale-option {
    display: flex !important;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    padding: 8px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    transition: all 0.2s ease;
    font-weight: normal !important;
}

.oddb-scale-option:hover {
    border-color: #6366f1;
    background: #f8f9ff;
}

.oddb-scale-option input[type="radio"] {
    display: none;
}

.oddb-scale-option:has(input:checked) {
    border-color: #6366f1;
    background: #6366f1;
    color: #fff;
}

.oddb-scale-option span {
    font-weight: 600;
    font-size: 14px;
}

/* Range Slider */
.oddb-range-wrapper {
    display: flex;
    align-items: center;
    gap: 16px;
}

.oddb-range-wrapper input[type="range"] {
    flex: 1;
    height: 8px;
    appearance: none;
    -webkit-appearance: none;
    background: #e0e0e0;
    border-radius: 4px;
    outline: none;
}

.oddb-range-wrapper input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 22px;
    height: 22px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(99, 102, 241, 0.4);
}

.oddb-range-wrapper input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

.oddb-range-value {
    min-width: 40px;
    text-align: center;
    font-weight: 600;
    color: #6366f1;
    font-size: 18px;
}

/* Date/Time Inputs */
.oddb-form-field input[type="date"],
.oddb-form-field input[type="time"],
.oddb-form-field input[type="datetime-local"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    background: #fafafa;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.oddb-form-field input[type="date"]:focus,
.oddb-form-field input[type="time"]:focus,
.oddb-form-field input[type="datetime-local"]:focus {
    outline: none;
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
    background: #fff;
}

/* Color Picker */
.oddb-form-field input[type="color"] {
    width: 60px;
    height: 40px;
    padding: 4px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    background: #fafafa;
}

.oddb-form-field input[type="color"]:focus {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

/* File Input */
.oddb-form-field input[type="file"] {
    width: 100%;
    padding: 12px 16px;
    border: 2px dashed #e0e0e0;
    border-radius: 8px;
    font-size: 14px;
    background: #fafafa;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.oddb-form-field input[type="file"]:hover {
    border-color: #6366f1;
}

.oddb-form-field input[type="file"]:focus {
    outline: none;
    border-color: #6366f1;
    border-style: solid;
}

/* Field Description */
.oddb-field-description {
    margin-top: 6px;
    font-size: 13px;
    color: #6b7280;
}

/* Heading/Paragraph/Divider Fields */
.oddb-field-heading {
    margin: 0 0 8px 0;
    color: #333;
}

.oddb-field-paragraph {
    margin: 0 0 16px;
    color: #666;
    line-height: 1.6;
}

.oddb-field-paragraph p {
    margin: 0 0 1em;
}

.oddb-field-paragraph p:last-child {
    margin-bottom: 0;
}

.oddb-field-paragraph h3,
.oddb-field-paragraph h4 {
    margin: 1em 0 0.5em;
    color: #333;
}

.oddb-field-paragraph ul,
.oddb-field-paragraph ol {
    margin: 0.5em 0;
    padding-left: 1.5em;
}

.oddb-field-paragraph blockquote {
    margin: 1em 0;
    padding-left: 1em;
    border-left: 3px solid #ddd;
    color: #888;
    font-style: italic;
}

.oddb-field-paragraph a {
    color: #6366f1;
    text-decoration: underline;
}

.oddb-field-paragraph a:hover {
    color: #4f46e5;
}

.oddb-field-divider {
    border: none;
    border-top: 1px solid #e0e0e0;
    margin: 24px 0;
}

/* Inline Form Mode */
.oddb-form-inline {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}

.oddb-form-inline .oddb-form-field {
    margin-bottom: 0;
    flex: 1;
    min-width: 150px;
}

.oddb-form-inline .oddb-field-submit {
    flex: 0 0 auto;
}

.oddb-form-inline .oddb-form-submit {
    width: auto;
    padding: 12px 24px;
}

.oddb-form-inline .oddb-form-messages {
    width: 100%;
    margin-bottom: 12px;
}

/* Success State (replaces form) */
.oddb-form-success-state {
    text-align: center;
    padding: 40px 20px;
}

.oddb-form-success-state .oddb-form-success {
    display: inline-block;
}

/* Submit Button */
.oddb-form-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 14px 28px;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.oddb-form-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.oddb-form-submit:active {
    transform: translateY(0);
}

.oddb-form-submit:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.oddb-submit-loading {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.oddb-spinner {
    animation: oddb-spin 1s linear infinite;
}

@keyframes oddb-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* Field Widths */
.oddb-field-half {
    width: calc(50% - 10px);
    display: inline-block;
    vertical-align: top;
}

.oddb-field-half:nth-child(odd) {
    margin-right: 20px;
}

/* Honeypot - Hidden */
.oddb-hp {
    position: absolute !important;
    left: -9999px !important;
    top: -9999px !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .oddb-form {
        background: #1e1e1e;
        box-shadow: 0 2px 12px rgba(0, 0, 0, 0.3);
    }

    .oddb-form-field label {
        color: #e0e0e0;
    }

    .oddb-form-field input,
    .oddb-form-field textarea,
    .oddb-form-field select {
        background: #2d2d2d;
        border-color: #404040;
        color: #e0e0e0;
    }

    .oddb-form-field input:focus,
    .oddb-form-field textarea:focus,
    .oddb-form-field select:focus {
        background: #333;
    }

    .oddb-field-math {
        background: #2d2d2d;
        border-color: #404040;
    }

    .oddb-field-math label {
        color: #b0b0b0;
    }
    
    .oddb-scale-option {
        border-color: #404040;
        background: #2d2d2d;
        color: #e0e0e0;
    }
    
    .oddb-scale-option:hover {
        background: #333;
    }
    
    .oddb-rating .oddb-star {
        color: #555;
    }
    
    .oddb-range-wrapper input[type="range"] {
        background: #404040;
    }
    
    .oddb-field-heading {
        color: #e0e0e0;
    }
    
    .oddb-field-paragraph {
        color: #b0b0b0;
    }
    
    .oddb-field-divider {
        border-top-color: #404040;
    }
    
    .oddb-field-description {
        color: #9ca3af;
    }
}

/* Responsive */
@media (max-width: 640px) {
    .oddb-form {
        padding: 20px;
        border-radius: 8px;
    }

    .oddb-field-half {
        width: 100%;
        margin-right: 0 !important;
    }

    .oddb-form-submit {
        padding: 16px 24px;
    }

    .oddb-form-wrapper {
        max-width: 95%;
        margin: 0 auto;
    }

}

/* Toggle Switch */
.oddb-toggle-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.oddb-toggle {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.oddb-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.oddb-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    border-radius: 26px;
    transition: 0.3s;
}

.oddb-toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    transition: 0.3s;
}

.oddb-toggle input:checked + .oddb-toggle-slider {
    background-color: #2563eb;
}

.oddb-toggle input:checked + .oddb-toggle-slider:before {
    transform: translateX(24px);
}

.oddb-toggle-labels {
    font-size: 14px;
    color: #666;
}

.oddb-toggle-labels .on {
    display: none;
}

.oddb-toggle input:checked ~ .oddb-toggle-labels .off {
    display: none;
}

.oddb-toggle input:checked ~ .oddb-toggle-labels .on {
    display: inline;
}

/* Signature Canvas */
.oddb-signature-wrapper {
    border: 2px dashed #d1d5db;
    border-radius: 8px;
    padding: 10px;
    background: #f9fafb;
}

.oddb-signature-canvas {
    display: block;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background: white;
    cursor: crosshair;
    touch-action: none;
    width: 100%;
    max-width: 400px;
}

.oddb-signature-actions {
    margin-top: 10px;
}

.oddb-signature-clear {
    padding: 6px 12px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
}

.oddb-signature-clear:hover {
    background: #dc2626;
}

/* Image Choice */
.oddb-image-choice {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 12px;
}

.oddb-image-option {
    position: relative;
    cursor: pointer;
    border: 2px solid #d1d5db;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.2s;
}

.oddb-image-option:hover {
    border-color: #2563eb;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.oddb-image-option input {
    position: absolute;
    opacity: 0;
}

.oddb-image-option img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    display: block;
}

.oddb-image-option span {
    display: block;
    padding: 8px;
    text-align: center;
    font-size: 13px;
    background: white;
}

.oddb-image-option input:checked ~ img {
    border: 3px solid #2563eb;
}

.oddb-image-option input:checked ~ span {
    background: #2563eb;
    color: white;
    font-weight: 600;
}

/* Name Fields */
.oddb-name-fields {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.oddb-name-title {
    width: 80px;
}

.oddb-name-first,
.oddb-name-last {
    flex: 1;
    min-width: 120px;
}

.oddb-name-middle {
    flex: 0.8;
    min-width: 100px;
}

/* Address Fields */
.oddb-address-fields {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.oddb-address-street,
.oddb-address-street2 {
    width: 100%;
}

.oddb-address-row {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.oddb-address-city {
    flex: 2;
    min-width: 150px;
}

.oddb-address-state {
    flex: 1;
    min-width: 100px;
}

.oddb-address-zip {
    flex: 1;
    min-width: 100px;
}

.oddb-address-country {
    width: 100%;
}

/* Consent */
.oddb-consent-label {
    display: flex;
    gap: 10px;
    cursor: pointer;
    padding: 12px;
    background: #f9fafb;
    border-radius: 6px;
    border: 1px solid #d1d5db;
}

.oddb-consent-label:hover {
    background: #f3f4f6;
}

.oddb-consent-label input {
    margin-top: 3px;
    flex-shrink: 0;
}

.oddb-consent-text {
    font-size: 14px;
    color: #374151;
    line-height: 1.5;
}

.oddb-consent-text a {
    color: #2563eb;
    text-decoration: underline;
}

/* Repeater */
.oddb-repeater {
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 15px;
    background: #f9fafb;
}

.oddb-repeater-items {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
}

.oddb-repeater-item {
    display: flex;
    gap: 8px;
}

.oddb-repeater-item input {
    flex: 1;
}

.oddb-repeater-remove {
    padding: 8px 12px;
    background: #ef4444;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    line-height: 1;
}

.oddb-repeater-remove:hover {
    background: #dc2626;
}

.oddb-repeater-add {
    padding: 8px 16px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
}

.oddb-repeater-add:hover {
    background: #1d4ed8;
}

/* HTML Block */
.oddb-field-html {
    padding: 15px;
    background: #f9fafb;
    border-left: 3px solid #2563eb;
    border-radius: 4px;
}

.oddb-field-html h1,
.oddb-field-html h2,
.oddb-field-html h3 {
    margin-top: 0;
}

.oddb-field-html p:last-child {
    margin-bottom: 0;
}

/* File upload hint */
.oddb-field-hint {
    font-size: 12px;
    color: #6b7280;
    margin-top: 4px;
    margin-bottom: 0;
}

/* Month/Week inputs */
input[type="month"],
input[type="week"] {
    padding: 10px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 14px;
    width: 100%;
    max-width: 200px;
}

/* Responsive updates */
@media (max-width: 640px) {
    .oddb-name-fields,
    .oddb-address-row {
        flex-direction: column;
    }
    
    .oddb-name-title,
    .oddb-name-first,
    .oddb-name-middle,
    .oddb-name-last,
    .oddb-address-city,
    .oddb-address-state,
    .oddb-address-zip {
        width: 100%;
    }
    
    .oddb-image-choice {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    }
}

