/**
 * Ultimate Form Builder - Frontend Styles
 * Professional and responsive form styling
 */

/* === BASE FORM STYLES === */
.ufb-form {
    max-width: 100%;
    margin: 20px 0;
    padding: 30px;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    position: relative;
}

.ufb-form * {
    box-sizing: border-box;
}

/* === FORM HEADER === */
.ufb-form-title {
    margin: 0 0 15px 0;
    font-size: 24px;
    font-weight: 600;
    color: #333333;
    text-align: center;
}

.ufb-form-description {
    margin: 0 0 25px 0;
    font-size: 16px;
    color: #666666;
    text-align: center;
    line-height: 1.5;
}

/* === FORM LAYOUT === */
.ufb-fields-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 25px;
    width: 100%;
}

/* Base column layouts - only apply on screens larger than 600px */
@media (min-width: 601px) {
    .ufb-columns-1 .ufb-field {
        flex: 1 1 100%;
        max-width: 100%;
    }

    .ufb-columns-2 .ufb-field {
        flex: 1 1 calc(50% - 10px);
        max-width: calc(50% - 10px);
    }

    .ufb-columns-3 .ufb-field {
        flex: 1 1 calc(33.333% - 14px);
        max-width: calc(33.333% - 14px);
    }

    .ufb-columns-4 .ufb-field {
        flex: 1 1 calc(25% - 15px);
        max-width: calc(25% - 15px);
    }
}

/* === FIELD WIDTH OVERRIDES === */
@media (min-width: 601px) {
    .ufb-width-full {
        flex: 1 1 100% !important;
        max-width: 100% !important;
    }

    .ufb-width-half {
        flex: 1 1 calc(50% - 10px) !important;
        max-width: calc(50% - 10px) !important;
    }

    .ufb-width-third {
        flex: 1 1 calc(33.333% - 14px) !important;
        max-width: calc(33.333% - 14px) !important;
    }

    .ufb-width-two-thirds {
        flex: 1 1 calc(66.666% - 7px) !important;
        max-width: calc(66.666% - 7px) !important;
    }

    .ufb-width-quarter {
        flex: 1 1 calc(25% - 15px) !important;
        max-width: calc(25% - 15px) !important;
    }
}

/* Mobile - all fields full width */
@media (max-width: 600px) {
    .ufb-field,
    .ufb-width-full,
    .ufb-width-half,
    .ufb-width-third,
    .ufb-width-two-thirds,
    .ufb-width-quarter {
        flex: 1 1 100% !important;
        max-width: 100% !important;
    }
}

/* === FIELD STYLES === */
.ufb-field {
    display: flex;
    flex-direction: column;
    margin-bottom: 0;
    min-width: 0; /* Prevent flex overflow */
}

/* Debug mode - uncomment to see column boundaries */
/*
.ufb-field {
    border: 2px dashed #e74c3c;
    background: rgba(231, 76, 60, 0.1);
}
.ufb-fields-container {
    border: 3px solid #3498db;
    background: rgba(52, 152, 219, 0.1);
}
*/

.ufb-field-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    color: #333333;
    line-height: 1.4;
}

.ufb-required-mark {
    color: #e74c3c;
    margin-left: 3px;
    font-weight: bold;
}

.ufb-field-input {
    position: relative;
}

/* === INPUT STYLES === */
.ufb-input {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e1e5e9;
    border-radius: 6px;
    font-size: 16px;
    font-family: inherit;
    background-color: #ffffff;
    color: #333333;
    transition: all 0.3s ease;
    outline: none;
}

.ufb-input:focus {
    border-color: #3498db;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

/* Only show validation errors after form interaction */
.ufb-form.ufb-validated .ufb-input:invalid,
.ufb-field.ufb-error .ufb-input {
    border-color: #e74c3c;
}

.ufb-input::placeholder {
    color: #999999;
    opacity: 1;
}

/* === TEXTAREA === */
.ufb-textarea {
    min-height: 120px;
    resize: vertical;
    font-family: inherit;
}

/* === SELECT === */
.ufb-select {
    cursor: pointer;
    background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 4 5'%3E%3Cpath fill='%23666' d='M2 0L0 2h4zm0 5L0 3h4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 12px;
    padding-right: 40px;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
}

/* === RADIO AND CHECKBOX GROUPS === */
.ufb-radio-group,
.ufb-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ufb-radio-option,
.ufb-checkbox-option {
    display: flex;
    align-items: center;
    cursor: pointer;
    font-size: 16px;
    line-height: 1.4;
    padding: 8px 0;
    transition: all 0.2s ease;
}

.ufb-radio-option:hover,
.ufb-checkbox-option:hover {
    background-color: #f8f9fa;
    border-radius: 4px;
    padding-left: 8px;
    padding-right: 8px;
}

.ufb-radio,
.ufb-checkbox {
    width: 18px !important;
    height: 18px !important;
    margin-right: 10px;
    margin-bottom: 0;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    border: 2px solid #d1d5db;
    background: #ffffff;
    position: relative;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.ufb-radio {
    border-radius: 50%;
}

.ufb-checkbox {
    border-radius: 4px;
}

.ufb-radio:hover,
.ufb-checkbox:hover {
    border-color: #3498db;
    background: #f8f9fa;
}

.ufb-radio:checked,
.ufb-checkbox:checked {
    background: #3498db;
    border-color: #3498db;
}

.ufb-radio:checked::after {
    content: "";
    position: absolute;
    width: 8px;
    height: 8px;
    background: #ffffff;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.ufb-checkbox:checked::after {
    content: "✓";
    position: absolute;
    color: #ffffff;
    font-size: 12px;
    font-weight: bold;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    line-height: 1;
}

.ufb-radio:focus,
.ufb-checkbox:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

.ufb-radio-label,
.ufb-checkbox-label {
    flex: 1;
    color: #333333;
}

/* === FILE INPUT === */
.ufb-file {
    padding: 10px;
    border-style: dashed;
    background-color: #f8f9fa;
    cursor: pointer;
    transition: all 0.3s ease;
}

.ufb-file:hover {
    background-color: #e9ecef;
    border-color: #3498db;
}

/* === SUBMIT BUTTON === */
.ufb-submit-container {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #e1e5e9;
}

.ufb-align-left {
    text-align: left;
}

.ufb-align-center {
    text-align: center;
}

.ufb-align-right {
    text-align: right;
}

.ufb-submit-btn {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none !important;
    border-radius: 6px;
    font-family: inherit;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
    position: relative;
    overflow: hidden;
    background: linear-gradient(135deg, #3498db, #2980b9) !important;
    color: #ffffff !important;
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
    text-decoration: none !important;
}

.ufb-submit-btn:hover {
    transform: translateY(-2px) !important;
    box-shadow: 0 6px 20px rgba(52, 152, 219, 0.4) !important;
}

.ufb-submit-btn:active {
    transform: translateY(0) !important;
}

.ufb-submit-btn:disabled {
    opacity: 0.7 !important;
    cursor: not-allowed !important;
    transform: none !important;
}

/* Button Sizes */
.ufb-btn-small {
    padding: 10px 20px !important;
    font-size: 14px !important;
}

.ufb-btn-medium {
    padding: 12px 30px !important;
    font-size: 16px !important;
}

.ufb-btn-large {
    padding: 15px 40px !important;
    font-size: 18px !important;
}

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

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

/* === MESSAGES === */
.ufb-messages {
    margin-bottom: 20px;
}

.ufb-message {
    padding: 15px 20px;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.ufb-success-message {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.ufb-success-message::before {
    content: "\2714";
    font-family: "Arial Unicode MS", "Segoe UI Symbol", sans-serif;
    font-weight: bold;
    font-size: 18px;
}

.ufb-error-message {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.ufb-error-message::before {
    content: "⚠";
    font-weight: bold;
    font-size: 18px;
}

/* === FIELD ERRORS === */
.ufb-field-error {
    color: #e74c3c;
    font-size: 14px;
    margin-top: 5px;
    font-weight: 500;
}

.ufb-field.ufb-has-error .ufb-input {
    border-color: #e74c3c;
    box-shadow: 0 0 0 3px rgba(231, 76, 60, 0.1);
}

/* === LOADING STATE === */
.ufb-form.ufb-loading {
    opacity: 0.7;
    pointer-events: none;
}

.ufb-form.ufb-loading .ufb-submit-btn {
    cursor: wait;
}

/* === HONEYPOT === */
.ufb-honeypot {
    position: absolute !important;
    left: -9999px !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* === RESPONSIVE DESIGN === */
@media (max-width: 600px) {
    .ufb-form {
        padding: 20px;
        margin: 10px 0;
    }
    
    .ufb-fields-container {
        gap: 15px;
    }
    
    /* Convert 3 and 4 columns to 2 columns on small tablets */
    .ufb-columns-3 .ufb-field,
    .ufb-columns-4 .ufb-field {
        flex: 1 1 calc(50% - 10px);
    }
    
    .ufb-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .ufb-radio-group,
    .ufb-checkbox-group {
        gap: 8px;
    }
    
    .ufb-submit-btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    /* Convert all columns to single column on mobile */
    .ufb-columns-2 .ufb-field,
    .ufb-columns-3 .ufb-field,
    .ufb-columns-4 .ufb-field {
        flex: 1 1 100%;
    }
    
    .ufb-width-half,
    .ufb-width-third,
    .ufb-width-two-thirds,
    .ufb-width-quarter {
        flex: 1 1 100% !important;
    }
}

@media (max-width: 480px) {
    .ufb-form {
        padding: 15px;
        border-radius: 4px;
    }
    
    .ufb-form-title {
        font-size: 20px;
    }
    
    .ufb-form-description {
        font-size: 14px;
    }
    
    .ufb-input {
        padding: 10px 14px;
    }
    
    .ufb-submit-btn {
        padding: 12px 20px;
        font-size: 16px;
    }
    
    /* Convert all columns to single column on mobile */
    .ufb-columns-2 .ufb-field,
    .ufb-columns-3 .ufb-field,
    .ufb-columns-4 .ufb-field {
        flex: 1 1 100%;
    }
    
    .ufb-width-half,
    .ufb-width-third,
    .ufb-width-two-thirds,
    .ufb-width-quarter {
        flex: 1 1 100% !important;
    }
}

/* === ACCESSIBILITY === */
.ufb-input:focus,
.ufb-submit-btn:focus {
    outline: 2px solid #ffa9af;
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .ufb-input,
    .ufb-submit-btn,
    .ufb-radio-option,
    .ufb-checkbox-option {
        transition: none;
    }
    
    .ufb-submit-spinner {
        animation: none;
    }
}

/* === PRINT STYLES === */
@media print {
    .ufb-form {
        box-shadow: none;
        border: 1px solid #ccc;
    }
    
    .ufb-submit-container {
        display: none;
    }
    
    .ufb-messages {
        display: none;
    }
}

/* === HIGH CONTRAST MODE === */
@media (prefers-contrast: high) {
    .ufb-input {
        border-width: 3px;
    }
    
    .ufb-submit-btn {
        border: 3px solid currentColor;
    }
}

/* === CONSENT STYLES === */
.ufb-consent-container {
    margin: 20px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.ufb-consent-item {
    margin: 10px 0;
    display: flex;
    align-items: flex-start;
    gap: 0;
}

.ufb-consent-label {
    display: flex;
    align-items: flex-start;
    gap: 0;
    margin: 0;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.4;
    width: 100%;
}

.ufb-consent-checkbox {
    background-image: none !important;
    width: 18px;
    height: 18px;
    margin: 0;
    flex-shrink: 0;
    margin-top: 2px;
    margin-right: 8px;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    border: 2px solid #d1d5db;
    border-radius: 4px;
    background: #ffffff;
    position: relative;
    transition: all 0.2s ease;
    pointer-events: auto;
}

.ufb-consent-checkbox:hover {
    border-color: #ff4d5b;
    background: #f8f9fa;
}

.ufb-consent-checkbox:checked {
    background: #ff4d5b;
    border-color: #ff4d5b;
}

.ufb-consent-checkbox:checked::after {
    font-family: "Segoe UI Symbol", "Noto Sans Symbols", sans-serif;
    content: "\2713";
    position: absolute;
    color: #ffffff;
    font-size: 12px;
    font-weight: bold;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    line-height: 1;
}

.ufb-consent-checkbox:focus {
    outline: 2px solid #ff4d5b;
    outline-offset: 2px;
}

.ufb-consent-title {
    color: #858799;
    text-decoration: underline;
    cursor: pointer;
    transition: color 0.2s ease;
    font-weight: 500;
}

.ufb-consent-title:hover {
    color: #005a87;
}

.ufb-consent-text {
    flex: 1;
    margin-left: 4px;
}

.ufb-consent-error {
    background: #fff2f2;
    border: 1px solid #dc3232;
    color: #dc3232;
    padding: 10px;
    border-radius: 4px;
    font-size: 14px;
    margin-top: 10px;
}

/* === CONSENT DISCLAIMER === */
.ufb-consent-disclaimer {
    margin: 15px 0;
    padding: 20px;
    background-color: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-left: 4px solid #007acc;
    border-radius: 6px;
    font-size: 14px;
    line-height: 1.6;
    color: #333333;
    position: relative;
}

.ufb-consent-disclaimer p {
    margin: 0 0 10px 0;
}

.ufb-consent-disclaimer p:last-child {
    margin-bottom: 0;
}

.ufb-consent-disclaimer a {
    color: #007acc;
    text-decoration: underline;
}

.ufb-consent-disclaimer a:hover {
    color: #005a99;
    text-decoration: none;
}

.ufb-consent-disclaimer strong,
.ufb-consent-disclaimer b {
    font-weight: 600;
    color: #222222;
}

.ufb-consent-disclaimer ul,
.ufb-consent-disclaimer ol {
    margin: 10px 0;
    padding-left: 20px;
}

.ufb-consent-disclaimer li {
    margin-bottom: 5px;
}

/* Mobile responsiveness */
@media (max-width: 600px) {
    .ufb-consent-disclaimer {
        padding: 15px;
        font-size: 13px;
        margin-top: 12px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .ufb-consent-disclaimer {
        background-color: #2c2c2c;
        border-color: #444444;
        border-left-color: #4a9eff;
        color: #e0e0e0;
    }
    
    .ufb-consent-disclaimer strong,
    .ufb-consent-disclaimer b {
        color: #ffffff;
    }
    
    .ufb-consent-disclaimer a {
        color: #4a9eff;
    }
    
    .ufb-consent-disclaimer a:hover {
        color: #80c0ff;
    }
}

/* === CONSENT MODAL === */
.ufb-consent-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: ufb-modal-fade-in 0.3s ease;
}

.ufb-consent-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    cursor: pointer;
}

.ufb-consent-modal-content {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    animation: ufb-modal-slide-in 0.3s ease;
}

.ufb-consent-modal-header {
    padding: 20px 25px 15px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.ufb-consent-modal-header h3 {
    margin: 0;
    font-size: 24px;
    font-weight: 600;
    color: #333;
}

.ufb-consent-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.2s ease;
}

.ufb-consent-modal-close:hover {
    background: #f0f0f0;
    color: #666;
}

.ufb-consent-modal-body {
    padding: 20px 25px;
    overflow-y: auto;
    flex: 1;
    font-size: 15px;
    line-height: 1.7;
    color: #333;
}

/* Naslovi */
.ufb-consent-modal-body h1,
.ufb-consent-modal-body h2,
.ufb-consent-modal-body h3,
.ufb-consent-modal-body h4,
.ufb-consent-modal-body h5,
.ufb-consent-modal-body h6 {
    font-weight: 600;
    margin: 1.2em 0 0.6em;
    color: #222;
    line-height: 1.3;
}

.ufb-consent-modal-body h3 {
    font-size: 20px;
    border-bottom: 1px solid #eee;
    padding-bottom: 4px;
}

/* Liste */
.ufb-consent-modal-body ul,
.ufb-consent-modal-body ol {
    margin: 0 0 1em 1.5em;
    padding: 0;
}

.ufb-consent-modal-body li {
    font-size: 16px !important;
    margin-bottom: 0.4em;
}

.uf-consent-modal-body ol {
    font-size: 16px !important;
}

/* Paragrafi */
.ufb-consent-modal-body p {
    font-size: 16px;
    margin-bottom: 1em;
}

/* Linkovi */
.ufb-consent-modal-body a {
    color: #0073aa;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.ufb-consent-modal-body a:hover {
    color: #005a87;
}

/* Strong & Italic */
.ufb-consent-modal-body strong {
    font-weight: 600;
    color: #111;
}

.ufb-consent-modal-body em,
.ufb-consent-modal-body i {
    font-style: italic;
    color: #555;
}

/* Blockquote */
.ufb-consent-modal-body blockquote {
    border-left: 3px solid #0073aa;
    margin: 1em 0;
    padding-left: 1em;
    color: #555;
    font-style: italic;
    background: #f9f9f9;
}

/* Code or preformatted text */
.ufb-consent-modal-body code,
.ufb-consent-modal-body pre {
    background: #f4f4f4;
    border-radius: 4px;
    padding: 2px 5px;
    font-family: monospace;
    font-size: 14px;
}

.ufb-consent-modal-body pre {
    display: block;
    padding: 10px;
    overflow-x: auto;
}

/* Horizontal line */
.ufb-consent-modal-body hr {
    border: 0;
    border-top: 1px solid #ddd;
    margin: 1.5em 0;
}

.ufb-consent-modal-footer {
    padding: 15px 25px 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    flex-wrap: wrap;
}

.ufb-consent-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    min-width: 80px;
}

.ufb-consent-agree {
    background: #0073aa;
    color: #ffffff;
}

.ufb-consent-agree:hover {
    background: #005a87;
}

.ufb-consent-disagree {
    background: #dc3232;
    color: #ffffff;
}

.ufb-consent-disagree:hover {
    background: #b32d2e;
}

.ufb-consent-close {
    background: #f0f0f0;
    color: #333;
}

.ufb-consent-close:hover {
    background: #e0e0e0;
}

/* Modal animations */
@keyframes ufb-modal-fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes ufb-modal-slide-in {
    from { 
        transform: translateY(-20px);
        opacity: 0;
    }
    to { 
        transform: translateY(0);
        opacity: 1;
    }
}

/* === MODAL BODY LOCK === */
body.ufb-modal-open {
    overflow: hidden;
}

/* === RESPONSIVE CONSENT STYLES === */
@media (max-width: 600px) {
    .ufb-consent-modal-content {
        width: 95%;
        max-height: 90vh;
    }
    
    .ufb-consent-modal-footer {
        flex-direction: column;
    }
    
    .ufb-consent-btn {
        width: 100%;
        justify-content: center;
    }
    
    .ufb-consent-label {
        font-size: 13px;
    }
}