/**
 * Accepta Repeater Control CSS
 * Styles for the repeater control interface
 */

.accepta-repeater-control {
    margin-bottom: 12px;
}

/* Items Container */
.accepta-repeater-items {
    margin-bottom: 12px;
}

/* Individual Item */
.accepta-repeater-item {
    border: 1px solid #ddd;
    border-radius: 4px;
    margin-bottom: 8px;
    background: #fff;
    overflow: hidden;
}

.accepta-repeater-item:last-child {
    margin-bottom: 0;
}

/* Item Header */
.accepta-repeater-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px 8px 25px;
    background: #f7f7f7;
    border-bottom: 1px solid #ddd;
    cursor: pointer;
    user-select: none;
    position: relative;
}

.accepta-repeater-item-header:hover {
    background: #f0f0f1;
}

.accepta-repeater-item-title {
    font-weight: 600;
    color: #333;
    flex: 1;
    margin-right: 10px;
}

.accepta-repeater-item-actions {
    display: flex;
    gap: 4px;
}

.accepta-repeater-item-toggle,
.accepta-repeater-item-delete {
    background: transparent;
    border: none;
    padding: 4px;
    cursor: pointer;
    border-radius: 2px;
    color: #666;
    transition: all 0.2s ease;
}

.accepta-repeater-item-toggle:hover {
    background: #0073aa;
    color: #fff;
}

.accepta-repeater-item-delete:hover {
    background: #d63638;
    color: #fff;
}

.accepta-repeater-item-toggle .dashicons,
.accepta-repeater-item-delete .dashicons {
    width: 16px;
    height: 16px;
    font-size: 16px;
}

/* Item Content */
.accepta-repeater-item-content {
    padding: 12px;
    display: none;
}

/* All items closed by default */
.accepta-repeater-item-toggle .dashicons-arrow-up-alt2 {
    display: none;
}

.accepta-repeater-item-toggle .dashicons-arrow-down-alt2 {
    display: inline-block;
}

/* When item is expanded, show up arrow */
.accepta-repeater-item.expanded .accepta-repeater-item-toggle .dashicons-arrow-down-alt2 {
    display: none;
}

.accepta-repeater-item.expanded .accepta-repeater-item-toggle .dashicons-arrow-up-alt2 {
    display: inline-block;
}

/* Fields */
.accepta-repeater-field {
    margin-bottom: 12px;
}

.accepta-repeater-field:last-child {
    margin-bottom: 0;
}

.accepta-repeater-field-label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 4px;
}

.accepta-repeater-field-input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 3px;
    font-size: 12px;
    line-height: 1.4;
    background: #fff;
    transition: border-color 0.2s ease;
}

.accepta-repeater-field-input:focus {
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
    outline: none;
}

.accepta-repeater-field-input::placeholder {
    color: #999;
    font-style: italic;
}

/* Textarea specific */
.accepta-repeater-field-textarea .accepta-repeater-field-input {
    resize: vertical;
    min-height: 60px;
}

/* Select specific */
.accepta-repeater-field-select .accepta-repeater-field-input {
    cursor: pointer;
}

/* Media Field */
.accepta-repeater-media-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.accepta-repeater-media-preview {
    min-height: 60px;
    border: 2px dashed #ddd;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f9f9f9;
    position: relative;
    overflow: hidden;
}

.accepta-repeater-media-preview:empty::before {
    content: 'No image selected';
    color: #999;
    font-style: italic;
    font-size: 12px;
}

.accepta-repeater-media-preview img {
    max-width: 100%;
    max-height: 60px;
    width: auto;
    height: auto;
    border-radius: 2px;
}

.accepta-repeater-media-actions {
    display: flex;
    gap: 6px;
}

.accepta-repeater-media-actions .button {
    font-size: 11px;
    padding: 4px 8px;
    height: auto;
    line-height: 1.4;
}

/* Add Button */
.accepta-repeater-actions {
    text-align: center;
    padding: 12px 0;
    margin-top: 8px;
}

.accepta-repeater-add-item {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px !important;
    font-size: 13px !important;
    border: 1px solid #0073aa !important;
    background: #0073aa !important;
    color: #fff !important;
    border-radius: 4px !important;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none !important;
    box-shadow: none !important;
    min-width: 120px;
}

.accepta-repeater-add-item:hover {
    background: #005a87 !important;
    border-color: #005a87 !important;
    color: #fff !important;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 115, 170, 0.2) !important;
}

.accepta-repeater-add-item:active {
    background: #004a73 !important;
    border-color: #004a73 !important;
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0, 115, 170, 0.3) !important;
}

.accepta-repeater-add-item:focus {
    background: #0073aa !important;
    border-color: #0073aa !important;
    color: #fff !important;
    box-shadow: 0 0 0 1px #0073aa !important;
}

.accepta-repeater-add-item .dashicons {
    width: 16px !important;
    height: 16px !important;
    font-size: 16px !important;
    line-height: 1 !important;
    margin: 0 !important;
}

/* Empty State */
.accepta-repeater-items:empty::before {
    content: 'No items added yet. Click "Add Item" to get started.';
    display: block;
    padding: 20px;
    text-align: center;
    color: #999;
    font-style: italic;
    border: 2px dashed #ddd;
    border-radius: 4px;
    background: #f9f9f9;
    margin-bottom: 12px;
}

/* Responsive adjustments */
@media (max-width: 782px) {
    .accepta-repeater-item-header {
        padding: 10px;
    }
    
    .accepta-repeater-item-content {
        padding: 10px;
    }
    
    .accepta-repeater-field-input {
        padding: 8px;
        font-size: 14px;
    }
    
    .accepta-repeater-add-item {
        padding: 8px 12px;
        font-size: 14px;
    }
}

/* Animation for smooth interactions */
.accepta-repeater-item-content {
    transition: all 0.3s ease;
}

.accepta-repeater-item {
    transition: all 0.2s ease;
}

.accepta-repeater-item:hover {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Sortable functionality */
.accepta-repeater-item-placeholder {
    visibility: visible !important;
    background: #f0f8ff;
    border: 2px dashed #0073aa;
    margin-bottom: 8px;
    border-radius: 3px;
    min-height: 50px;
}

.accepta-repeater-item-placeholder:before {
    content: 'Drop item here';
    display: block;
    text-align: center;
    color: #0073aa;
    font-style: italic;
    padding: 15px;
    font-size: 12px;
}

.accepta-repeater-item-dragging {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    transform: rotate(3deg);
    z-index: 1000;
}

.accepta-repeater-items.ui-sortable .accepta-repeater-item-header {
    cursor: move;
}

.accepta-repeater-items.ui-sortable .accepta-repeater-item-header:hover {
    background: #e8f4fd;
}

.accepta-repeater-items.ui-sortable .accepta-repeater-item-header:before {
    content: '⋮⋮';
    position: absolute;
    left: 5px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
    font-size: 14px;
    line-height: 1;
}

/* Font Awesome Field Styles */
.accepta-repeater-fontawesome-field {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.accepta-repeater-fontawesome-input {
    flex-grow: 1;
    min-width: 150px;
}

.accepta-repeater-fontawesome-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 32px;
    border: 1px solid #ddd;
    border-radius: 3px;
    background: #f9f9f9;
}

.accepta-repeater-fontawesome-preview i {
    font-size: 16px;
    color: #333;
}

.accepta-repeater-fontawesome-actions {
    display: flex;
    gap: 5px;
}

/* Font Awesome Icon Picker Modal */
.accepta-fontawesome-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999999;
    display: none;
}

.accepta-fontawesome-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    width: 90%;
    max-width: 800px;
    max-height: 80vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.accepta-fontawesome-modal-header {
    padding: 20px;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
}

.accepta-fontawesome-modal-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.accepta-fontawesome-modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 3px;
}

.accepta-fontawesome-modal-close:hover {
    background: #e9ecef;
    color: #333;
}

.accepta-fontawesome-modal-search {
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
}

.accepta-fontawesome-search-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.accepta-fontawesome-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.accepta-fontawesome-category {
    margin-bottom: 30px;
}

.accepta-fontawesome-category-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 15px;
    color: #333;
    border-bottom: 2px solid #0073aa;
    padding-bottom: 5px;
}

.accepta-fontawesome-icons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 10px;
}

.accepta-fontawesome-icon-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fff;
    text-decoration: none;
    color: #333;
}

.accepta-fontawesome-icon-item:hover {
    border-color: #0073aa;
    background: #f0f8ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 115, 170, 0.15);
}

.accepta-fontawesome-icon-item.selected {
    border-color: #0073aa;
    background: #0073aa;
    color: #fff;
}

.accepta-fontawesome-icon-item i {
    font-size: 20px;
    margin-bottom: 8px;
    display: inline-block;
    width: 20px;
    height: 20px;
    text-align: center;
    line-height: 20px;
}

/* Ensure icons are visible even if Font Awesome doesn't load */
.accepta-fontawesome-icon-item i {
    min-height: 20px;
    min-width: 20px;
    background: #f0f0f0;
    border-radius: 3px;
    position: relative;
}

/* Show class name as fallback when Font Awesome doesn't load */
.accepta-fontawesome-icon-item i:after {
    content: attr(class);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 8px;
    color: #666;
    text-align: center;
    line-height: 1;
    max-width: 18px;
    overflow: hidden;
    word-break: break-all;
}

/* Hide fallback text when Font Awesome loads properly */
.accepta-fontawesome-icon-item i.fa:after,
.accepta-fontawesome-icon-item i.fas:after,
.accepta-fontawesome-icon-item i.fab:after,
.accepta-fontawesome-icon-item i.far:after,
.accepta-fontawesome-icon-item i[class*="fa-"]:after {
    display: none;
}

/* Ensure Font Awesome icons show properly */
.accepta-fontawesome-icon-item i.fa,
.accepta-fontawesome-icon-item i.fas,
.accepta-fontawesome-icon-item i.fab,
.accepta-fontawesome-icon-item i.far,
.accepta-fontawesome-icon-item i[class*="fa-"] {
    background: transparent;
}

.accepta-fontawesome-icon-item .icon-name {
    font-size: 11px;
    text-align: center;
    line-height: 1.3;
    word-break: break-word;
}

.accepta-fontawesome-modal-footer {
    padding: 15px 20px;
    border-top: 1px solid #eee;
    background: #f8f9fa;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.accepta-fontawesome-modal-footer .button {
    min-width: 80px;
}

/* Conditional Field Display */
.accepta-repeater-field[data-condition] {
    display: none;
}

.accepta-repeater-field[data-condition].show {
    display: block;
}

/* Hide custom icon field by default, show only when custom is selected */
.accepta-repeater-field[data-field="custom_icon"] {
    display: none;
}

.accepta-repeater-item .accepta-repeater-field[data-field="custom_icon"].show {
    display: block;
}
