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

:root {
    --bg-primary: #000000;
    --bg-secondary: #0a0a0a;
    --bg-card: #111111;
    --bg-card-hover: #1a1a1a;
    --bg-input: #0d0d0d;
    --border-color: #222222;
    --border-hover: #333333;
    --text-primary: #ffffff;
    --text-secondary: #a0a0a0;
    --text-muted: #666666;
    --accent-start: #6366f1;
    --accent-mid: #8b5cf6;
    --accent-end: #a855f7;
    --accent-glow: rgba(99, 102, 241, 0.15);
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --success: #22c55e;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;
    --transition-fast: 150ms ease;
    --transition-base: 250ms ease;
    --transition-slow: 400ms cubic-bezier(0.16, 1, 0.3, 1);
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

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

/* ===== Background Ambient Glow ===== */
body::before {
    content: '';
    position: fixed;
    top: -40%;
    left: -20%;
    width: 80%;
    height: 80%;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.06) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    bottom: -40%;
    right: -20%;
    width: 80%;
    height: 80%;
    background: radial-gradient(circle, rgba(168, 85, 247, 0.05) 0%, transparent 70%);
    pointer-events: none;
    z-index: 0;
}

/* ===== Nav Badge ===== */
.nav-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 14px;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: var(--radius-full);
    color: var(--success);
    font-size: 0.8rem;
    font-weight: 500;
}

/* ===== Loading Progress ===== */
.loading-progress {
    width: 200px;
    height: 3px;
    background: var(--border-color);
    border-radius: var(--radius-full);
    margin: 16px auto 0;
    overflow: hidden;
}

.loading-bar {
    width: 30%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-start), var(--accent-end));
    border-radius: var(--radius-full);
    animation: loadingSlide 1.5s ease-in-out infinite;
}

@keyframes loadingSlide {
    0% {
        transform: translateX(-100%);
        width: 30%;
    }

    50% {
        width: 60%;
    }

    100% {
        transform: translateX(400%);
        width: 30%;
    }
}

/* ===== Header ===== */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
}

nav {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.btn-ghost {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

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

/* ===== Main Content ===== */
main {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 24px 80px;
    position: relative;
    z-index: 1;
}

/* ===== Hero Section ===== */
.hero {
    text-align: center;
    padding: 64px 0 40px;
}

.hero-badge {
    display: inline-block;
    padding: 6px 16px;
    background: var(--accent-glow);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: var(--radius-full);
    color: var(--accent-mid);
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-bottom: 20px;
}

.hero h1 {
    font-size: 3rem;
    font-weight: 800;
    letter-spacing: -0.03em;
    line-height: 1.1;
    margin-bottom: 16px;
}

.gradient-text {
    background: linear-gradient(135deg, var(--accent-start) 0%, var(--accent-mid) 50%, var(--accent-end) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    max-width: 500px;
    margin: 0 auto;
    line-height: 1.7;
}

/* ===== Search Section ===== */
.search-section {
    margin-bottom: 32px;
}

.search-container {
    display: flex;
    align-items: center;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 6px 6px 6px 20px;
    transition: all var(--transition-base);
}

.search-container:focus-within {
    border-color: var(--accent-start);
    box-shadow: 0 0 0 4px var(--accent-glow), 0 4px 20px rgba(0, 0, 0, 0.3);
}

.search-icon {
    color: var(--text-muted);
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

#searchInput {
    flex: 1;
    padding: 14px 16px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 1rem;
    outline: none;
}

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

.generate-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 28px;
    background: var(--text-primary);
    color: var(--bg-primary);
    border: none;
    border-radius: var(--radius-xl);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
}

.generate-btn:hover {
    background: #e0e0e0;
    transform: scale(1.02);
}

.generate-btn:active {
    transform: scale(0.98);
}

.generate-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ===== Loading Section ===== */
.loading-section {
    text-align: center;
    padding: 48px 0;
}

.loading-section p {
    color: var(--text-secondary);
    margin-top: 20px;
    font-size: 0.95rem;
    animation: pulse 2s infinite;
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--accent-mid);
    border-radius: 50%;
    margin: 0 auto;
    animation: spin 0.8s linear infinite;
}

/* ===== Results Section ===== */
.results-section {
    animation: fadeIn 0.5s ease;
}

.results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
    padding: 16px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.char-counter {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    font-variant-numeric: tabular-nums;
}

.char-counter.warning {
    color: #f59e0b;
}

.char-counter.danger {
    color: var(--danger);
}

.results-actions {
    display: flex;
    gap: 8px;
}

.btn-copy,
.btn-clear {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-full);
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.btn-copy {
    background: var(--text-primary);
    color: var(--bg-primary);
    border: none;
}

.btn-copy:hover {
    background: #e0e0e0;
    transform: translateY(-1px);
}

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

.btn-clear:hover {
    color: var(--danger);
    border-color: var(--danger);
    background: rgba(239, 68, 68, 0.08);
}

/* ===== Tags Container ===== */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.88rem;
    color: var(--text-primary);
    transition: all var(--transition-fast);
    animation: tagAppear 0.3s ease backwards;
    cursor: default;
}

.tag-pill:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
}

.tag-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    border-radius: 50%;
    transition: all var(--transition-fast);
    padding: 0;
    line-height: 1;
}

.tag-remove:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.15);
}

/* ===== How to Use ===== */
.how-to-use {
    margin-top: 80px;
    text-align: center;
}

.how-to-use h2 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 40px;
    letter-spacing: -0.02em;
}

.steps-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.step-card {
    padding: 32px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
}

.step-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
}

.step-number {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--accent-start), var(--accent-end));
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    margin: 0 auto 16px;
}

.step-card h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.step-card p {
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.6;
}

/* ===== FAQ Section ===== */
.faq-section {
    margin-top: 80px;
}

.faq-section h2 {
    text-align: center;
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 40px;
    letter-spacing: -0.02em;
}

.faq-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.faq-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color var(--transition-fast);
}

.faq-item:hover {
    border-color: var(--border-hover);
}

.faq-question {
    width: 100%;
    padding: 18px 20px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.faq-question svg {
    flex-shrink: 0;
    color: var(--text-muted);
    transition: transform var(--transition-base);
}

.faq-item.active .faq-question svg {
    transform: rotate(180deg);
}

.faq-answer {
    max-height: 0;
    overflow: hidden;
    transition: max-height var(--transition-slow), padding var(--transition-slow);
}

.faq-item.active .faq-answer {
    max-height: 300px;
}

.faq-answer p {
    padding: 0 20px 18px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    line-height: 1.7;
}

/* ===== Footer ===== */
footer {
    text-align: center;
    padding: 40px 24px;
    border-top: 1px solid var(--border-color);
    color: var(--text-muted);
    font-size: 0.85rem;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    color: var(--success);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    z-index: 2000;
    opacity: 0;
    transition: all var(--transition-base);
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.hidden {
    display: flex;
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-8px);
    }
}

@keyframes tagAppear {
    from {
        opacity: 0;
        transform: scale(0.8) translateY(8px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ===== Utility ===== */
.hidden {
    display: none !important;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .hero h1 {
        font-size: 2.2rem;
    }

    .hero-subtitle {
        font-size: 1rem;
    }

    .search-container {
        padding: 4px 4px 4px 14px;
    }

    .generate-btn span {
        display: none;
    }

    .generate-btn {
        padding: 12px 16px;
    }

    .steps-grid {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }

    .results-actions {
        width: 100%;
        justify-content: space-between;
    }

    .btn-copy,
    .btn-clear {
        flex: 1;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .hero {
        padding: 32px 0 20px;
    }

    .hero h1 {
        font-size: 1.75rem;
    }

    .hero-subtitle {
        font-size: 0.95rem;
    }

    .hero-badge {
        font-size: 0.75rem;
        padding: 5px 12px;
    }

    main {
        padding: 0 16px 60px;
    }

    nav {
        padding: 0 16px;
        height: 56px;
    }

    .logo {
        font-size: 1.1rem;
    }

    .logo-icon {
        width: 32px;
        height: 32px;
    }

    /* Larger touch targets for mobile */
    .tag-pill {
        padding: 10px 16px;
        font-size: 0.9rem;
    }

    .tag-remove {
        width: 22px;
        height: 22px;
        font-size: 16px;
    }

    /* Better spacing for FAQ on mobile */
    .faq-question {
        padding: 16px;
        font-size: 0.9rem;
    }

    .faq-answer p {
        padding: 0 16px 16px;
        font-size: 0.85rem;
    }

    /* Improve loading section */
    .loading-section {
        padding: 32px 0;
    }

    .loading-section p {
        font-size: 0.9rem;
    }

    /* Better button sizing */
    .btn-copy,
    .btn-clear {
        padding: 10px 14px;
        font-size: 0.8rem;
    }

    .char-counter {
        font-size: 0.85rem;
    }
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {

    /* Increase tap target sizes */
    .tag-remove {
        min-width: 24px;
        min-height: 24px;
    }

    .faq-question {
        min-height: 48px;
    }

    .generate-btn {
        min-height: 48px;
    }

    /* Remove hover effects on touch devices */
    .tag-pill:hover {
        background: var(--bg-card);
        border-color: var(--border-color);
    }
}