/* Container */
.epf-container {
    max-width: 100%;
    margin: 0 auto;
    background: transparent !important;
}

/* Form */
.epf-form {
    background: transparent !important;
    padding: 20px;
    border: none !important;
    border-radius: 0;
}

/* Horizontal layout */
.epf-layout-horizontal {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: wrap !important;
    gap: 15px !important;
}

.epf-layout-horizontal .epf-checkbox-label,
.epf-layout-horizontal .epf-radio-label {
    margin: 0 !important;
}

/* Fields Container */
.epf-fields {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    margin-bottom: 20px;
}

/* Field Groups */
.epf-field-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.epf-field-wrapper {
    width: 100%;
    flex: 1 1 auto;
    min-width: 0;
}

/* Field group with inline label */
.epf-field-group[data-label-position="inline"] {
    flex-direction: row;
    align-items: center;
}

.epf-field-group[data-label-position="inline"] .epf-label {
    min-width: 120px;
    margin-bottom: 0;
    flex-shrink: 0;
}

.epf-field-group[data-label-position="inline"] .epf-field-wrapper {
    flex: 1 1 0%;
    width: auto;
}

/* Field Widths - each field's slice of the row after its proportional share of the 15px gap is removed */
.epf-field-group.epf-field-width-100 { width: 100% !important; }
.epf-field-group.epf-field-width-90 { width: calc(90% - 13.5px) !important; }
.epf-field-group.epf-field-width-80 { width: calc(80% - 12px) !important; }
.epf-field-group.epf-field-width-75 { width: calc(75% - 11.25px) !important; }
.epf-field-group.epf-field-width-70 { width: calc(70% - 10.5px) !important; }
.epf-field-group.epf-field-width-66 { width: calc(66.666% - 10px) !important; }
.epf-field-group.epf-field-width-60 { width: calc(60% - 9px) !important; }
.epf-field-group.epf-field-width-50 { width: calc(50% - 7.5px) !important; }
.epf-field-group.epf-field-width-40 { width: calc(40% - 6px) !important; }
.epf-field-group.epf-field-width-33 { width: calc(33.333% - 5px) !important; }
.epf-field-group.epf-field-width-30 { width: calc(30% - 4.5px) !important; }
.epf-field-group.epf-field-width-25 { width: calc(25% - 3.75px) !important; }
.epf-field-group.epf-field-width-20 { width: calc(20% - 3px) !important; }
.epf-field-group.epf-field-width-10 { width: calc(10% - 1.5px) !important; }

@media (max-width: 768px) {
    .epf-field-group.epf-field-width-90,
    .epf-field-group.epf-field-width-80,
    .epf-field-group.epf-field-width-75,
    .epf-field-group.epf-field-width-70,
    .epf-field-group.epf-field-width-66,
    .epf-field-group.epf-field-width-60,
    .epf-field-group.epf-field-width-50,
    .epf-field-group.epf-field-width-40,
    .epf-field-group.epf-field-width-33,
    .epf-field-group.epf-field-width-30,
    .epf-field-group.epf-field-width-25,
    .epf-field-group.epf-field-width-20,
    .epf-field-group.epf-field-width-10 {
        width: 100% !important;
    }
    
    .epf-field-group[data-label-position="inline"] {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .epf-field-group[data-label-position="inline"] .epf-label {
        margin-bottom: 8px;
    }
}

/* Labels */
.epf-label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    color: #333;
    font-size: 14px;
}

.epf-required {
    color: #e74c3c;
    margin-right: 3px;
}

/* Input Fields */
.epf-field {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
    text-align: right;
    direction: rtl;
}

/* Select - prevent text cutoff */
select.epf-field {
    white-space: normal;
    height: auto;
    min-height: 42px;
    line-height: 1.5;
}

select.epf-field option {
    white-space: normal;
    padding: 5px;
}

/* Date field - match width of other fields */
input[type="date"].epf-field,
input[type="time"].epf-field {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    -webkit-appearance: none;
    appearance: none;
}

.epf-field:focus {
    outline: none;
    border-color: #4CAF50;
    box-shadow: 0 0 0 2px rgba(76, 175, 80, 0.1);
}

.epf-field:invalid:not(:placeholder-shown) {
    border-color: #e74c3c;
}

/* Textarea */
.epf-textarea {
    min-height: 100px;
    resize: vertical;
    font-family: inherit;
}

/* Static Text */
.epf-static-text {
    padding: 10px 0;
    line-height: 1.6;
    color: #333;
    direction: rtl;
}

.epf-static-text p {
    margin: 0 0 10px;
}

.epf-static-text p:last-child {
    margin-bottom: 0;
}

.epf-static-text ul,
.epf-static-text ol {
    margin: 10px 0;
    padding-right: 25px !important;
    padding-left: 0 !important;
    direction: rtl !important;
    text-align: right !important;
    list-style: none !important;
}

.epf-static-text ol {
    counter-reset: epf-ol-counter;
}

.epf-static-text ol > li {
    counter-increment: epf-ol-counter;
    position: relative;
}

.epf-static-text ol > li::before {
    content: counter(epf-ol-counter) ". ";
    font-weight: inherit;
    unicode-bidi: plaintext;
}

.epf-static-text ul > li::before {
    content: "• ";
    unicode-bidi: plaintext;
}

.epf-static-text li {
    margin-bottom: 5px;
    text-align: right !important;
    direction: rtl !important;
}

/* Signature */
.epf-signature-wrapper {
    margin: 20px 0;
}

.epf-signature-container {
    border: 2px solid #333;
    border-radius: 4px;
    background: #fff;
    margin-top: 10px;
    position: relative;
    height: 200px;
}

.epf-signature-canvas {
    display: block;
    width: 100%;
    height: 100%;
    cursor: crosshair;
    touch-action: none;
}

.epf-btn-clear-signature {
    position: absolute;
    bottom: 8px;
    left: 8px;
    padding: 6px 14px;
    background: #f44336;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    transition: background 0.3s ease;
    z-index: 5;
    box-shadow: 0 1px 4px rgba(0,0,0,0.25);
}

.epf-btn-clear-signature:hover {
    background: #d32f2f;
}

/* Submit Button */
.epf-submit-wrapper {
    margin-top: 20px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.epf-submit-wrapper .epf-messages {
    width: 100%;
    flex: 1 1 100%;
}

.epf-submit-btn {
    padding: 12px 30px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 600;
    transition: background 0.3s ease;
}

.epf-submit-btn:hover {
    background: #45a049;
}

.epf-submit-btn:disabled {
    background: #cccccc;
    cursor: not-allowed;
}

.epf-loading {
    color: #666;
    font-style: italic;
}

/* Messages */
.epf-messages {
    margin-top: 15px;
}

.epf-success-message {
    padding: 12px 16px;
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
    margin-bottom: 10px;
}

.epf-error-message {
    padding: 12px 16px;
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin-bottom: 10px;
}

/* RTL Support */
[dir="rtl"] .epf-form {
    text-align: right;
}

[dir="rtl"] .epf-required {
    margin-right: 0;
    margin-left: 3px;
}

/* Print Styles for PDF */
@media print {
    .epf-btn-clear-signature,
    .epf-submit-wrapper,
    .epf-messages {
        display: none !important;
    }
    
    .epf-form {
        border: none;
        padding: 0;
    }
}

/* Radio and Checkbox Groups - 5+6 */
.epf-radio-group,
.epf-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.epf-radio-label,
.epf-checkbox-label,
.epf-acceptance-label {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
    direction: rtl;
}

.epf-radio-label:hover,
.epf-checkbox-label:hover,
.epf-acceptance-label:hover {
    background-color: #f5f5f5;
}

.epf-radio-input,
.epf-checkbox-input,
.epf-acceptance-input {
    width: 18px;
    height: 18px;
    margin: 0;
    cursor: pointer;
    flex-shrink: 0;
}

.epf-radio-text,
.epf-checkbox-text,
.epf-acceptance-text {
    flex: 1;
    text-align: right;
    white-space: normal;
    word-wrap: break-word;
    line-height: 1.5;
}

/* Horizontal Layout - 6 */
.epf-layout-horizontal {
    flex-direction: row !important;
    flex-wrap: wrap !important;
}

.epf-layout-horizontal .epf-radio-label,
.epf-layout-horizontal .epf-checkbox-label {
    flex: 0 0 auto;
    margin: 0;
}

/* RTL for lists and numbers - scoped to our form only */
.epf-container ul,
.epf-container ol {
    direction: rtl;
    text-align: right;
    padding-right: 20px;
    padding-left: 0;
}

.epf-container li {
    text-align: right;
}

/* Input placeholders RTL - scoped to our form only */
.epf-container input::placeholder,
.epf-container textarea::placeholder {
    text-align: right;
    direction: rtl;
}

/* Table Select Field */
.epf-table-select-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.epf-table-select {
    width: 100%;
    min-width: 500px;
    border-collapse: collapse;
    direction: rtl;
    font-size: 14px;
}

.epf-table-select th,
.epf-table-select td {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: center;
    vertical-align: middle;
    min-width: 90px;
}

.epf-table-select thead th {
    background: #f5f5f5;
    font-weight: bold;
}

.epf-table-select-col {
    width: 50px;
    min-width: 50px;
}

@media (max-width: 768px) {
    .epf-table-select {
        font-size: 13px;
    }

    .epf-table-select th,
    .epf-table-select td {
        padding: 6px 8px;
        min-width: 80px;
    }

    .epf-table-select-col {
        width: 40px;
        min-width: 40px;
    }
}

.epf-table-select-radio {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.epf-table-select-row {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.epf-table-select-row:hover {
    background-color: #f9f9f9;
}

.epf-table-select-row.epf-row-selected {
    background-color: #e8f5e9;
}

/* When "show only selected" is active, hide non-selected rows in PDF capture mode */
.epf-table-select-wrapper[data-show-only-selected="1"].epf-pdf-mode .epf-table-select-row:not(.epf-row-selected) {
    display: none;
}
