:root {
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --accent: #ec4899;
    --bg-dark: #0a0e1a;
    --glass-bg: rgba(255, 255, 255, 0.04);
    --glass-border: rgba(255, 255, 255, 0.08);
    --text-main: #f1f5f9;
    --text-dim: #64748b;
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Outfit', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    padding: 2rem 1rem;
    overflow-x: hidden;
    position: relative;
}

/* ── Animated Background Blobs ── */
.bg-blobs {
    position: fixed;
    inset: 0;
    z-index: -1;
    overflow: hidden;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(100px);
    opacity: 0.35;
    animation: float 20s ease-in-out infinite alternate;
}

.blob-1 {
    width: 500px;
    height: 500px;
    background: var(--primary);
    top: -10%;
    left: -10%;
    animation-delay: 0s;
}

.blob-2 {
    width: 400px;
    height: 400px;
    background: var(--accent);
    bottom: -10%;
    right: -5%;
    animation-delay: -7s;
}

.blob-3 {
    width: 350px;
    height: 350px;
    background: #3b82f6;
    top: 50%;
    left: 60%;
    animation-delay: -14s;
}

@keyframes float {
    0% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(30px, -50px) scale(1.05);
    }

    66% {
        transform: translate(-20px, 20px) scale(0.95);
    }

    100% {
        transform: translate(10px, -30px) scale(1.02);
    }
}

/* ── Container ── */
.container {
    width: 100%;
    max-width: 1000px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 28px;
    padding: 3rem;
    box-shadow: 0 32px 64px -16px rgba(0, 0, 0, 0.6);
    animation: fadeIn 0.6s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(24px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── Header ── */
header {
    text-align: center;
    margin-bottom: 2.5rem;
}

.header-top {
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    margin-bottom: 0.5rem;
}

.history-toggle-btn {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    border-radius: 10px;
}

.history-toggle-btn:hover {
    background: var(--glass-border);
    transform: translateY(-50%) scale(1.05);
}

h1 {
    font-size: 2.8rem;
    font-weight: 700;
    color: #fff;
}

.accent {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-dim);
    font-size: 1.05rem;
}

/* ── Input ── */
.input-section {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    margin-bottom: 2.5rem;
}

.method-selector {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.method-selector label {
    font-size: 0.85rem;
    color: var(--text-dim);
    font-weight: 500;
    margin-left: 0.5rem;
}

.tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    padding: 4px;
    border-radius: 12px;
    border: 1px solid var(--glass-border);
}

.tab-btn {
    flex: 1;
    padding: 0.6rem 1rem;
    border-radius: 8px;
    font-size: 0.85rem;
    background: transparent;
    color: var(--text-dim);
    border: none;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--glass-border);
    color: var(--text-main);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.token-input-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    animation: fadeIn 0.3s ease-out;
}

.token-input-wrapper label {
    font-size: 0.85rem;
    color: var(--text-dim);
    font-weight: 500;
    margin-left: 0.5rem;
}

#tokenInput {
    width: 100%;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.9rem 1.25rem;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.3s;
}

#tokenInput:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.35);
}

.sequential-inputs-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    animation: fadeIn 0.3s ease-out;
}

.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-group label {
    font-size: 0.85rem;
    color: var(--text-dim);
    font-weight: 500;
    margin-left: 0.5rem;
}

.input-group input {
    width: 100%;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 0.9rem 1.25rem;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.35);
}

textarea {
    width: 100%;
    height: 180px;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 1.25rem;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.95rem;
    resize: vertical;
    transition: border-color 0.3s, box-shadow 0.3s;
    line-height: 1.6;
}

textarea::placeholder {
    color: var(--text-dim);
}

textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* ── Buttons ── */
button {
    cursor: pointer;
    border: none;
    border-radius: 12px;
    padding: 0.85rem 1.8rem;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.95rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: white;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.35);
}

.primary-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.45);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid var(--glass-border);
    color: var(--text-dim);
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.generate-btn {
    background: linear-gradient(135deg, var(--accent), #be185d);
    color: white;
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.35);
}

.generate-btn:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(236, 72, 153, 0.45);
}

/* ── Results ── */
.results-section {
    border-top: 1px solid var(--glass-border);
    padding-top: 2rem;
    animation: slideUp 0.4s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.results-header h2 {
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.count-badge {
    background: rgba(139, 92, 246, 0.2);
    color: var(--primary);
    font-size: 0.85rem;
    padding: 2px 10px;
    border-radius: 20px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.header-actions-extra {
    display: flex;
    gap: 0.5rem;
    padding-left: 1rem;
    border-left: 1px solid var(--glass-border);
}

.btn-sm {
    padding: 0.6rem 1.2rem;
    font-size: 0.85rem;
}

.danger-btn {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.danger-btn:hover {
    background: var(--error);
    color: white;
}

.progress-text {
    font-size: 0.85rem;
    color: var(--text-dim);
}

/* ── Cards ── */
.cards-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 1.25rem;
}

.card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    transition: all 0.3s ease;
    animation: cardIn 0.3s ease-out both;
}

@keyframes cardIn {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(8px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(139, 92, 246, 0.3);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-index {
    font-size: 0.7rem;
    color: var(--text-dim);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 8px;
    border-radius: 6px;
}

.phone {
    font-weight: 600;
    font-size: 1.15rem;
    color: var(--text-main);
    font-variant-numeric: tabular-nums;
}

.status-badge {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 3px 10px;
    border-radius: 20px;
    font-weight: 600;
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-dim);
    white-space: nowrap;
}

.status-badge.loading {
    background: rgba(139, 92, 246, 0.2);
    color: var(--primary);
    animation: pulse 1.5s infinite;
}

.status-badge.success {
    background: rgba(34, 197, 94, 0.15);
    color: var(--success);
}

.status-badge.error {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

.card-content {
    min-height: 20px;
}

.card-content p {
    color: var(--text-dim);
    font-size: 0.85rem;
}

.link-container {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    padding: 0.65rem 0.8rem;
    font-size: 0.8rem;
    border: 1px solid rgba(34, 197, 94, 0.15);
    word-break: break-all;
    line-height: 1.5;
}

.link-container a {
    color: var(--success);
    text-decoration: none;
}

.link-container a:hover {
    text-decoration: underline;
}

/* ── History Panel ── */
.history-panel {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-left: 1px solid var(--glass-border);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: right 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: -20px 0 50px rgba(0, 0, 0, 0.5);
}

.history-panel.open {
    right: 0;
}

.history-panel-header {
    padding: 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
}

.history-panel-header h3 {
    font-size: 1.2rem;
    font-weight: 600;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.2s;
}

.close-btn:hover {
    color: var(--text-main);
}

.history-list {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.history-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.history-item-header {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--text-dim);
}

.history-phone {
    font-weight: 600;
    color: var(--text-main);
}

.history-link-box {
    background: rgba(0, 0, 0, 0.2);
    padding: 0.5rem;
    border-radius: 8px;
    font-size: 0.8rem;
    word-break: break-all;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
}

.history-copy-btn {
    background: var(--glass-border);
    border: none;
    color: var(--text-main);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    cursor: pointer;
}

.history-panel-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--glass-border);
}

.history-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
    backdrop-filter: blur(4px);
}

.history-overlay.open {
    display: block;
}

.hidden {
    display: none;
}

/* ── Responsive ── */
@media (max-width: 640px) {
    .container {
        padding: 1.5rem;
        border-radius: 20px;
    }

    h1 {
        font-size: 2rem;
    }

    .results-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .cards-grid {
        grid-template-columns: 1fr;
    }

    .history-panel {
        width: 100%;
        right: -100%;
    }
}