/**
 * PC Form Builder Public Styles
 *
 * Frontend styling for the form builder plugin.
 *
 * @package PCFormBuilder
 */

/* CSS Variables */
:root {
    --pcfb-primary: #2271b1;
    --pcfb-primary-dark: #135e96;
    --pcfb-primary-light: #72aee6;
    --pcfb-success: #00a32a;
    --pcfb-success-light: #dcfce1;
    --pcfb-danger: #d63638;
    --pcfb-danger-light: #fbe9e9;
    --pcfb-warning: #dba617;
    --pcfb-warning-light: #fff9c4;
    --pcfb-text: #3c434a;
    --pcfb-text-light: #6c7781;
    --pcfb-bg: #ffffff;
    --pcfb-bg-light: #f6f7f7;
    --pcfb-border: #e1e2e3;
    --pcfb-border-radius: 6px;
    --pcfb-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --pcfb-transition: all 0.2s ease;
    --pcfb-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
}

/* Reset & Base */
.pcfb-form-wrapper {
    font-family: var(--pcfb-font-family);
    font-size: 16px;
    line-height: 1.5;
    color: var(--pcfb-text);
    box-sizing: border-box;
}

.pcfb-form-wrapper *,
.pcfb-form-wrapper *::before,
.pcfb-form-wrapper *::after {
    box-sizing: border-box;
}

/* Container */
.pcfb-form-container {
    background: var(--pcfb-bg);
    border: 1px solid var(--pcfb-border);
    border-radius: var(--pcfb-border-radius);
    box-shadow: var(--pcfb-box-shadow);
    padding: 30px;
    max-width: 100%;
}

/* Form Header */
.pcfb-form-header {
    margin-bottom: 25px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--pcfb-border);
}

.pcfb-form-title {
    margin: 0 0 10px;
    font-size: 24px;
    font-weight: 700;
    color: var(--pcfb-text);
    line-height: 1.3;
}

.pcfb-form-description {
    margin: 0;
    font-size: 15px;
    color: var(--pcfb-text-light);
}

/* Form Fields */
.pcfb-form-fields {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.pcfb-form-group {
    display: flex;
    flex-direction: column;
}

.pcfb-label {
    font-weight: 600;
    font-size: 14px;
    color: var(--pcfb-text);
    margin-bottom: 8px;
}

.pcfb-required {
    color: var(--pcfb-danger);
    margin-left: 3px;
}

/* Input Styles */
.pcfb-input,
.pcfb-textarea,
.pcfb-select {
    width: 100%;
    padding: 12px 15px;
    font-family: inherit;
    font-size: 15px;
    line-height: 1.5;
    color: var(--pcfb-text);
    background-color: var(--pcfb-bg);
    border: 1px solid var(--pcfb-border);
    border-radius: var(--pcfb-border-radius);
    transition: var(--pcfb-transition);
    appearance: none;
}

.pcfb-input:focus,
.pcfb-textarea:focus,
.pcfb-select:focus {
    outline: none;
    border-color: var(--pcfb-primary);
    box-shadow: 0 0 0 3px rgba(34, 113, 177, 0.15);
}

.pcfb-input::placeholder,
.pcfb-textarea::placeholder {
    color: var(--pcfb-text-light);
    opacity: 1;
}

.pcfb-textarea {
    resize: vertical;
    min-height: 100px;
    max-height: 400px;
}

.pcfb-select {
    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='%236c7781' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 15px center;
    padding-right: 40px;
    cursor: pointer;
}

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

.pcfb-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 400;
    font-size: 15px;
    color: var(--pcfb-text);
    padding: 5px 0;
}

.pcfb-checkbox-label:hover .pcfb-checkbox-text {
    color: var(--pcfb-primary);
}

.pcfb-checkbox {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    accent-color: var(--pcfb-primary);
    flex-shrink: 0;
}

.pcfb-checkbox:checked + .pcfb-checkbox-text {
    color: var(--pcfb-text);
}

.pcfb-checkbox-text {
    transition: var(--pcfb-transition);
}

/* Form Footer */
.pcfb-form-footer {
    margin-top: 30px;
    padding-top: 25px;
    border-top: 1px solid var(--pcfb-border);
}

/* Submit Button */
.pcfb-submit-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 30px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 600;
    line-height: 1;
    color: #fff;
    background: var(--pcfb-primary);
    border: none;
    border-radius: var(--pcfb-border-radius);
    cursor: pointer;
    transition: var(--pcfb-transition);
    text-decoration: none;
    min-width: 160px;
}

.pcfb-submit-button:hover {
    background: var(--pcfb-primary-dark);
    transform: translateY(-1px);
}

.pcfb-submit-button:active {
    transform: translateY(0);
}

.pcfb-submit-button:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

/* Spinner */
.pcfb-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: pcfb-spin 0.8s linear infinite;
}

@keyframes pcfb-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Error Messages */
.pcfb-field-error {
    display: none;
    margin-top: 6px;
    font-size: 13px;
    color: var(--pcfb-danger);
}

.pcfb-form-group.error .pcfb-input,
.pcfb-form-group.error .pcfb-textarea,
.pcfb-form-group.error .pcfb-select {
    border-color: var(--pcfb-danger);
    background-color: var(--pcfb-danger-light);
}

.pcfb-form-group.error .pcfb-field-error {
    display: block;
}

/* Success/Error Messages */
.pcfb-form-message {
    margin-top: 20px;
    padding: 15px 20px;
    border-radius: var(--pcfb-border-radius);
    animation: pcfb-fadeIn 0.3s ease;
}

@keyframes pcfb-fadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pcfb-success-message {
    background-color: var(--pcfb-success-light);
    border: 1px solid var(--pcfb-success);
}

.pcfb-error-message {
    background-color: var(--pcfb-danger-light);
    border: 1px solid var(--pcfb-danger);
}

.pcfb-message-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.pcfb-message-icon {
    font-size: 24px;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
}

.pcfb-success-message .pcfb-message-icon {
    color: var(--pcfb-success);
}

.pcfb-error-message .pcfb-message-icon {
    color: var(--pcfb-danger);
}

.pcfb-message-text {
    margin: 0;
    font-size: 15px;
    color: var(--pcfb-text);
}

/* No Fields Message */
.pcfb-no-fields {
    text-align: center;
    color: var(--pcfb-text-light);
    padding: 40px 20px;
    background: var(--pcfb-bg-light);
    border-radius: var(--pcfb-border-radius);
    margin: 0;
}

/* Responsive Design */
@media screen and (max-width: 600px) {
    .pcfb-form-container {
        padding: 20px;
    }

    .pcfb-form-title {
        font-size: 20px;
    }

    .pcfb-form-fields {
        gap: 15px;
    }

    .pcfb-input,
    .pcfb-textarea,
    .pcfb-select {
        padding: 10px 12px;
        font-size: 16px;
    }

    .pcfb-submit-button {
        width: 100%;
        padding: 14px 20px;
    }

    .pcfb-checkbox-label {
        font-size: 14px;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .pcfb-form-wrapper {
        --pcfb-text: #f0f0f1;
        --pcfb-text-light: #a0a5aa;
        --pcfb-bg: #1d2327;
        --pcfb-bg-light: #2c3338;
        --pcfb-border: #3c434a;
        --pcfb-border-radius: 6px;
        --pcfb-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    }

    .pcfb-form-container {
        background: var(--pcfb-bg);
        border-color: var(--pcfb-border);
    }

    .pcfb-form-header {
        border-bottom-color: var(--pcfb-border);
    }

    .pcfb-form-title {
        color: var(--pcfb-text);
    }

    .pcfb-form-description {
        color: var(--pcfb-text-light);
    }

    .pcfb-label {
        color: var(--pcfb-text);
    }

    .pcfb-input,
    .pcfb-textarea,
    .pcfb-select {
        background-color: var(--pcfb-bg-light);
        border-color: var(--pcfb-border);
        color: var(--pcfb-text);
    }

    .pcfb-input::placeholder,
    .pcfb-textarea::placeholder {
        color: var(--pcfb-text-light);
    }

    .pcfb-checkbox-label {
        color: var(--pcfb-text);
    }

    .pcfb-form-footer {
        border-top-color: var(--pcfb-border);
    }

    .pcfb-message-text {
        color: var(--pcfb-text);
    }

    .pcfb-no-fields {
        background: var(--pcfb-bg-light);
        color: var(--pcfb-text-light);
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .pcfb-form-container {
        border-width: 2px;
    }

    .pcfb-input,
    .pcfb-textarea,
    .pcfb-select {
        border-width: 2px;
    }

    .pcfb-submit-button {
        border: 2px solid #fff;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .pcfb-form-wrapper *,
    .pcfb-form-wrapper *::before,
    .pcfb-form-wrapper *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print Styles */
@media print {
    .pcfb-form-wrapper {
        box-shadow: none;
        border: 1px solid #000;
    }

    .pcfb-form-container {
        box-shadow: none;
    }

    .pcfb-submit-button {
        display: none;
    }
}

/* Accessibility Focus Styles */
.pcfb-input:focus-visible,
.pcfb-textarea:focus-visible,
.pcfb-select:focus-visible,
.pcfb-checkbox:focus-visible {
    outline: 2px solid var(--pcfb-primary);
    outline-offset: 2px;
}

/* Validation Styles */
.pcfb-input:invalid:not(:placeholder-shown),
.pcfb-input.pattern-violation:not(:placeholder-shown) {
    border-color: var(--pcfb-danger);
}

/* Loading State */
.pcfb-form.loading .pcfb-submit-text {
    display: none;
}

.pcfb-form.loading .pcfb-submit-loader {
    display: inline-flex !important;
    align-items: center;
    gap: 8px;
}

.pcfb-form.loading .pcfb-submit-button {
    cursor: wait;
}

/* Form Layout Variations */
.pcfb-form-wrapper.pcfb-form-aligned .pcfb-form-group {
    flex-direction: row;
    align-items: flex-start;
    gap: 20px;
}

.pcfb-form-wrapper.pcfb-form-aligned .pcfb-label {
    flex: 0 0 150px;
    padding-top: 12px;
    margin-bottom: 0;
}

.pcfb-form-wrapper.pcfb-form-aligned .pcfb-input,
.pcfb-form-wrapper.pcfb-form-aligned .pcfb-textarea,
.pcfb-form-wrapper.pcfb-form-aligned .pcfb-select {
    flex: 1;
}

@media screen and (max-width: 768px) {
    .pcfb-form-wrapper.pcfb-form-aligned .pcfb-form-group {
        flex-direction: column;
        gap: 8px;
    }

    .pcfb-form-wrapper.pcfb-form-aligned .pcfb-label {
        flex: none;
        padding-top: 0;
    }
}
