/**
 * Like & Save for Elementor – Frontend CSS
 *
 * Minimal, Elementor-first defaults. All appearance is meant to be overridden
 * via Elementor's Style controls. These styles only ensure the widgets are
 * functional and accessible out-of-the-box.
 *
 * Naming: BEM-lite with an `lse-` prefix to avoid conflicts.
 *
 * @package Like_Save_Elementor
 * @version 1.0.0
 */

/* ── Reset & Base ─────────────────────────────────────────────────────────── */
.lse-like-wrap,
.lse-save-wrap {
    display: flex;
    align-items: center;
}

/* ── Like & Save Buttons ──────────────────────────────────────────────────── */
.lse-like-btn,
.lse-save-btn,
.lse-card-action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0;                   /* gap handled via icon spacing controls */
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: 4px;
    padding: 8px 16px;
    font-family: inherit;
    font-size: inherit;
    line-height: 1;
    text-decoration: none;
    background: transparent;
    color: inherit;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    vertical-align: middle;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    outline-offset: 2px;
}

.lse-like-btn:focus-visible,
.lse-save-btn:focus-visible,
.lse-card-action-btn:focus-visible {
    outline: 2px solid currentColor;
}

.lse-like-btn:disabled,
.lse-save-btn:disabled,
.lse-card-action-btn:disabled {
    pointer-events: none;
    opacity: 0.6;
}

/* ── Icon ─────────────────────────────────────────────────────────────────── */
.lse-like-btn .lse-icon,
.lse-save-btn .lse-icon {
    display: inline-flex;
    align-items: center;
    line-height: 1;
    margin-right: 6px;        /* default; overridden by Elementor slider control */
    flex-shrink: 0;
}

.lse-like-btn.lse-icon-after .lse-icon,
.lse-save-btn.lse-icon-after .lse-icon {
    margin-right: 0;
    margin-left: 6px;
}

/* Default icon shown when inactive, liked/saved icon hidden */
.lse-like-btn .lse-liked-icon,
.lse-save-btn .lse-saved-icon {
    display: none;
}

/* Active state: swap icons */
.lse-like-btn.lse-active .lse-liked-icon {
    display: inline-flex;
}
.lse-like-btn.lse-active .lse-default-icon {
    display: none;
}

.lse-save-btn.lse-active .lse-saved-icon {
    display: inline-flex;
}
.lse-save-btn.lse-active .lse-default-icon {
    display: none;
}

/* ── Icon View (Stacked / Framed) ─────────────────────────────────────────── */
.lse-icon-view-stacked,
.lse-icon-view-framed {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
    box-sizing: border-box;
}

.lse-icon-view-stacked img,
.lse-icon-view-framed img {
    width: 1em;
    height: 1em;
    object-fit: contain;
}

.lse-icon-shape-circle {
    border-radius: 50%;
}

.lse-icon-shape-square {
    border-radius: 0;
}

/* ── Counter ──────────────────────────────────────────────────────────────── */
.lse-count {
    display: inline-block;
    margin-left: 5px;
    font-variant-numeric: tabular-nums;
    min-width: 1ch;
    text-align: center;
}

/* ── Loading Spinner ──────────────────────────────────────────────────────── */
.lse-loader {
    display: none;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: lse-spin 0.65s linear infinite;
    margin-left: 6px;
    flex-shrink: 0;
    vertical-align: middle;
}

.lse-loading .lse-loader {
    display: inline-block;
}

.lse-loading .lse-label,
.lse-loading .lse-icon {
    opacity: 0.5;
}

@keyframes lse-spin {
    to { transform: rotate(360deg); }
}

/* ── Flash Messages ───────────────────────────────────────────────────────── */
.lse-flash-msg {
    display: block;
    font-size: 12px;
    margin-top: 4px;
    padding: 2px 6px;
    border-radius: 3px;
    animation: lse-fadein 0.25s ease;
}

.lse-flash-error {
    color: #c0392b;
    background: rgba(192, 57, 43, 0.08);
}

.lse-flash-info {
    color: #2980b9;
    background: rgba(41, 128, 185, 0.08);
}

@keyframes lse-fadein {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ── Toggle Animations ────────────────────────────────────────────────────── */

/* Heart Pop */
.lse-anim-pop {
    animation: lse-pop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes lse-pop {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.25); }
    75%  { transform: scale(0.9); }
    100% { transform: scale(1); }
}

/* Bookmark Slide */
.lse-anim-slide .lse-icon {
    animation: lse-slide 0.4s ease;
}

@keyframes lse-slide {
    0%   { transform: translateY(0); }
    40%  { transform: translateY(-6px); }
    70%  { transform: translateY(2px); }
    100% { transform: translateY(0); }
}

/* Shake */
.lse-anim-shake {
    animation: lse-shake 0.5s ease;
}

@keyframes lse-shake {
    0%, 100% { transform: translateX(0); }
    20%      { transform: translateX(-5px); }
    40%      { transform: translateX(5px); }
    60%      { transform: translateX(-4px); }
    80%      { transform: translateX(4px); }
}

/* Bounce */
.lse-anim-bounce {
    animation: lse-bounce 0.5s ease;
}

@keyframes lse-bounce {
    0%, 100% { transform: translateY(0); }
    40%      { transform: translateY(-8px); }
    70%      { transform: translateY(3px); }
}

/* ── Guest Disabled Button ────────────────────────────────────────────────── */
.lse-guest-disabled {
    cursor: not-allowed;
    opacity: 0.55;
}

/* ── Elementor Editor Notice ──────────────────────────────────────────────── */
.lse-editor-notice {
    padding: 10px 14px;
    background: #fff8e1;
    border-left: 3px solid #f9a825;
    color: #795548;
    font-size: 13px;
    border-radius: 3px;
}

/* ── Posts Grid ───────────────────────────────────────────────────────────── */
.lse-posts-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* overridden by responsive control */
    column-gap: 24px;
    row-gap: 24px;
}

/* ── Post Card ────────────────────────────────────────────────────────────── */
.lse-post-card {
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid #eaeaea;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.lse-post-card:hover {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

/* Card removing animation */
.lse-card-removing {
    animation: lse-card-out 0.4s ease forwards;
}

@keyframes lse-card-out {
    to {
        opacity: 0;
        transform: scale(0.9);
        max-height: 0;
        margin: 0;
        padding: 0;
        border-width: 0;
    }
}

/* ── Card: Image ──────────────────────────────────────────────────────────── */
.lse-post-card__image {
    overflow: hidden;
    flex-shrink: 0;
}

.lse-post-card__image img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
    transition: transform 0.35s ease;
}

.lse-post-card:hover .lse-post-card__image img {
    transform: scale(1.04);
}

/* Placeholder image (Elementor editor) */
.lse-placeholder-image {
    height: 180px;
    background: linear-gradient(135deg, #e0e0e0 25%, #f5f5f5 100%);
}

/* ── Card: Body ───────────────────────────────────────────────────────────── */
.lse-post-card__body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

/* ── Card: Type badge ─────────────────────────────────────────────────────── */
.lse-post-card__type-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 2px 8px;
    border-radius: 30px;
    background: #f0f0f0;
    color: #555;
    align-self: flex-start;
}

/* ── Card: Title ──────────────────────────────────────────────────────────── */
.lse-post-card__title {
    margin: 0;
    font-size: 17px;
    font-weight: 600;
    line-height: 1.35;
}

.lse-post-card__title a {
    color: inherit;
    text-decoration: none;
    transition: color 0.2s ease;
}

.lse-post-card__title a:hover {
    color: #0073aa;
}

/* ── Card: Meta row ───────────────────────────────────────────────────────── */
.lse-post-card__meta {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 13px;
    color: #888;
}

.lse-post-card__likes {
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

/* ── Card: Excerpt ────────────────────────────────────────────────────────── */
.lse-post-card__excerpt {
    margin: 0;
    font-size: 14px;
    color: #666;
    line-height: 1.55;
}

/* ── Card action buttons (Unlike / Unsave) ────────────────────────────────── */
.lse-card-action-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    font-size: 12px;
    border-radius: 30px;
    border: 1px solid #ddd;
    background: transparent;
    color: #888;
    cursor: pointer;
    align-self: flex-start;
    margin-top: auto;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.lse-card-action-btn:hover {
    background: #fff0f0;
    color: #c0392b;
    border-color: #c0392b;
}

.lse-unsave-btn:hover {
    background: #f0f0ff;
    color: #2c3e50;
    border-color: #2c3e50;
}

/* ── Status messages ──────────────────────────────────────────────────────── */
.lse-message {
    padding: 14px 18px;
    border-radius: 6px;
    font-size: 15px;
}

.lse-login-required {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    color: #6c757d;
}

.lse-empty {
    background: #f8f9fa;
    border: 1px dashed #ced4da;
    color: #6c757d;
    text-align: center;
    padding: 32px;
}

/* ── Load More button ─────────────────────────────────────────────────────── */
.lse-load-more-wrap {
    display: flex;
    justify-content: center;
    margin-top: 32px;
}

.lse-load-more-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 28px;
    border: 1px solid #ddd;
    border-radius: 30px;
    background: #fff;
    color: inherit;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.lse-load-more-btn:hover {
    background: #f5f5f5;
    border-color: #999;
}

.lse-load-more-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.lse-load-more-btn.lse-loading::after {
    content: '';
    display: inline-block;
    width: 13px;
    height: 13px;
    border: 2px solid rgba(0, 0, 0, 0.15);
    border-top-color: currentColor;
    border-radius: 50%;
    animation: lse-spin 0.65s linear infinite;
}

/* ── Numbered Pagination ──────────────────────────────────────────────────── */
.lse-pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
    padding: 0;
    margin: 28px 0 0;
    list-style: none;
}

.lse-pagination .page-numbers {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    text-decoration: none;
    color: inherit;
    font-size: 14px;
    transition: background 0.2s, border-color 0.2s;
}

.lse-pagination .page-numbers:hover,
.lse-pagination .page-numbers.current {
    background: #0073aa;
    border-color: #0073aa;
    color: #fff;
}

/* ── Responsive ───────────────────────────────────────────────────────────── */
@media (max-width: 1024px) {
    .lse-posts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 767px) {
    .lse-posts-grid {
        grid-template-columns: 1fr;
    }

    .lse-like-btn,
    .lse-save-btn {
        width: 100%;
        justify-content: center;
    }
}

/* ── Counter Widgets (My Counter / Site Totals) ──────────────────────────── */
.lse-counter-widget {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 32px;
}

.lse-counter-widget.lse-counter-layout-column {
    flex-direction: column;
    align-items: flex-start;
}

.lse-counter-item {
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.2;
}

.lse-counter-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    line-height: 1;
}

.lse-counter-icon img {
    width: 1em;
    height: 1em;
    object-fit: contain;
}

.lse-counter-text {
    display: flex;
    flex-direction: column;
}

.lse-counter-value {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.2;
}

.lse-counter-label {
    font-size: 13px;
    opacity: 0.75;
}

/* ── Print ────────────────────────────────────────────────────────────────── */
@media print {
    .lse-like-btn,
    .lse-save-btn,
    .lse-card-action-btn,
    .lse-load-more-btn,
    .lse-loader {
        display: none !important;
    }
}
