/* =========================================
   Tampermonkey Script Overview — Styles
   ========================================= */

/* --- Reset & Base --- */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Color Palette — Deep dark with vibrant accents */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: rgba(22, 22, 35, 0.7);
    --bg-card-hover: rgba(30, 30, 48, 0.85);
    --bg-glass: rgba(255, 255, 255, 0.03);

    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-card: rgba(255, 255, 255, 0.08);
    --border-hover: rgba(255, 255, 255, 0.14);

    --text-primary: #e8e8ef;
    --text-secondary: #8a8a9a;
    --text-muted: #55556a;

    --accent-primary: #7c6aed;
    --accent-primary-rgb: 124, 106, 237;
    --accent-glow: rgba(124, 106, 237, 0.25);
    --accent-secondary: #4ecdc4;
    --accent-secondary-rgb: 78, 205, 196;
    --accent-warning: #f7b731;
    --accent-error: #fc5c65;
    --accent-success: #26de81;

    --gradient-primary: linear-gradient(135deg, #7c6aed 0%, #4ecdc4 100%);
    --gradient-card: linear-gradient(145deg, rgba(124, 106, 237, 0.08) 0%, rgba(78, 205, 196, 0.04) 100%);
    --gradient-shimmer: linear-gradient(90deg, transparent, rgba(255,255,255,0.04), transparent);

    --radius-sm: 8px;
    --radius-md: 14px;
    --radius-lg: 20px;
    --radius-xl: 28px;

    --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.3), 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-card-hover: 0 12px 40px rgba(0, 0, 0, 0.5), 0 4px 12px rgba(124, 106, 237, 0.15);
    --shadow-glow: 0 0 30px rgba(124, 106, 237, 0.2);

    --transition-fast: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-smooth: 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* --- Animated Background Orbs --- */
.bg-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.3;
    pointer-events: none;
    z-index: 0;
    animation: orbFloat 20s ease-in-out infinite;
}

.bg-orb-1 {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(124, 106, 237, 0.4), transparent 70%);
    top: -100px;
    left: -100px;
    animation-delay: 0s;
}

.bg-orb-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(78, 205, 196, 0.3), transparent 70%);
    bottom: -80px;
    right: -80px;
    animation-delay: -7s;
    animation-duration: 25s;
}

.bg-orb-3 {
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(247, 183, 49, 0.2), transparent 70%);
    top: 40%;
    left: 50%;
    animation-delay: -14s;
    animation-duration: 30s;
}

@keyframes orbFloat {
    0%, 100% { transform: translate(0, 0) scale(1); }
    25% { transform: translate(40px, -30px) scale(1.05); }
    50% { transform: translate(-20px, 40px) scale(0.95); }
    75% { transform: translate(30px, 20px) scale(1.02); }
}

/* --- Container --- */
.container {
    position: relative;
    z-index: 1;
    max-width: 1000px;
    margin: 0 auto;
    padding: 40px 24px 60px;
}

/* --- Language Toggle --- */
.lang-toggle-wrapper {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 16px;
    animation: fadeInUp 0.5s ease-out;
}

.lang-toggle {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: 50px;
    padding: 0;
    cursor: pointer;
    overflow: hidden;
    backdrop-filter: blur(12px);
    transition: border-color var(--transition-fast);
}

.lang-toggle:hover {
    border-color: var(--border-hover);
}

.lang-option {
    position: relative;
    z-index: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 32px;
    font-family: 'Inter', sans-serif;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    transition: color var(--transition-smooth);
    user-select: none;
}

.lang-option.active {
    color: white;
}

.lang-slider {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 42px;
    height: 26px;
    background: var(--gradient-primary);
    border-radius: 50px;
    transition: transform var(--transition-spring);
    box-shadow: 0 2px 8px rgba(var(--accent-primary-rgb), 0.3);
}

/* --- Header --- */
.header {
    text-align: center;
    margin-bottom: 40px;
    animation: fadeInUp 0.7s ease-out;
}

.header-image {
    max-width: 100%;
    height: auto;
    margin-bottom: 20px;
    border-radius: var(--radius-md);
}

@keyframes iconPulse {
    0%, 100% { box-shadow: 0 0 20px rgba(124, 106, 237, 0.3); }
    50% { box-shadow: 0 0 40px rgba(124, 106, 237, 0.5), 0 0 60px rgba(78, 205, 196, 0.2); }
}

.brand-title {
    display: flex;
    align-items: center;
    gap: 0.4em;
    line-height: 1.2;
}

.brand-title img {
    flex-shrink: 0;
}

.header h1 {
    justify-content: center;
    font-size: 2.4rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
}

.header-subtitle {
    font-size: 1.05rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin-bottom: 28px;
}

/* --- Stats Bar --- */
.header-stats {
    display: inline-flex;
    align-items: center;
    gap: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-xl);
    padding: 12px 28px;
    backdrop-filter: blur(16px);
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.stat-value {
    font-size: 1.4rem;
    font-weight: 700;
    font-family: 'JetBrains Mono', monospace;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.72rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
}

.stat-divider {
    width: 1px;
    height: 32px;
    background: var(--border-subtle);
}

/* --- Search Bar --- */
.search-bar {
    position: relative;
    margin-bottom: 32px;
    animation: fadeInUp 0.7s ease-out 0.15s both;
}

.search-icon {
    position: absolute;
    left: 18px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-muted);
    pointer-events: none;
    transition: color var(--transition-fast);
}

.search-bar:focus-within .search-icon {
    color: var(--accent-primary);
}

#search-input {
    width: 100%;
    padding: 16px 20px 16px 50px;
    background: var(--bg-card);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    outline: none;
    transition: all var(--transition-smooth);
    backdrop-filter: blur(12px);
}

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

#search-input:focus {
    border-color: rgba(var(--accent-primary-rgb), 0.4);
    box-shadow: 0 0 0 3px rgba(var(--accent-primary-rgb), 0.1), var(--shadow-card);
    background: var(--bg-card-hover);
}

/* --- Scripts Grid --- */
.scripts-grid {
    display: grid;
    gap: 16px;
    animation: fadeInUp 0.7s ease-out 0.3s both;
}

/* --- Script Card --- */
.script-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    padding: 24px;
    transition: all var(--transition-smooth);
    backdrop-filter: blur(12px);
    position: relative;
    overflow: hidden;
    cursor: default;
    animation: cardAppear 0.5s ease-out both;
}

.script-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--gradient-primary);
    opacity: 0;
    transition: opacity var(--transition-smooth);
}

.script-card:hover {
    border-color: var(--border-hover);
    background: var(--bg-card-hover);
    box-shadow: var(--shadow-card-hover);
    transform: translateY(-2px);
}

.script-card:hover::before {
    opacity: 1;
}

.card-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 12px;
}

.card-title-section {
    flex: 1;
    min-width: 0;
}

.card-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.3;
}

.card-author {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 400;
}

.card-author span {
    color: var(--text-secondary);
}

.card-version {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: 50px;
    background: rgba(var(--accent-primary-rgb), 0.12);
    color: var(--accent-primary);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    border: 1px solid rgba(var(--accent-primary-rgb), 0.15);
}

.card-description {
    font-size: 0.92rem;
    color: var(--text-secondary);
    line-height: 1.65;
    margin-bottom: 16px;
}

/* --- Tags (match, grant, run-at) --- */
.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 16px;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 50px;
    font-size: 0.7rem;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 500;
    border: 1px solid;
}

.tag-match {
    background: rgba(var(--accent-secondary-rgb), 0.08);
    color: var(--accent-secondary);
    border-color: rgba(var(--accent-secondary-rgb), 0.15);
}

.tag-grant {
    background: rgba(247, 183, 49, 0.08);
    color: var(--accent-warning);
    border-color: rgba(247, 183, 49, 0.15);
}

.tag-runat {
    background: rgba(38, 222, 129, 0.08);
    color: var(--accent-success);
    border-color: rgba(38, 222, 129, 0.15);
}

/* --- Card Actions --- */
.card-actions {
    display: flex;
    gap: 10px;
    padding-top: 16px;
    border-top: 1px solid var(--border-subtle);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 0.82rem;
    font-weight: 600;
    text-decoration: none;
    transition: all var(--transition-fast);
    cursor: pointer;
    border: none;
    outline: none;
}

.btn-install {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 2px 8px rgba(var(--accent-primary-rgb), 0.25);
}

.btn-install:hover {
    box-shadow: 0 4px 16px rgba(var(--accent-primary-rgb), 0.4);
    transform: translateY(-1px);
}

.btn-install:active {
    transform: translateY(0);
}

.btn-source {
    background: var(--bg-glass);
    color: var(--text-secondary);
    border: 1px solid var(--border-subtle);
}

.btn-source:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.btn svg {
    width: 16px;
    height: 16px;
}

/* --- Card Error State --- */
.script-card.card-error {
    border-color: rgba(252, 92, 101, 0.15);
}

.script-card.card-error .card-version {
    background: rgba(252, 92, 101, 0.12);
    color: var(--accent-error);
    border-color: rgba(252, 92, 101, 0.2);
}

/* --- Loading State --- */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    gap: 24px;
    color: var(--text-muted);
}

.loading-spinner {
    position: relative;
    width: 48px;
    height: 48px;
}

.spinner-ring {
    position: absolute;
    inset: 0;
    border: 2px solid transparent;
    border-radius: 50%;
}

.spinner-ring:nth-child(1) {
    border-top-color: var(--accent-primary);
    animation: spin 1s linear infinite;
}

.spinner-ring:nth-child(2) {
    inset: 4px;
    border-right-color: var(--accent-secondary);
    animation: spin 1.5s linear infinite reverse;
}

.spinner-ring:nth-child(3) {
    inset: 8px;
    border-bottom-color: var(--accent-warning);
    animation: spin 2s linear infinite;
}

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

/* --- Empty & Error States --- */
.empty-state,
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
    gap: 12px;
}

.empty-state svg,
.error-state svg {
    width: 48px;
    height: 48px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.empty-state h3,
.error-state h3 {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.empty-state p,
.error-state p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.empty-state code {
    font-family: 'JetBrains Mono', monospace;
    background: rgba(var(--accent-primary-rgb), 0.1);
    color: var(--accent-primary);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
}

.btn-retry {
    margin-top: 8px;
    padding: 10px 24px;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-retry:hover {
    box-shadow: 0 4px 16px rgba(var(--accent-primary-rgb), 0.4);
    transform: translateY(-1px);
}

/* --- Footer --- */
.footer {
    text-align: center;
    margin-top: 48px;
    padding-top: 24px;
    border-top: 1px solid var(--border-subtle);
    animation: fadeInUp 0.7s ease-out 0.5s both;
}

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

/* --- Utilities --- */
.hidden {
    display: none !important;
}

/* --- Animations --- */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes cardAppear {
    from {
        opacity: 0;
        transform: translateY(12px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* --- Responsive --- */
@media (max-width: 640px) {
    .container {
        padding: 24px 16px 48px;
    }

    .header h1 {
        font-size: 1.8rem;
    }

    .header-subtitle {
        font-size: 0.92rem;
    }

    .header-stats {
        gap: 14px;
        padding: 10px 20px;
    }

    .stat-value {
        font-size: 1.1rem;
    }

    .script-card {
        padding: 18px;
    }

    .card-top {
        flex-direction: column;
        gap: 8px;
    }

    .card-actions {
        flex-direction: column;
    }

    .btn {
        justify-content: center;
    }
}
.page-actions,
.admin-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 12px;
}

.page-actions {
    justify-content: flex-end;
    margin-bottom: 16px;
}

.access-panel {
    width: min(440px, calc(100% - 32px));
    margin: min(15vh, 120px) auto 40px;
    padding: clamp(20px, 5vw, 36px);
    border: 1px solid var(--border-card);
    border-radius: var(--radius-lg);
    background: var(--bg-card);
}

.access-panel h1,
.admin-heading {
    margin-bottom: 20px;
}

.setup-panel {
    margin-top: 40px;
}

.access-panel form {
    display: grid;
    gap: 12px;
}

.access-panel a {
    margin-top: 16px;
}

.access-panel button {
    justify-self: start;
}

.access-panel input[type="password"],
#admin-search {
    width: 100%;
    padding: 10px 12px;
    font: inherit;
    color: var(--text-primary);
    background: var(--bg-secondary);
    border: 1px solid var(--border-hover);
    border-radius: var(--radius-sm);
}

#admin-search {
    display: block;
    margin: 6px 0 16px;
}

.form-error,
.form-success {
    margin: 0 0 16px;
}

.form-error { color: #ff9a9f; }
.form-success, .status-visible { color: #85e1bb; }
.status-hidden { color: #f0c77b; }

.admin-list {
    list-style: none;
    display: grid;
    gap: 8px;
}

.admin-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 16px;
    border: 1px solid var(--border-card);
    border-radius: var(--radius-md);
    background: var(--bg-card);
    overflow-wrap: anywhere;
}

.admin-row[hidden] { display: none; }
.admin-row:target { border-color: var(--accent-primary); }

.admin-file {
    display: block;
    color: #a7a7b5;
    font-size: 0.875rem;
}

