/* ==========================================================================
   AdHUB — Apple Design System (Light)
   Restyled with Apple-inspired light design language.
   All original selectors preserved for script.js compatibility.
   ========================================================================== */

/* ==========================================================================
   1. RESET & BASE
   ========================================================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* ---- Apple Color System (Light) ---- */
    --primary-color: #0071e3;
    --primary-dark: #0077ed;
    --primary-light: #0071e3;
    --secondary-color: #86868b;
    --accent-color: #0071e3;
    --success-color: #34c759;
    --danger-color: #ff3b30;
    --warning-color: #ff9500;

    /* ---- Background Scale (Apple Light) ---- */
    --bg-color: #ffffff;
    --bg-secondary: #f5f5f7;
    --bg-tertiary: #e8e8ed;
    --bg-card: #ffffff;
    --bg-hover: #f0f0f5;

    /* ---- Text Scale (Apple Light) ---- */
    --text-primary: #1d1d1f;
    --text-secondary: #6e6e73;
    --text-muted: #86868b;

    /* ---- Borders ---- */
    --border-color: rgba(0, 0, 0, 0.08);
    --border-hover: rgba(0, 0, 0, 0.16);

    /* ---- Shadows ---- */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 4px 24px rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 0 0 transparent;

    /* ---- Transitions (Apple: subtle, under 0.4s) ---- */
    --transition: all 0.25s ease;
    --transition-slow: all 0.35s ease;

    /* ---- Spacing Scale (4px base) ---- */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 40px;
    --space-2xl: 60px;
    --space-3xl: 80px;

    /* ---- Layout ---- */
    --max-width: 980px;
    --max-width-wide: 1200px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-xl: 22px;
}


/* ==========================================================================
   2. TYPOGRAPHY & BODY
   ========================================================================== */

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "SF Pro Text", "Helvetica Neue", Helvetica, Arial, sans-serif;
    background: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.47;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-size: 17px;
    letter-spacing: -0.022em;
}

/* Subtle top gradient for Apple-light depth */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(ellipse at 50% 0%, rgba(245, 245, 247, 0.6) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}


/* ==========================================================================
   3. LAYOUT — CONTAINER
   ========================================================================== */

.container {
    max-width: var(--max-width-wide);
    margin: 0 auto;
    padding: 0 22px;
    position: relative;
    z-index: 1;
}


/* ==========================================================================
   4. HEADER — Apple-style frosted glass navigation
   ========================================================================== */

.header {
    background: rgba(255, 255, 255, 0.72);
    backdrop-filter: saturate(180%) blur(20px);
    -webkit-backdrop-filter: saturate(180%) blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 14px 24px;
    position: sticky;
    top: 12px;
    z-index: 1000;
    box-shadow: var(--shadow);
    margin: 12px 0 var(--space-lg);
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.header-left {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.header-right {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex: 1;
    justify-content: flex-end;
}

/* Logo — Apple-clean type treatment */
.logo {
    font-size: 1.5rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

.logo-icon {
    font-size: 1.5rem;
    /* Apple never animates logos — static presence */
    animation: none;
}

/* Version Badge — muted, unobtrusive */
.version-badge {
    padding: 3px 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-muted);
    letter-spacing: 0.02em;
    white-space: nowrap;
}


/* ==========================================================================
   5. LANGUAGE SELECTOR
   ========================================================================== */

.language-selector {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

.language-dropdown {
    position: relative;
}

.language-current {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 8px 14px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 400;
    transition: var(--transition);
    white-space: nowrap;
}

.language-current:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-hover);
}

.language-current .lang-flag {
    font-size: 1.1rem;
}

.language-current .lang-name {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
}

.language-current .lang-arrow {
    font-size: 0.6rem;
    margin-left: 2px;
    transition: var(--transition);
    opacity: 0.5;
    color: var(--text-muted);
}

.language-dropdown.open .lang-arrow {
    transform: rotate(180deg);
}

.language-dropdown-content {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 280px;
    max-height: 400px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: var(--transition);
    z-index: 1000;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.language-dropdown.open .language-dropdown-content {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-search-container {
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.lang-search {
    width: 100%;
    padding: 10px 14px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.85rem;
    transition: var(--transition);
    font-family: inherit;
}

.lang-search:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

.lang-search::placeholder {
    color: var(--text-muted);
}

.lang-list {
    overflow-y: auto;
    flex: 1;
    max-height: 300px;
}

.lang-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    transition: var(--transition);
    border-left: 3px solid transparent;
}

.lang-item:hover {
    background: var(--bg-hover);
}

.lang-item.active {
    background: rgba(0, 113, 227, 0.06);
    border-left-color: var(--primary-color);
}

.lang-item .lang-flag {
    font-size: 1.2rem;
    line-height: 1;
}

.lang-item .lang-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.lang-item .lang-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

.lang-item .lang-native {
    font-size: 0.72rem;
    color: var(--text-secondary);
}

.lang-item .lang-code-badge {
    margin-left: auto;
    padding: 2px 6px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    font-size: 0.65rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
}

/* Lang list scrollbar — minimal */
.lang-list::-webkit-scrollbar {
    width: 4px;
}
.lang-list::-webkit-scrollbar-track {
    background: transparent;
}
.lang-list::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 2px;
}
.lang-list::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}


/* ==========================================================================
   6. TRANSLATION INDICATOR
   ========================================================================== */

.translation-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(0, 113, 227, 0.06);
    border: 1px solid rgba(0, 113, 227, 0.12);
    border-radius: var(--radius-sm);
    font-size: 0.78rem;
    color: var(--primary-color);
}

.translation-spinner {
    animation: subtlePulse 1.5s ease-in-out infinite;
}

.translation-text {
    font-weight: 500;
}

@keyframes subtlePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}


/* ==========================================================================
   7. SEARCH
   ========================================================================== */

.search-container {
    position: relative;
    flex: 1;
    max-width: 100%;
    min-width: 200px;
}

.search-input {
    width: 100%;
    padding: 10px 40px 10px 16px;
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: 0.88rem;
    font-family: inherit;
    transition: var(--transition);
}

.search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(0, 0, 0, 0.02);
    box-shadow: 0 0 0 3px rgba(0, 113, 227, 0.15);
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-icon {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    opacity: 0.4;
    font-size: 1rem;
}


/* ==========================================================================
   8. CONTROLS — Filter Tabs
   ========================================================================== */

.controls {
    margin: var(--space-lg) 0;
    min-height: 50px;
    contain: layout;
}

.filter-tabs {
    display: flex;
    gap: var(--space-sm);
    min-height: 42px;
    contain: layout style;
    flex-wrap: wrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.filter-tabs::-webkit-scrollbar {
    height: 0;
}

.filter-tab {
    padding: 8px 20px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 980px;
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.82rem;
    font-weight: 400;
    transition: var(--transition);
    white-space: nowrap;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-width: 90px;
    min-height: 36px;
    box-sizing: border-box;
    text-align: center;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}

.filter-tab[data-filter="all"] { min-width: 65px; }
.filter-tab[data-filter="tools"] { min-width: 95px; }
.filter-tab[data-filter="links"] { min-width: 95px; }

.filter-tab:active {
    transform: scale(0.97);
}

.filter-tab:hover {
    background: rgba(0, 0, 0, 0.04);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.filter-tab.active {
    background: var(--text-primary);
    border-color: var(--text-primary);
    color: var(--bg-color);
    font-weight: 600;
}

/* Category Filters */
.category-filters {
    display: flex;
    gap: var(--space-sm);
    flex-wrap: wrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 4px;
}

.category-chip {
    padding: 6px 16px;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 980px;
    font-size: 0.78rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
}

.category-chip:active {
    transform: scale(0.95);
}

.category-chip:hover {
    background: rgba(0, 0, 0, 0.04);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

.category-chip.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: #fff;
}


/* ==========================================================================
   9. STATUS BAR
   ========================================================================== */

.status-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-lg);
    border: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: var(--space-sm);
}

.status-text {
    font-size: 0.82rem;
    color: var(--text-secondary);
    flex: 1;
    min-width: 200px;
}

.refresh-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 1rem;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    min-width: 40px;
    min-height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.refresh-btn:active {
    transform: scale(0.95) rotate(180deg);
}

.refresh-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-hover);
    color: var(--text-primary);
}

#startServerBtn {
    background: var(--success-color);
    border: none;
    color: #fff;
    padding: 8px 16px;
    border-radius: 980px;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
}

#startServerBtn:active {
    transform: scale(0.98);
}

#startServerBtn:hover {
    opacity: 0.85;
}


/* ==========================================================================
   10. CONTENT SECTIONS
   ========================================================================== */

.content-section {
    margin-bottom: var(--space-xl);
    min-height: 220px;
    contain: layout style;
}

.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    padding: 14px 20px;
    min-height: 52px;
    height: auto;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    flex-wrap: wrap;
    contain: layout style;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.01em;
}

.section-icon {
    font-size: 1.3rem;
    line-height: 1;
}

.section-badge {
    padding: 5px 14px;
    border-radius: 980px;
    font-size: 0.72rem;
    font-weight: 500;
    white-space: nowrap;
}

/* Tools section — subtle blue accent */
.tools-section .section-header {
    border-left: 3px solid var(--primary-color);
}

.our-tools-badge {
    background: rgba(0, 113, 227, 0.08);
    color: var(--primary-color);
    border: 1px solid rgba(0, 113, 227, 0.15);
}

/* Links section — subtle secondary accent */
.links-section .section-header {
    border-left: 3px solid var(--text-muted);
}

.external-links-badge {
    background: rgba(110, 110, 115, 0.08);
    color: var(--text-secondary);
    border: 1px solid rgba(110, 110, 115, 0.15);
}

.content-section.hidden {
    display: none;
}


/* ==========================================================================
   11. TOOL CARDS — Apple product-card treatment
   ========================================================================== */

.tools-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 320px), 1fr));
    gap: var(--space-md);
    min-height: 180px;
    contain: layout style;
}

.tool-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    padding-bottom: 56px;
    transition: var(--transition-slow);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    contain: layout style paint;
    min-height: 180px;
    height: auto;
    box-sizing: border-box;
}

/* Removed the decorative top gradient bar for Apple cleanliness */
.tool-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: transparent;
    transition: var(--transition);
}

.tool-card:active {
    transform: scale(0.98);
}

.tool-card:hover {
    transform: translateY(-2px);
    border-color: var(--border-hover);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
    background: var(--bg-hover);
}

.tool-card:hover::before {
    background: var(--primary-color);
    height: 2px;
}

.tool-card.server {
    border-left: 2px solid var(--primary-color);
}

.tool-card.link {
    border-left: 2px solid var(--text-muted);
}

.tool-header {
    display: flex;
    flex-direction: column;
    gap: var(--space-sm);
    margin-bottom: 10px;
}

.tool-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tool-icon {
    font-size: 1.5rem;
    line-height: 1;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-icon svg {
    width: 28px;
    height: 28px;
    flex-shrink: 0;
}

.tool-icon .svg-icon {
    width: 28px;
    height: 28px;
}

.tool-name {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.3;
    word-break: break-word;
    letter-spacing: -0.01em;
}

/* Tool Status */
.tool-status {
    padding: 3px 8px;
    border-radius: 980px;
    font-size: 0.62rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    flex-shrink: 0;
    white-space: nowrap;
}

.tool-status.running {
    background: rgba(52, 199, 89, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(52, 199, 89, 0.2);
}

.tool-status.stopped {
    background: rgba(255, 59, 48, 0.08);
    color: var(--danger-color);
    border: 1px solid rgba(255, 59, 48, 0.18);
}

/* Tool Badges */
.tool-badges {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    min-height: 22px;
}

.tool-badge {
    padding: 3px 8px;
    border-radius: 980px;
    font-size: 0.62rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    flex-shrink: 0;
    white-space: nowrap;
    background: rgba(0, 113, 227, 0.08);
    color: var(--primary-color);
    border: 1px solid rgba(0, 113, 227, 0.15);
}

.tool-badge.status-active {
    background: rgba(52, 199, 89, 0.08);
    color: var(--success-color);
    border-color: rgba(52, 199, 89, 0.18);
    text-transform: none;
}

.tool-badge.status-inactive {
    background: rgba(255, 59, 48, 0.08);
    color: var(--danger-color);
    border-color: rgba(255, 59, 48, 0.18);
    text-transform: none;
}

.tool-badge.view-count-badge {
    background: rgba(0, 113, 227, 0.06);
    color: var(--accent-color);
    border: 1px solid rgba(0, 113, 227, 0.12);
    display: flex;
    align-items: center;
    gap: 3px;
    font-size: 0.62rem;
    font-weight: 500;
    text-transform: none;
    transition: var(--transition);
    cursor: default;
}

.tool-badge.view-count-badge:hover {
    background: rgba(0, 113, 227, 0.1);
}

/* Description */
.tool-description {
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: var(--space-md);
    line-height: 1.47;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Meta */
.tool-meta {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    flex-wrap: wrap;
}

.tool-category {
    padding: 3px 8px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: capitalize;
    font-weight: 500;
}

.tool-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.tool-tag {
    padding: 2px 7px;
    background: rgba(0, 0, 0, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.62rem;
    color: var(--text-muted);
    font-weight: 500;
    transition: var(--transition);
}

.tool-tag:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-secondary);
}

/* Offline Notice */
.offline-notice {
    padding: 8px 10px;
    background: rgba(255, 149, 0, 0.08);
    border: 1px solid rgba(255, 149, 0, 0.18);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    color: var(--warning-color);
    margin-bottom: 10px;
    text-align: center;
    font-weight: 500;
}

/* Tool Actions */
.tool-actions {
    position: absolute;
    bottom: 14px;
    right: 14px;
}

.btn-open {
    width: 36px;
    height: 36px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn-open:hover {
    background: rgba(0, 113, 227, 0.1);
    color: var(--primary-color);
}

.btn-open:active {
    transform: scale(0.92);
}

.tool-card:hover .btn-open {
    background: rgba(0, 113, 227, 0.1);
    color: var(--primary-color);
}

.tool-card.link .btn-open:hover {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-primary);
}

.tool-card.link:hover .btn-open {
    background: rgba(0, 0, 0, 0.06);
    color: var(--text-primary);
}


/* ==========================================================================
   12. BUTTONS — Apple style (understated, confident)
   ========================================================================== */

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 980px;
    font-size: 0.82rem;
    font-weight: 400;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    font-family: inherit;
}

.btn:active {
    transform: scale(0.97);
}

.btn-primary {
    background: var(--primary-color);
    color: #fff;
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-secondary {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-hover);
}

.btn-danger {
    background: rgba(255, 59, 48, 0.08);
    color: var(--danger-color);
    border: 1px solid rgba(255, 59, 48, 0.18);
}

.btn-danger:hover {
    background: var(--danger-color);
    color: #fff;
}

.btn-success {
    background: rgba(52, 199, 89, 0.08);
    color: var(--success-color);
    border: 1px solid rgba(52, 199, 89, 0.18);
}

.btn-success:hover {
    background: var(--success-color);
    color: #fff;
}

.btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
}


/* ==========================================================================
   13. EMPTY STATE
   ========================================================================== */

.empty-state {
    text-align: center;
    padding: var(--space-3xl) var(--space-lg);
}

.empty-icon {
    font-size: 3.5rem;
    margin-bottom: var(--space-lg);
    opacity: 0.3;
    filter: grayscale(1);
}

.empty-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: var(--space-sm);
    letter-spacing: -0.01em;
}

.empty-subtext {
    color: var(--text-secondary);
    font-size: 0.95rem;
}


/* ==========================================================================
   14. LOADING
   ========================================================================== */

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

.loading {
    display: inline-block;
    animation: spin 1s linear infinite;
}


/* ==========================================================================
   15. FOOTER — Apple-minimal
   ========================================================================== */

.footer {
    margin: var(--space-xl) 0 var(--space-md);
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    border-radius: 0;
    background: transparent;
    border-left: none;
    border-right: none;
    border-bottom: none;
}

.footer-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--space-md);
}

.footer-text {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.footer-version {
    font-size: 0.72rem;
    color: var(--text-muted);
    padding: 0;
    background: transparent;
    border-radius: 0;
}


/* ==========================================================================
   16. IDEA BUTTON
   ========================================================================== */

.idea-button {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 8px 16px;
    background: var(--primary-color);
    border: none;
    border-radius: 980px;
    color: #fff;
    font-weight: 400;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
    font-family: inherit;
}

.idea-button:hover {
    background: var(--primary-dark);
}

.idea-button:active {
    transform: scale(0.97);
}

.idea-icon {
    font-size: 1rem;
    /* No animation — Apple-restrained */
    animation: none;
}

.idea-text {
    font-weight: 400;
}

/* Re-define pulse for backwards compat with anything that references it */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}


/* ==========================================================================
   17. MODAL — Apple sheet style
   ========================================================================== */

.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.active {
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 1;
    animation: appleModalFadeIn 0.3s ease;
}

@keyframes appleModalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Keep legacy animation name for any JS references */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    width: 90%;
    max-width: 440px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    animation: appleModalSlideUp 0.35s ease;
}

@keyframes appleModalSlideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Keep legacy animation name */
@keyframes slideUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.01em;
}

.modal-close {
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
    line-height: 1;
}

.modal-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(90vh - 80px);
}

.modal-description {
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: var(--space-lg);
    text-align: center;
    font-size: 0.88rem;
}

.discord-embed-container {
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--bg-secondary);
}

.discord-embed-container iframe {
    display: block;
    border: none;
    min-height: 500px;
}

.discord-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
}

.discord-loading {
    color: var(--text-muted);
    font-size: 0.85rem;
}


/* ==========================================================================
   18. PLUGIN UPDATE BANNER
   ========================================================================== */

.plugin-update-banner {
    background: rgba(255, 149, 0, 0.06);
    border: 1px solid rgba(255, 149, 0, 0.15);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin: var(--space-md) 0;
    animation: appleSlideDown 0.3s ease;
}

@keyframes appleSlideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Keep legacy name */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.plugin-update-content {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    flex-wrap: wrap;
}

.plugin-update-icon {
    font-size: 1.3rem;
}

.plugin-update-text {
    flex: 1;
    min-width: 200px;
}

.plugin-update-text strong {
    display: block;
    color: var(--warning-color);
    font-weight: 600;
    margin-bottom: 4px;
    font-size: 0.88rem;
}

.plugin-update-text span {
    color: var(--text-secondary);
    font-size: 0.82rem;
}

.plugin-update-text code {
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: "SF Mono", "Menlo", "Monaco", "Consolas", monospace;
    font-size: 0.82em;
    color: var(--primary-color);
}

.btn-update-plugin {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 18px;
    background: var(--warning-color);
    color: #fff;
    font-weight: 600;
    text-decoration: none;
    border-radius: 980px;
    transition: var(--transition);
    white-space: nowrap;
    font-size: 0.82rem;
    font-family: inherit;
}

.btn-update-plugin:hover {
    opacity: 0.85;
}

.plugin-update-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.3rem;
    cursor: pointer;
    padding: 4px 8px;
    line-height: 1;
    border-radius: 4px;
    transition: var(--transition);
}

.plugin-update-close:hover {
    color: var(--text-primary);
}


/* ==========================================================================
   19. TOP CLICKED CARDS
   ========================================================================== */

.tool-card.top-clicked {
    background: var(--bg-card);
    border-color: rgba(255, 59, 48, 0.15);
}

.tool-card.top-clicked:hover {
    background: var(--bg-hover);
    border-color: rgba(255, 59, 48, 0.3);
}

.tool-card.top-clicked::before {
    background: var(--danger-color);
    height: 2px;
    transform: scaleX(1);
}

.tool-badge.top-badge {
    background: rgba(255, 59, 48, 0.08);
    border: 1px solid rgba(255, 59, 48, 0.18);
    color: var(--danger-color);
    /* Apple: no pulsing badges — static, confident */
    animation: none;
}

/* Remove the legacy topBadgePulse — keep selector for compat */
@keyframes topBadgePulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 1; }
}


/* ==========================================================================
   20. SKELETON LOADING (from inline styles — kept for CLS prevention)
   ========================================================================== */

@keyframes skeleton-pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 0.3; }
}

.skeleton {
    background: var(--bg-secondary);
    animation: skeleton-pulse 1.8s ease-in-out infinite;
    border-radius: var(--radius-lg);
}

.skeleton-card {
    height: 180px;
    min-height: 180px;
    contain: layout style paint;
}

.skeleton-text {
    height: 16px;
    margin: 8px 0;
    width: 80%;
}

.skeleton-text.short { width: 40%; }

.tools-grid.loading {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: var(--space-md);
}


/* ==========================================================================
   21. LOAD MORE
   ========================================================================== */

.load-more-container {
    display: flex;
    justify-content: center;
    padding: var(--space-lg) 0;
}

.load-more-btn {
    background: var(--primary-color);
    color: #fff;
    border: none;
    padding: 10px 28px;
    border-radius: 980px;
    font-size: 0.85rem;
    font-weight: 400;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    font-family: inherit;
}

.load-more-btn:hover {
    background: var(--primary-dark);
}

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

.load-more-btn .spinner {
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.items-counter {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.72rem;
    margin-top: var(--space-sm);
}


/* ==========================================================================
   22. SCROLLBAR — Minimal
   ========================================================================== */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}


/* ==========================================================================
   23. RESPONSIVE — Tablet (max 1068px)
   ========================================================================== */

@media (max-width: 1068px) {
    .container {
        padding: 0 var(--space-md);
    }

    .tools-grid {
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
    }
}


/* ==========================================================================
   24. RESPONSIVE — Mobile (max 734px)
   ========================================================================== */

@media (max-width: 734px) {
    body {
        padding-bottom: env(safe-area-inset-bottom);
        font-size: 16px;
    }

    .container {
        padding: 0 var(--space-md);
    }

    .header {
        padding: 12px 16px;
        margin: 8px 0 var(--space-md);
        top: 8px;
        border-radius: var(--radius-md);
    }

    .header-content {
        flex-direction: column;
        align-items: stretch;
        gap: var(--space-md);
    }

    .header-left {
        justify-content: center;
        flex-wrap: wrap;
    }

    .header-right {
        flex-direction: column;
        gap: var(--space-md);
    }

    .language-selector {
        width: 100%;
        justify-content: center;
        flex-direction: column;
    }

    .language-dropdown {
        width: 100%;
    }

    .language-current {
        width: 100%;
        justify-content: center;
    }

    .language-current .lang-name {
        max-width: none;
    }

    .language-dropdown-content {
        width: 100%;
        left: 0;
        right: 0;
    }

    .translation-indicator {
        width: 100%;
        justify-content: center;
    }

    .version-badge {
        font-size: 0.65rem;
    }

    .logo {
        font-size: 1.35rem;
    }

    .logo-icon {
        font-size: 1.35rem;
    }

    .search-container {
        max-width: 100%;
    }

    .search-input {
        padding: 12px 40px 12px 16px;
        font-size: 16px; /* Prevents iOS zoom */
    }

    .controls {
        margin: var(--space-md) 0;
    }

    .filter-tabs {
        gap: 6px;
        margin-bottom: var(--space-md);
    }

    .filter-tab {
        padding: 8px 16px;
        font-size: 0.82rem;
    }

    .category-filters {
        gap: 6px;
    }

    .category-chip {
        padding: 6px 12px;
        font-size: 0.72rem;
    }

    .status-bar {
        padding: 10px 12px;
        flex-direction: column;
        align-items: stretch;
    }

    .status-text {
        font-size: 0.78rem;
        min-width: auto;
    }

    .refresh-btn,
    #startServerBtn {
        width: 100%;
        justify-content: center;
    }

    .tools-grid {
        grid-template-columns: 1fr;
        gap: var(--space-md);
    }

    .section-header {
        padding: 12px 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .section-title {
        font-size: 1rem;
    }

    .section-icon {
        font-size: 1.2rem;
    }

    .section-badge {
        font-size: 0.68rem;
        padding: 4px 12px;
    }

    .tool-card {
        padding: 16px;
        padding-bottom: 52px;
        border-radius: var(--radius-md);
    }

    .tool-name {
        font-size: 0.9rem;
    }

    .tool-icon {
        font-size: 1.4rem;
    }

    .tool-description {
        font-size: 0.78rem;
    }

    .btn-open {
        width: 40px;
        height: 40px;
    }

    .empty-state {
        padding: var(--space-xl) var(--space-lg);
    }

    .empty-icon {
        font-size: 3rem;
    }

    .empty-text {
        font-size: 1.1rem;
    }

    .empty-subtext {
        font-size: 0.85rem;
    }

    .footer-content {
        flex-direction: column;
        text-align: center;
    }

    /* Modal adjustments */
    .modal-content {
        width: 95%;
        max-width: none;
        border-radius: var(--radius-lg);
    }

    .modal-header {
        padding: 16px 20px;
    }

    .modal-title {
        font-size: 1.1rem;
    }

    .modal-body {
        padding: 20px;
    }

    .discord-embed-container iframe {
        min-height: 400px;
    }

    .idea-text {
        display: none;
    }

    .idea-button {
        padding: 8px 14px;
    }
}


/* ==========================================================================
   25. RESPONSIVE — Small phones (max 480px)
   ========================================================================== */

@media (max-width: 480px) {
    .container {
        padding: 0 var(--space-sm);
    }

    .header {
        padding: 10px 12px;
        border-radius: var(--radius-sm);
    }

    .footer {
        padding: 14px 16px;
    }

    .logo {
        font-size: 1.2rem;
    }

    .filter-tab {
        padding: 8px 12px;
        font-size: 0.78rem;
    }

    .tool-card {
        padding: 14px;
    }

    .tool-name {
        font-size: 0.85rem;
    }

    .tool-icon {
        font-size: 1.3rem;
    }

    .tool-description {
        font-size: 0.72rem;
    }

    .tool-tag {
        font-size: 0.58rem;
        padding: 2px 6px;
    }

    .idea-button {
        padding: 8px 12px;
    }

    .idea-icon {
        font-size: 0.95rem;
    }

    .plugin-update-content {
        flex-direction: column;
        align-items: flex-start;
    }

    .plugin-update-close {
        position: absolute;
        top: 8px;
        right: 8px;
    }

    .plugin-update-banner {
        position: relative;
    }
}


/* ==========================================================================
   26. TOUCH DEVICE OVERRIDES
   ========================================================================== */

@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
    }

    .filter-tab,
    .category-chip {
        min-height: 40px;
    }

    .refresh-btn {
        min-width: 44px;
        min-height: 44px;
    }
}


/* ==========================================================================
   27. REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}


/* ==========================================================================
   28. DARK MODE (placeholder for system preference)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    :root {
        /* Light-first design — no dark overrides */
    }
}
