:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-dark: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --accent: #10b981;
    --glass-border: rgba(255, 255, 255, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    line-height: 1.6;
    overflow-x: hidden;
    min-height: 100vh;
}

::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

h1, h2, .logo span {
    font-family: 'Outfit', sans-serif;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 2rem;
}

/* Background Blobs */
.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    filter: blur(80px);
    opacity: 0.4;
}

.blob {
    position: absolute;
    border-radius: 50%;
}

.blob-1 {
    width: 400px;
    height: 400px;
    background: #4338ca;
    top: -100px;
    left: -100px;
}

.blob-2 {
    width: 300px;
    height: 300px;
    background: #7c3aed;
    bottom: -50px;
    right: -50px;
}

.blob-3 {
    width: 250px;
    height: 250px;
    background: #0ea5e9;
    top: 40%;
    left: 60%;
}

/* Header */
header {
    padding: 1.5rem 0;
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    position: sticky;
    top: 0;
    z-index: 100;
}

header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary);
    text-decoration: none;
}

nav {
    display: flex;
    gap: 2rem;
}

nav a {
    color: var(--text-dim);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.3s;
}

nav a:hover, nav a.active {
    color: var(--text-main);
}

/* Hero Section */
.hero {
    text-align: center;
    padding: 4rem 0 3rem;
}

.hero h1 {
    font-size: 3.5rem;
    margin-bottom: 1rem;
    background: linear-gradient(to right, #fff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero h1 span {
    color: var(--primary);
    -webkit-text-fill-color: var(--primary);
}

.hero p {
    font-size: 1.25rem;
    color: var(--text-dim);
    max-width: 600px;
    margin: 0 auto;
}

/* Generator Card */
.generator-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 1.5rem;
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    margin-bottom: 3rem;
}

.tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1rem;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    padding: 0.5rem 1rem;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s;
    border-radius: 0.5rem;
}

.tab-btn.active {
    color: var(--text-main);
    background: rgba(99, 102, 241, 0.1);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.75rem;
    font-weight: 600;
    color: var(--text-dim);
}

input[type="text"], textarea {
    width: 100%;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: 0.75rem;
    padding: 1rem;
    color: white;
    font-size: 1rem;
    outline: none;
}

textarea {
    min-height: 150px;
    resize: vertical;
}

.action-bar {
    display: flex;
    justify-content: flex-end;
    margin-top: 2rem;
}

.primary-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 1rem 2.5rem;
    border-radius: 0.75rem;
    font-size: 1.1rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.loader {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.hidden {
    display: none !important;
}

#status-display {
    margin-top: 2rem;
}

.status-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.status-dot {
    width: 10px;
    height: 10px;
    background: var(--primary);
    border-radius: 50%;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
}

/* Result Section */
.result-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.result-card {
    background: var(--card-bg);
    backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 1.5rem;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 700;
    margin-bottom: 1rem;
}

.copy-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
}

.audio-card {
    grid-column: span 2;
}

#audio-player {
    width: 100%;
}

pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 1rem;
    border-radius: 0.5rem;
    font-size: 0.85rem;
    white-space: pre-wrap;
    color: #e2e8f0;
}

.script-card {
    grid-column: span 2;
}

.scrollable-content {
    background: rgba(0, 0, 0, 0.3);
    padding: 1.5rem;
    border-radius: 0.5rem;
    max-height: 400px;
    overflow-y: auto;
}

/* History Section */
#history-section {
    margin-top: 4rem;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.section-header h2 {
    font-size: 1.75rem;
    color: var(--text-main);
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 50%;
    transition: all 0.3s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
}

.history-controls {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.toggle-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-dim);
}

.toggle-container input {
    cursor: pointer;
}

/* Context Menu */
#context-menu {
    position: fixed;
    background: #1e293b;
    border: 1px solid var(--glass-border);
    border-radius: 0.5rem;
    padding: 0.5rem 0;
    min-width: 150px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    backdrop-filter: blur(10px);
}

.menu-item {
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.2s;
}

.menu-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.menu-item i {
    width: 16px;
    height: 16px;
}

.history-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.history-card {
    background: var(--card-bg);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    overflow: hidden;
    transition: transform 0.3s, border-color 0.3s;
}

.history-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
}

.history-card.clickable {
    cursor: pointer;
}

.history-card.clickable:active {
    transform: translateY(-2px);
    background: rgba(45, 55, 72, 0.8);
}

.card-thumb {
    width: 100%;
    height: 160px;
    background: #000;
    position: relative;
}

.card-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0.8;
}

.card-status {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    padding: 0.25rem 0.75rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 700;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
}

.status-completed { color: #10b981; }
.status-running { color: #fbbf24; }
.status-failed { color: #f87171; }

.pulse-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: #fbbf24;
    border-radius: 50%;
    margin-right: 4px;
    box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.7);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 10px rgba(251, 191, 36, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(251, 191, 36, 0); }
}

.card-body {
    padding: 1.25rem;
}

.card-body h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
}

.card-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-dim);
    font-size: 0.85rem;
}

.view-count {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.retry-btn {
    background: rgba(248, 113, 113, 0.1);
    border: 1px solid rgba(248, 113, 113, 0.3);
    color: #f87171;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.3s;
}

.retry-btn:hover {
    background: rgba(248, 113, 113, 0.2);
    border-color: #f87171;
    color: #fff;
}

.view-btn {
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: var(--primary);
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    cursor: pointer;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    transition: all 0.3s;
}

.view-btn:hover {
    background: var(--primary);
    color: #fff;
}

.error-msg {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: #f87171;
    background: rgba(248, 113, 113, 0.1);
    padding: 0.5rem;
    border-radius: 0.4rem;
    border: 1px solid rgba(248, 113, 113, 0.2);
}

.running-msg {
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: #fbbf24;
    background: rgba(251, 191, 36, 0.1);
    padding: 0.5rem;
    border-radius: 0.4rem;
    border: 1px solid rgba(251, 191, 36, 0.2);
}

footer {
    text-align: center;
    padding: 4rem 0 2rem;
    color: var(--text-dim);
}
