/* ========== RESET & BASE ========== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-card: #16161f;
    --bg-card-hover: #1c1c28;
    --bg-input: #1a1a26;
    --border-color: #2a2a3a;
    --border-light: #35354a;
    --text-primary: #f0f0f5;
    --text-secondary: #a0a0b8;
    --text-muted: #6b6b82;
    --gradient-start: #F58529;
    --gradient-mid: #DD2A7B;
    --gradient-end: #8134AF;
    --success: #00d67e;
    --error: #ff4757;
    --warning: #ffa502;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --shadow: 0 4px 24px rgba(0,0,0,0.3);
    --shadow-lg: 0 8px 40px rgba(0,0,0,0.4);
    --transition: 0.2s ease;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

a {
    color: inherit;
    text-decoration: none;
}

img, video {
    max-width: 100%;
    display: block;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    color: inherit;
}

.gradient-text {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-mid), var(--gradient-end));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ========== HEADER ========== */
.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 10, 15, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
}

.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 1.25rem;
}

.logo-icon {
    width: 32px;
    height: 32px;
}

.api-counter {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.api-counter-bar {
    width: 80px;
    height: 6px;
    background: var(--bg-input);
    border-radius: 3px;
    overflow: hidden;
}

.api-counter-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--success), var(--gradient-start));
    border-radius: 3px;
    transition: width 0.5s ease;
    width: 0%;
}

.api-counter-fill.warning {
    background: linear-gradient(90deg, var(--warning), var(--error));
}

/* ========== HERO ========== */
.hero {
    padding: 80px 0 60px;
    text-align: center;
    transition: padding var(--transition);
}

.hero.compact {
    padding: 30px 0 20px;
}

.hero-title {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    margin-bottom: 12px;
    line-height: 1.15;
}

.hero.compact .hero-title {
    font-size: 1.8rem;
}

.hero-subtitle {
    font-size: 1.15rem;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.hero.compact .hero-subtitle {
    display: none;
}

/* ========== SEARCH ========== */
.search-form {
    max-width: 680px;
    margin: 0 auto;
}

.search-wrapper {
    position: relative;
}

.search-input-group {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 4px;
    transition: border-color var(--transition), box-shadow var(--transition);
}

.search-input-group:focus-within {
    border-color: var(--gradient-mid);
    box-shadow: 0 0 0 4px rgba(221, 42, 123, 0.15);
}

.search-icon {
    width: 22px;
    height: 22px;
    margin-left: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-input {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    font-size: 1rem;
    color: var(--text-primary);
    padding: 14px 16px;
    font-family: inherit;
}

.search-input::placeholder {
    color: var(--text-muted);
}

.search-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-mid), var(--gradient-end));
    color: white;
    font-weight: 600;
    font-size: 0.95rem;
    padding: 12px 28px;
    border-radius: var(--radius-md);
    transition: opacity var(--transition), transform var(--transition);
    flex-shrink: 0;
}

.search-btn:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.search-btn:active {
    transform: translateY(0);
}

.search-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.search-btn-icon {
    width: 18px;
    height: 18px;
}

.search-hints {
    display: flex;
    justify-content: center;
    gap: 16px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.hint-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.82rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    transition: color var(--transition), background var(--transition);
}

.hint-item:hover {
    color: var(--text-secondary);
    background: var(--bg-card);
}

.hero.compact .search-hints {
    display: none;
}

/* ========== LOADING ========== */
.loading-overlay {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 0;
    text-align: center;
}

.loading-overlay.active {
    display: flex;
}

.spinner {
    width: 48px;
    height: 48px;
    position: relative;
    margin-bottom: 16px;
}

.spinner-ring {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid var(--border-color);
    border-top-color: var(--gradient-mid);
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

/* ========== RESULTS ========== */
.results-section {
    padding: 0 0 60px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
    padding: 8px 0;
    transition: color var(--transition);
}

.back-btn:hover {
    color: var(--text-primary);
}

/* ========== PROFILE CARD ========== */
.profile-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 32px;
    display: flex;
    gap: 32px;
    align-items: center;
    margin-bottom: 24px;
}

.profile-avatar {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid transparent;
    background-origin: border-box;
    background-clip: content-box, border-box;
    background-image:
        linear-gradient(var(--bg-card), var(--bg-card)),
        linear-gradient(135deg, var(--gradient-start), var(--gradient-mid), var(--gradient-end));
    flex-shrink: 0;
}

.profile-info {
    flex: 1;
    min-width: 0;
}

.profile-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.profile-name {
    font-size: 1.4rem;
    font-weight: 700;
}

.verified-badge {
    width: 20px;
    height: 20px;
    color: #3897f0;
}

.profile-username {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-bottom: 12px;
}

.profile-bio {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 16px;
    white-space: pre-wrap;
    word-break: break-word;
}

.profile-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
}

.profile-stat {
    text-align: center;
}

.profile-stat-value {
    font-weight: 700;
    font-size: 1.1rem;
}

.profile-stat-label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.profile-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.88rem;
    transition: all var(--transition);
}

.btn-gradient {
    background: linear-gradient(135deg, var(--gradient-start), var(--gradient-mid), var(--gradient-end));
    color: white;
}

.btn-gradient:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-outline {
    border: 1px solid var(--border-light);
    color: var(--text-secondary);
}

.btn-outline:hover {
    border-color: var(--gradient-mid);
    color: var(--text-primary);
    background: rgba(221, 42, 123, 0.08);
}

.btn-sm {
    padding: 7px 14px;
    font-size: 0.82rem;
}

.btn svg {
    width: 16px;
    height: 16px;
}

/* ========== MEDIA GRID ========== */
.section-title {
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.section-title .badge {
    background: var(--bg-input);
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 20px;
}

.media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.media-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color var(--transition), transform var(--transition);
}

.media-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
}

.media-card-thumb {
    position: relative;
    aspect-ratio: 1;
    overflow: hidden;
    background: var(--bg-secondary);
}

.media-card-thumb img,
.media-card-thumb video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-type-badge {
    position: absolute;
    top: 10px;
    left: 10px;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    color: white;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    display: flex;
    align-items: center;
    gap: 5px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.media-type-badge svg {
    width: 12px;
    height: 12px;
}

.carousel-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    color: white;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
}

.media-card-body {
    padding: 16px;
}

.media-card-caption {
    color: var(--text-secondary);
    font-size: 0.85rem;
    line-height: 1.5;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.media-card-stats {
    display: flex;
    gap: 16px;
    margin-bottom: 14px;
    font-size: 0.82rem;
    color: var(--text-muted);
}

.media-card-stats span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.media-card-stats svg {
    width: 14px;
    height: 14px;
}

.media-card-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* ========== SINGLE POST VIEW ========== */
.single-post {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
}

.single-post-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.single-post-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
}

.single-post-user {
    font-weight: 600;
    font-size: 0.95rem;
}

.single-post-date {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.single-post-media {
    background: var(--bg-secondary);
}

.single-post-media img,
.single-post-media video {
    width: 100%;
    max-height: 600px;
    object-fit: contain;
}

.single-post-body {
    padding: 20px;
}

.single-post-caption {
    color: var(--text-secondary);
    font-size: 0.95rem;
    line-height: 1.6;
    margin-bottom: 16px;
    white-space: pre-wrap;
    word-break: break-word;
}

.single-post-stats {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.single-post-stats span {
    display: flex;
    align-items: center;
    gap: 6px;
}

.single-post-stats svg {
    width: 18px;
    height: 18px;
}

.download-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.download-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.download-item-info {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 0.88rem;
}

.download-item-info .file-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    background: var(--bg-card);
    display: flex;
    align-items: center;
    justify-content: center;
}

.download-item-info .file-icon svg {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
}

.download-item-meta {
    font-size: 0.78rem;
    color: var(--text-muted);
}

/* ========== CAROUSEL VIEW ========== */
.carousel-items {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 12px;
    margin-top: 16px;
    padding: 0 20px 20px;
}

.carousel-item {
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    aspect-ratio: 1;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

.carousel-item img,
.carousel-item video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.carousel-item-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity var(--transition);
}

.carousel-item:hover .carousel-item-overlay {
    opacity: 1;
}

.carousel-item-number {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0,0,0,0.7);
    color: white;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 10px;
}

/* ========== TOAST ========== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 14px 24px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9rem;
    z-index: 1000;
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    box-shadow: var(--shadow-lg);
    max-width: 90vw;
}

.toast.active {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.error {
    border-color: var(--error);
}

.toast.success {
    border-color: var(--success);
}

/* ========== FEATURES ========== */
.features {
    padding: 60px 0;
    border-top: 1px solid var(--border-color);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 24px;
}

.feature-card {
    text-align: center;
    padding: 32px 24px;
    border-radius: var(--radius-lg);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    transition: border-color var(--transition), transform var(--transition);
}

.feature-card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
}

.feature-icon {
    margin-bottom: 16px;
}

.feature-card h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.feature-card p {
    font-size: 0.88rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* ========== FOOTER ========== */
.footer {
    padding: 24px 0;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.82rem;
    border-top: 1px solid var(--border-color);
}

/* ========== CACHED BADGE ========== */
.cached-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: rgba(0, 214, 126, 0.1);
    color: var(--success);
    font-size: 0.78rem;
    font-weight: 600;
    padding: 4px 12px;
    border-radius: 20px;
    margin-left: 12px;
}

/* ========== RESPONSIVE ========== */
@media (max-width: 768px) {
    .hero-title {
        font-size: 2rem;
    }

    .hero.compact .hero-title {
        font-size: 1.4rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    .profile-card {
        flex-direction: column;
        text-align: center;
        padding: 24px;
    }

    .profile-stats {
        justify-content: center;
    }

    .profile-actions {
        justify-content: center;
    }

    .features-grid {
        grid-template-columns: 1fr;
    }

    .media-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    }

    .search-btn-text {
        display: none;
    }

    .search-btn {
        padding: 12px 16px;
    }

    .single-post-stats {
        gap: 16px;
        flex-wrap: wrap;
    }

    .carousel-items {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
}

@media (max-width: 480px) {
    .media-grid {
        grid-template-columns: 1fr;
    }

    .hero {
        padding: 50px 0 40px;
    }

    .profile-avatar {
        width: 90px;
        height: 90px;
    }
}
