/* ═══════════════════════════════════════════════════════════════════
   Audio Player MP3 — Music Browser Widget
   [apm_search] shortcode styles
   ═══════════════════════════════════════════════════════════════════ */

/* ── Root variables (shared by .apm-gsearch and .apm-gposts) ───── */
.apm-gsearch,
.apm-gposts {
    --gs-bg      : #16162a;
    --gs-surface : #1e1e36;
    --gs-border  : rgba(255,255,255,0.10);
    --gs-primary : #7c3aed;
    --gs-accent  : #06d6a0;
    --gs-text    : #e2e8f0;
    --gs-muted   : #94a3b8;
    --gs-dim     : #64748b;
    --gs-glow    : rgba(124,58,237,0.30);
    --gs-radius  : 12px;
    --gs-shadow  : 0 8px 32px rgba(0,0,0,0.45);

    width: 100%;
    max-width: 860px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Top bar: search wrap + sort buttons ────────────────────────── */
.apm-gsearch-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* ── Search input row ───────────────────────────────────────────── */
.apm-gsearch-wrap {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--gs-bg);
    border: 1px solid var(--gs-border);
    border-radius: var(--gs-radius);
    padding: 0 14px;
    height: 52px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.apm-gsearch-wrap:focus-within {
    border-color: var(--gs-primary);
    box-shadow: 0 0 0 3px var(--gs-glow);
}

/* Search icon */
.apm-gsearch-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--gs-dim);
    pointer-events: none;
    transition: color 0.2s;
}

.apm-gsearch-wrap:focus-within .apm-gsearch-icon {
    color: var(--gs-primary);
}

/* Text input */
.apm-gsearch-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    color: var(--gs-text);
    font-size: 15px;
    padding: 0;
    outline: none;
    -webkit-appearance: none;
    appearance: none;
}

.apm-gsearch-input::placeholder {
    color: var(--gs-dim);
}

.apm-gsearch-input::-webkit-search-cancel-button,
.apm-gsearch-input::-webkit-search-decoration { display: none; }

/* Spinner */
.apm-gsearch-spinner {
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    border: 2px solid var(--gs-border);
    border-top-color: var(--gs-primary);
    border-radius: 50%;
    animation: apm-gs-spin 0.7s linear infinite;
}

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

/* Clear button */
.apm-gsearch-clear {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    background: var(--gs-surface);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: var(--gs-muted);
    padding: 0;
    transition: background 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.apm-gsearch-clear svg {
    width: 14px;
    height: 14px;
    pointer-events: none;
}

.apm-gsearch-clear:hover {
    background: var(--gs-primary);
    color: #fff;
}

/* ── Sort buttons ───────────────────────────────────────────────── */
.apm-gsearch-sort {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}

.apm-gsearch-sort-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    height: 52px;
    padding: 0 16px;
    background: var(--gs-bg);
    border: 1px solid var(--gs-border);
    border-radius: var(--gs-radius);
    color: var(--gs-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.apm-gsearch-sort-btn:hover {
    border-color: var(--gs-primary);
    color: var(--gs-text);
}

.apm-gsearch-sort-btn--active {
    background: rgba(124,58,237,0.15);
    border-color: var(--gs-primary);
    color: #a78bfa;
}

/* ── Status bar: count ──────────────────────────────────────────── */
.apm-gsearch-statusbar {
    display: flex;
    align-items: center;
    padding: 10px 4px 6px;
    min-height: 34px;
}

.apm-gsearch-count {
    font-size: 12px;
    color: var(--gs-muted);
    font-variant-numeric: tabular-nums;
}

/* ── Results list (inline, not a dropdown) ──────────────────────── */
.apm-gsearch-results {
    background: var(--gs-bg);
    border: 1px solid var(--gs-border);
    border-radius: var(--gs-radius);
    overflow: hidden;
    min-height: 64px;
}

/* ── Result item ────────────────────────────────────────────────── */
.apm-gsearch-result {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    text-decoration: none;
    color: var(--gs-text);
    border-bottom: 1px solid var(--gs-border);
    transition: background 0.12s;
    cursor: pointer;
}

.apm-gsearch-result:last-child {
    border-bottom: none;
}

.apm-gsearch-result:hover {
    background: rgba(124, 58, 237, 0.12);
}

.apm-gsearch-result--no-page {
    opacity: 0.55;
    cursor: default;
    pointer-events: none;
}

/* Artwork */
.apm-gsearch-art {
    flex-shrink: 0;
    width: 46px;
    height: 46px;
    border-radius: 6px;
    overflow: hidden;
    background: var(--gs-surface);
    display: flex;
    align-items: center;
    justify-content: center;
}

.apm-gsearch-art-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.apm-gsearch-art-ph {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    color: var(--gs-dim);
}

.apm-gsearch-art-ph svg {
    width: 20px;
    height: 20px;
}

/* Text info block */
.apm-gsearch-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.apm-gsearch-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--gs-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.apm-gsearch-result:hover .apm-gsearch-title {
    color: #fff;
}

.apm-gsearch-meta {
    font-size: 12px;
    color: var(--gs-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
}

.apm-gsearch-playlist {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: var(--gs-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Right column: genre + plays */
.apm-gsearch-right {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}

.apm-gsearch-genre {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    padding: 2px 8px;
    border-radius: 20px;
    white-space: nowrap;
    background: rgba(124, 58, 237, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(124, 58, 237, 0.25);
}

/* Per-genre colours */
.apm-gsearch-genre[data-genre="hiragasy"],
.apm-gsearch-genre[data-genre="vakodrazana"],
.apm-gsearch-genre[data-genre="bagasy"],
.apm-gsearch-genre[data-genre="kalony"]    { background:rgba(217,119,6,0.12); color:#fbbf24; border-color:rgba(217,119,6,0.25); }

.apm-gsearch-genre[data-genre="salegy"],
.apm-gsearch-genre[data-genre="tsapiky"]   { background:rgba(6,214,160,0.12); color:#06d6a0; border-color:rgba(6,214,160,0.25); }

.apm-gsearch-genre[data-genre="beko"],
.apm-gsearch-genre[data-genre="malesa"],
.apm-gsearch-genre[data-genre="basesa"]    { background:rgba(99,102,241,0.12); color:#818cf8; border-color:rgba(99,102,241,0.25); }

.apm-gsearch-genre[data-genre="gospel"]    { background:rgba(147,51,234,0.12); color:#c084fc; border-color:rgba(147,51,234,0.25); }
.apm-gsearch-genre[data-genre="jazz"]      { background:rgba(234,179,8,0.12);  color:#facc15; border-color:rgba(234,179,8,0.25);  }
.apm-gsearch-genre[data-genre="rap"]       { background:rgba(249,115,22,0.12); color:#fb923c; border-color:rgba(249,115,22,0.25); }
.apm-gsearch-genre[data-genre="rock"]      { background:rgba(239,68,68,0.12);  color:#f87171; border-color:rgba(239,68,68,0.25);  }
.apm-gsearch-genre[data-genre="reggae"]    { background:rgba(34,197,94,0.12);  color:#4ade80; border-color:rgba(34,197,94,0.25);  }
.apm-gsearch-genre[data-genre="pop"]       { background:rgba(236,72,153,0.12); color:#f472b6; border-color:rgba(236,72,153,0.25); }
.apm-gsearch-genre[data-genre="variete"]   { background:rgba(14,165,233,0.12); color:#38bdf8; border-color:rgba(14,165,233,0.25); }

.apm-gsearch-plays {
    font-size: 10px;
    color: var(--gs-dim);
    white-space: nowrap;
}

/* ── Empty / no results ─────────────────────────────────────────── */
.apm-gsearch-empty {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 24px 16px;
    font-size: 13px;
    color: var(--gs-muted);
}

.apm-gsearch-empty strong {
    color: var(--gs-text);
}

/* ── Pagination ─────────────────────────────────────────────────── */
.apm-gsearch-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 14px 0 2px;
    flex-wrap: wrap;
}

.apm-gsearch-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    background: var(--gs-bg);
    border: 1px solid var(--gs-border);
    border-radius: 8px;
    color: var(--gs-muted);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.apm-gsearch-page-btn:hover:not([disabled]) {
    border-color: var(--gs-primary);
    color: var(--gs-text);
}

.apm-gsearch-page-btn--active {
    background: var(--gs-primary);
    border-color: var(--gs-primary);
    color: #fff;
    font-weight: 600;
    cursor: default;
}

.apm-gsearch-page-btn[disabled] {
    opacity: 0.30;
    cursor: default;
}

.apm-gsearch-page-first,
.apm-gsearch-page-prev,
.apm-gsearch-page-next,
.apm-gsearch-page-last {
    font-size: 20px;
    line-height: 1;
    min-width: 36px;
}

.apm-gsearch-page-ellipsis {
    color: var(--gs-dim);
    font-size: 13px;
    padding: 0 4px;
    line-height: 36px;
    user-select: none;
}

/* ═══════════════════════════════════════════════════════════════════
   Post browser — [apm_posts] specific styles
   ═══════════════════════════════════════════════════════════════════ */

/* Post item: slightly taller to accommodate excerpt */
.apm-gpost-result {
    align-items: flex-start;
    padding: 12px 14px;
}

.apm-gpost-result .apm-gsearch-art {
    margin-top: 2px;
    width: 54px;
    height: 54px;
    border-radius: 8px;
}

/* Excerpt */
.apm-gpost-excerpt {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 12px;
    color: var(--gs-muted);
    line-height: 1.5;
    margin-top: 1px;
}

/* Category tags */
.apm-gpost-cats {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.apm-gpost-cat {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    color: var(--gs-dim);
    background: var(--gs-surface);
    border: 1px solid var(--gs-border);
    border-radius: 20px;
    padding: 1px 7px;
    white-space: nowrap;
}

/* Date */
.apm-gpost-date {
    font-size: 11px;
    color: var(--gs-dim);
    white-space: nowrap;
    margin-top: 4px;
}

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .apm-gsearch-topbar    { flex-wrap: wrap; }
    .apm-gsearch-sort      { width: 100%; }
    .apm-gsearch-sort-btn  { flex: 1; justify-content: center; height: 44px; font-size: 12px; }
    .apm-gsearch-wrap      { height: 46px; }
    .apm-gsearch-input     { font-size: 14px; } /* prevent iOS zoom */
    .apm-gsearch-genre     { display: none; }
    .apm-gsearch-plays     { display: none; }
    .apm-gsearch-art       { width: 40px; height: 40px; }
    .apm-gsearch-page-btn  { min-width: 32px; height: 32px; font-size: 12px; }
}
