/* =====================================================================
 * AECI - ACF Custom Icon field
 * Frontend & admin styles for the field UI and the icon picker modal.
 * Frontend wrappers (.aeci-icon-wrapper, .aeci-icon) come from the widgets
 * and are intentionally minimal so user controls in Elementor take over.
 * ===================================================================== */

/* ---------------------------------------------------------------------
 * Field UI on the post edit screen
 * ------------------------------------------------------------------- */

.aeci-icon-field-wrapper {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.aeci-icon-preview {
    width: 36px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    background: #fff;
    color: #1d2327;
    flex-shrink: 0;
}

.aeci-icon-preview i {
    font-size: 20px;
    line-height: 1;
}

.aeci-icon-preview:empty::after {
    content: '';
    display: block;
    width: 12px;
    height: 12px;
    border: 1px dashed #c3c4c7;
    border-radius: 2px;
}

/* ---------------------------------------------------------------------
 * Modal (Vanilla JS picker)
 * ------------------------------------------------------------------- */

body.aeci-modal-open {
    overflow: hidden;
}

.aeci-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    z-index: 160000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    box-sizing: border-box;
    animation: aeci-fade-in 120ms ease-out;
}

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

.aeci-modal-dialog {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 20px 60px -10px rgba(0, 0, 0, 0.35);
    width: 100%;
    max-width: 880px;
    max-height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font: 13px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #1d2327;
    animation: aeci-pop-in 140ms cubic-bezier(0.2, 0.8, 0.4, 1.1);
}

@keyframes aeci-pop-in {
    from { transform: translateY(8px) scale(0.98); opacity: 0; }
    to   { transform: translateY(0)   scale(1);    opacity: 1; }
}

.aeci-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid #e0e0e0;
}

.aeci-modal-title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    color: #1d2327;
}

.aeci-modal-close {
    background: transparent;
    border: 0;
    cursor: pointer;
    font-size: 26px;
    line-height: 1;
    padding: 4px 10px;
    color: #50575e;
    border-radius: 4px;
}

.aeci-modal-close:hover,
.aeci-modal-close:focus-visible {
    background: #f0f0f1;
    color: #1d2327;
    outline: none;
}

.aeci-modal-search {
    margin: 12px 18px 0;
    padding: 10px 12px;
    font-size: 14px;
    border: 1px solid #c3c4c7;
    border-radius: 4px;
    box-sizing: border-box;
    width: calc(100% - 36px);
    background: #fff;
}

.aeci-modal-search:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.2);
    outline: none;
}

.aeci-modal-recent {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 18px 4px;
    flex-wrap: wrap;
}

.aeci-modal-recent-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: #50575e;
    margin-right: 4px;
}

.aeci-modal-recent-item {
    width: 30px;
    height: 30px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    background: #fff;
    cursor: pointer;
    color: #1d2327;
    transition: border-color 100ms, background-color 100ms;
}

.aeci-modal-recent-item:hover,
.aeci-modal-recent-item:focus-visible {
    border-color: #2271b1;
    background: #f0f6fc;
    outline: none;
}

.aeci-modal-recent-item i {
    font-size: 14px;
}

.aeci-modal-tabs {
    display: flex;
    gap: 4px;
    padding: 8px 18px 0;
    border-bottom: 1px solid #e0e0e0;
    overflow-x: auto;
    flex-shrink: 0;
}

.aeci-modal-tab {
    background: transparent;
    border: 0;
    padding: 8px 14px;
    font-size: 13px;
    font-weight: 500;
    color: #50575e;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    white-space: nowrap;
    border-radius: 4px 4px 0 0;
    transition: color 100ms, border-color 100ms, background-color 100ms;
}

.aeci-modal-tab:hover {
    color: #1d2327;
    background: #f6f7f7;
}

.aeci-modal-tab.is-active {
    color: #2271b1;
    border-bottom-color: #2271b1;
}

.aeci-modal-tab:focus-visible {
    outline: 2px solid #2271b1;
    outline-offset: -2px;
}

.aeci-modal-body {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.aeci-modal-grid {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    padding: 10px 18px;
    outline: none;
}

.aeci-modal-grid:focus-visible {
    box-shadow: inset 0 0 0 2px #2271b1;
}

.aeci-modal-grid-inner {
    position: relative;
    width: 100%;
}

.aeci-modal-grid-pool {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 8px;
    will-change: transform;
}

.aeci-modal-cell {
    aspect-ratio: 1 / 1;
    width: 64px;
    height: 64px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 1px solid #dcdcde;
    border-radius: 4px;
    cursor: pointer;
    color: #1d2327;
    transition: border-color 80ms, background-color 80ms, transform 80ms;
    padding: 0;
}

.aeci-modal-cell i {
    font-size: 22px;
    line-height: 1;
}

.aeci-modal-cell:hover {
    border-color: #2271b1;
    background: #f6f7f7;
}

.aeci-modal-cell.is-cursor {
    border-color: #2271b1;
    box-shadow: 0 0 0 2px rgba(34, 113, 177, 0.18);
}

.aeci-modal-cell.is-selected {
    border-color: #2271b1;
    background: #e7f1fb;
    color: #135e96;
}

.aeci-modal-cell:focus-visible {
    outline: 2px solid #2271b1;
    outline-offset: 1px;
}

.aeci-modal-footer {
    border-top: 1px solid #e0e0e0;
    padding: 10px 18px;
    background: #f6f7f7;
}

.aeci-modal-status {
    font-size: 12px;
    color: #50575e;
}

/* Compact mobile / small modal layout */
@media (max-width: 640px) {
    .aeci-modal-overlay { padding: 0; }
    .aeci-modal-dialog { border-radius: 0; max-width: 100%; max-height: 100%; height: 100%; }
    .aeci-modal-cell { width: auto; height: 56px; }
    .aeci-modal-cell i { font-size: 18px; }
}

/* ---------------------------------------------------------------------
 * Editor placeholder (Elementor edit mode only)
 * ------------------------------------------------------------------- */

.aeci-editor-placeholder {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 14px 18px;
    border: 1px dashed #c8c8d8;
    border-radius: 6px;
    background: #faf9fb;
    color: #4a4a55;
    font: 12px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    text-align: center;
    min-width: 180px;
}

.aeci-editor-placeholder__icon {
    font-size: 18px;
    color: #b9740c;
}

.aeci-editor-placeholder__title {
    font-weight: 600;
    color: #1d2327;
}

.aeci-editor-placeholder__message {
    font-size: 11px;
    color: #6c6c78;
    max-width: 220px;
    word-break: break-word;
}

/* ---------------------------------------------------------------------
 * Universal animations
 *
 * These mirror the most-used Font Awesome animations but apply to any
 * icon set (IcoMoon, Fontello, etc.) since they target our wrapper class
 * instead of FA-specific classes.
 * ------------------------------------------------------------------- */

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

@keyframes aeci-pulse {
    0%, 100% { transform: scale(1);    opacity: 1;   }
    50%      { transform: scale(1.15); opacity: 0.6; }
}

@keyframes aeci-bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40%                     { transform: translateY(-10px); }
    60%                     { transform: translateY(-5px); }
}

.aeci-icon i.aeci-spin   { animation: aeci-spin   1.4s linear infinite; transform-origin: center; }
.aeci-icon i.aeci-pulse  { animation: aeci-pulse  1.2s ease-in-out infinite; transform-origin: center; }
.aeci-icon i.aeci-bounce { animation: aeci-bounce 1.6s ease-in-out infinite; transform-origin: center; }

/* Respect users who prefer reduced motion. */
@media (prefers-reduced-motion: reduce) {
    .aeci-icon i.aeci-spin,
    .aeci-icon i.aeci-pulse,
    .aeci-icon i.aeci-bounce {
        animation: none;
    }
}
