/**
 * Kuiba XForm - Modern Frontend Styles
 * Styled to match Miele branding
 */

.kuiba-xform-modern {
    max-width: 600px;
    margin: 2rem auto;
    padding: 0 1rem;
    font-family: "Miele Elements Casnic", -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen-Sans, Ubuntu, Cantarell, 'Helvetica Neue', sans-serif;
}

.kuiba-xform-card {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
    padding: 2rem;
    transition: box-shadow 0.3s ease;
}

.kuiba-xform-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.kuiba-xform-title {
    margin: 0 0 1.5rem;
    font-size: 1.75rem;
    font-weight: 700;
    color: #000000;
}

.kuiba-xform-agent-info {
    background: #f5f5f5;
    border-left: 4px solid #dd9933;
    padding: 1rem;
    margin-bottom: 1.5rem;
    border-radius: 4px;
    font-size: 0.95rem;
    color: #202020;
}

.kuiba-xform-agent-info strong {
    color: #000000;
    font-weight: 700;
}

.kuiba-xform-step {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.kuiba-xform-field-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.kuiba-xform-label {
    font-weight: 500;
    font-size: 0.95rem;
    color: #000000;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.kuiba-xform-required {
    color: #8c0014;
    font-weight: 700;
}

.kuiba-xform-input,
.kuiba-xform-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #c2c2c2;
    border-radius: 4px;
    font-size: 1rem;
    transition: all 0.2s ease;
    background: #fff;
    color: #000000;
    font-family: "Miele Elements Casnic", -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.kuiba-xform-input:focus,
.kuiba-xform-textarea:focus {
    outline: none;
    border-color: #dd9933;
    box-shadow: 0 0 0 3px rgba(221, 153, 51, 0.1);
}

.kuiba-xform-input:disabled {
    background: #f5f5f5;
    cursor: not-allowed;
}

select.kuiba-xform-input {
    cursor: pointer;
}

textarea.kuiba-xform-input {
    resize: vertical;
    min-height: 100px;
}

.kuiba-xform-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.5rem 0;
    font-size: 0.95rem;
    color: #202020;
}

.kuiba-xform-checkbox-label input[type="checkbox"] {
    width: 1.125rem;
    height: 1.125rem;
    cursor: pointer;
    accent-color: #dd9933;
}

/* Radio button group styling */
.kuiba-xform-radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.5rem 0;
}

.kuiba-xform-radio-label {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    padding: 0.75rem 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    font-size: 0.95rem;
    color: #202020;
    transition: all 0.2s ease;
    background: #fff;
}

.kuiba-xform-radio-label:hover {
    border-color: #c2c2c2;
    background: #fafafa;
}

.kuiba-xform-radio-label input[type="radio"] {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
    flex-shrink: 0;
    accent-color: #dd9933;
}

.kuiba-xform-radio-label:has(input[type="radio"]:checked) {
    border-color: #dd9933;
    background: #fffbf5;
    color: #000000;
}

.kuiba-xform-multiselect {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.kuiba-xform-field-description {
    font-size: 0.875rem;
    color: #666666;
    margin: 0;
    line-height: 1.4;
}

.kuiba-xform-signature {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.kuiba-xform-signature-canvas {
    border: 2px solid #c2c2c2;
    border-radius: 4px;
    cursor: crosshair;
    width: 100%;
    height: auto;
    max-width: 600px;
    background: #fff;
}

.kuiba-xform-button {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 500;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    display: inline-block;
    font-family: "Miele Elements Casnic", -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.kuiba-xform-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.kuiba-xform-button-primary {
    background: #dd9933;
    color: #000000;
    font-weight: 500;
}

.kuiba-xform-button-primary:hover:not(:disabled) {
    background: #c2c2c2;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.kuiba-xform-button-secondary {
    background: #e0e0e0;
    color: #202020;
}

.kuiba-xform-button-secondary:hover:not(:disabled) {
    background: #c2c2c2;
}

.kuiba-xform-button-group {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.5rem;
}

.kuiba-xform-button-group .kuiba-xform-button-secondary {
    flex: 0 0 auto;
    min-width: 120px;
}

.kuiba-xform-button-group .kuiba-xform-button-primary {
    flex: 1;
}

.kuiba-xform-error {
    background: #ffe6e6;
    border: 1px solid #ff9999;
    color: #8c0014;
    padding: 1rem;
    border-radius: 4px;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    font-weight: 500;
}

.kuiba-xform-info-box {
    background: #fffbf5;
    border: 1px solid #dd9933;
    border-left: 4px solid #dd9933;
    color: #000000;
    padding: 1rem;
    border-radius: 4px;
    font-size: 0.95rem;
    margin-bottom: 1rem;
    font-weight: 500;
}

.kuiba-xform-success-text {
    color: #2e7d32 !important;
    font-weight: 500;
}

.kuiba-xform-success-card {
    text-align: center;
}

.kuiba-xform-success-icon {
    width: 64px;
    height: 64px;
    background: #dd9933;
    color: #000000;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    margin: 0 auto 1.5rem;
}

.kuiba-xform-error-card {
    text-align: center;
}

.kuiba-xform-message {
    font-size: 1.1rem;
    color: #202020;
    line-height: 1.6;
    margin: 0 0 1.5rem;
}

/* Customer lookup messages */
.kuiba-xform-lookup-message {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
    animation: kuiba-xform-slide-in 0.3s ease-out;
}

.kuiba-xform-lookup-success {
    background: #e8f5e9;
    border-left: 4px solid #2e7d32;
    color: #1b5e20;
}

.kuiba-xform-lookup-info {
    background: #fffbf5;
    border-left: 4px solid #dd9933;
    color: #000000;
}

@keyframes kuiba-xform-slide-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Autofilled field animation */
.kuiba-xform-autofilled {
    background-color: #fff9e6 !important;
    transition: background-color 2s ease;
}

/* Loading state */
@keyframes kuiba-xform-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.kuiba-xform-button:disabled {
    animation: kuiba-xform-pulse 1.5s ease-in-out infinite;
}

/* Mobile responsiveness */
@media (max-width: 640px) {
    .kuiba-xform-modern {
        margin: 1rem auto;
    }

    .kuiba-xform-card {
        padding: 1.5rem;
    }

    .kuiba-xform-title {
        font-size: 1.5rem;
    }

    .kuiba-xform-signature-canvas {
        width: 100%;
    }

    .kuiba-xform-button {
        width: 100%;
    }

    .kuiba-xform-button-group {
        flex-direction: column;
    }

    .kuiba-xform-button-group .kuiba-xform-button-secondary,
    .kuiba-xform-button-group .kuiba-xform-button-primary {
        width: 100%;
        flex: 1;
    }
}

/* Print styles */
@media print {
    .kuiba-xform-modern {
        box-shadow: none;
    }

    .kuiba-xform-button {
        display: none;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .kuiba-xform-input,
    .kuiba-xform-textarea {
        border-width: 2px;
    }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
    .kuiba-xform-card,
    .kuiba-xform-button,
    .kuiba-xform-input {
        transition: none;
    }

    .kuiba-xform-button:disabled {
        animation: none;
    }
}

/* Customer Selection Modal */
.kuiba-xform-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    padding: 1rem;
    animation: kuiba-xform-fade-in 0.3s ease-out;
}

@keyframes kuiba-xform-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.kuiba-xform-modal {
    background: #fff;
    border-radius: 8px;
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2), 0 10px 10px -5px rgba(0, 0, 0, 0.1);
    animation: kuiba-xform-scale-in 0.3s ease-out;
}

@keyframes kuiba-xform-scale-in {
    from {
        transform: scale(0.95);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.kuiba-xform-modal-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #000000;
    margin: 0;
    padding: 1.5rem 1.5rem 0.5rem;
    border-bottom: 2px solid #e0e0e0;
}

.kuiba-xform-modal-description {
    font-size: 0.95rem;
    color: #666666;
    margin: 0;
    padding: 1rem 1.5rem;
}

.kuiba-xform-customer-list {
    padding: 1rem 1.5rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.kuiba-xform-customer-option {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    padding: 1rem;
    border: 2px solid #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fff;
}

.kuiba-xform-customer-option:hover {
    border-color: #c2c2c2;
    background: #fafafa;
}

.kuiba-xform-customer-option:has(input[type="radio"]:checked) {
    border-color: #dd9933;
    background: #fffbf5;
}

.kuiba-xform-customer-option input[type="radio"] {
    width: 1.25rem;
    height: 1.25rem;
    cursor: pointer;
    flex-shrink: 0;
    margin-top: 0.25rem;
    accent-color: #dd9933;
}

.kuiba-xform-customer-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.kuiba-xform-customer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.kuiba-xform-customer-header strong {
    font-size: 1.05rem;
    color: #000000;
    font-weight: 700;
}

.kuiba-xform-customer-number {
    font-size: 0.875rem;
    color: #666666;
    background: #f5f5f5;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-weight: 500;
}

.kuiba-xform-customer-details {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.875rem;
    color: #202020;
}

.kuiba-xform-customer-details span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.kuiba-xform-customer-address {
    font-size: 0.875rem;
    color: #666666;
}

.kuiba-xform-modal-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e0e0e0;
}

.kuiba-xform-modal-actions button {
    flex: 1;
}

.kuiba-xform-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 1.5rem 0;
}

.kuiba-xform-modal-header .kuiba-xform-modal-title {
    padding: 0;
    border-bottom: none;
    margin: 0;
}

.kuiba-xform-modal-close {
    background: transparent;
    border: none;
    font-size: 2rem;
    line-height: 1;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.kuiba-xform-modal-close:hover {
    background: #f0f0f0;
    color: #000;
}

.kuiba-xform-modal-body {
    padding: 1.5rem;
    max-height: 60vh;
    overflow-y: auto;
}

.kuiba-xform-modal-actions {
    padding: 1rem 1.5rem 1.5rem;
    border-top: 1px solid #e0e0e0;
    margin: 0;
}

/* Mobile modal adjustments */
@media (max-width: 640px) {
    .kuiba-xform-modal {
        margin: 0.5rem;
        max-height: 95vh;
    }

    .kuiba-xform-modal-title {
        font-size: 1.25rem;
        padding: 1rem 1rem 0.5rem;
    }

    .kuiba-xform-modal-description {
        padding: 0.75rem 1rem;
    }

    .kuiba-xform-customer-list {
        padding: 0.75rem 1rem 1rem;
    }

    .kuiba-xform-customer-option {
        padding: 0.75rem;
    }

    .kuiba-xform-modal-actions {
        flex-direction: column;
    }

    .kuiba-xform-modal-actions button {
        width: 100%;
    }
}
