/* --- General --- */
:root {
    --font-family: 'Sora', sans-serif;
    --background: #f4f7fa;
    --surface: #ffffff;
    --on-surface: #1a1c2c;
    --primary: #4a55ff;
    --primary-deep: #353dd6;
    --primary-light: rgba(74, 85, 255, 0.1);
    --border-color: #e2e8f0;
    --text-primary: #1a1c2c;
    --text-secondary: #717d96;
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.02), 0 10px 20px rgba(0, 0, 0, 0.05);
    --radius: 12px;
}

body.dark {
    --background: #131420;
    --surface: #1a1c2c;
    --on-surface: #ffffff;
    --border-color: #2c2f48;
    --text-primary: #ffffff;
    --text-secondary: #8c96c4;
    --primary-light: rgba(74, 85, 255, 0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background: var(--background);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    padding: 20px;
    transition: background 0.3s ease, color 0.3s ease;
}

.container {
    width: 100%;
    max-width: 600px;
    margin-top: 5vh;
}

/* --- Header --- */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.logo-title {
    font-size: 1.75rem;
    font-weight: 700;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: var(--radius);
    transition: all 0.2s ease;
}

.icon-btn:hover {
    color: var(--primary);
    background: var(--primary-light);
}

/* --- Tab Navigation --- */
.tab-nav {
    display: flex;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 0.5rem;
    margin-bottom: 2rem;
}

.tab-btn {
    flex: 1;
    padding: 0.8rem 1rem;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 10px rgba(74, 85, 255, 0.2);
}

.tab-btn:not(.active):hover {
    color: var(--primary);
}

.tab-btn:disabled {
    cursor: not-allowed;
    opacity: 0.6;
}

.beta-tag {
    background-color: #ffc107;
    color: #000;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: 8px;
    text-transform: uppercase;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Sub-Tab Navigation --- */
.sub-tab-nav {
    display: flex;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.sub-tab-btn {
    padding: 0.8rem 1.2rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px; /* Aligns with the parent border */
}

.sub-tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.sub-tab-content {
    display: none;
}

.sub-tab-content.active {
    display: block;
    animation: fadeIn 0.5s ease;
}

/* --- Input --- */
.input-container {
    position: relative;
    margin-bottom: 1rem;
}

.input-icon {
    position: absolute;
    top: 50%;
    left: 1.25rem;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 1rem;
}

input[type="text"] {
    width: 100%;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1.1rem 3.5rem;
    font-family: var(--font-family);
    font-size: 1rem;
    color: var(--text-primary);
    transition: border-color 0.3s ease;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

input::placeholder {
    color: var(--text-secondary);
    opacity: 0.8;
}

.paste-btn {
    position: absolute;
    top: 50%;
    right: 0.75rem;
    transform: translateY(-50%);
    background: var(--primary-light);
    border: none;
    color: var(--primary);
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.paste-btn:hover {
    background: var(--primary);
    color: white;
}

/* --- Action Button --- */
.action-btn {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    padding: 1.1rem;
    font-family: var(--font-family);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.action-btn:hover {
    background: var(--primary-deep);
    box-shadow: 0 7px 15px rgba(74, 85, 255, 0.2);
    transform: translateY(-2px);
}

.action-btn:disabled {
    background: var(--border-color);
    color: var(--text-secondary);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.action-btn.loading .btn-text {
    opacity: 0;
}

.action-btn .spinner {
    display: none;
}

.action-btn.loading .spinner {
    display: block;
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.5);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* --- Results Area --- */
#results-area {
    margin-top: 2rem;
}

.results-container, .stories-container {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    animation: fadeIn 0.5s ease;
}

.results-header {
    font-size: 1.2rem;
    margin-bottom: 1.5rem;
    font-weight: 600;
}

.quality-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
}

.quality-card {
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    padding: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quality-card:hover {
    border-color: var(--primary);
    transform: translateY(-3px);
    box-shadow: 0 4px 10px var(--primary-light);
}

.quality-card.selected {
    border-color: var(--primary);
    background: var(--primary-light);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.quality-card h4 {
    font-size: 1rem;
    color: var(--text-primary);
}

.quality-card p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.stories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1.5rem;
}

.story-card {
    text-align: center;
}

.story-card img, .story-card video {
    width: 100%;
    aspect-ratio: 9 / 16;
    object-fit: cover;
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    box-shadow: var(--shadow);
}

.story-card .download-link {
    display: inline-block;
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    margin-top: 0.5rem;
}

.story-card .download-link:hover {
    text-decoration: underline;
}

/* --- Loader --- */
.loader {
    text-align: center;
    padding: 2rem;
}
.loader .spinner {
    width: 32px;
    height: 32px;
    border-width: 3px;
    border-color: var(--border-color);
    border-top-color: var(--primary);
    animation: spin 1s linear infinite;
    margin: 0 auto;
    border-radius: 50%;
}

/* --- Format Tabs --- */
#format-tabs-container {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-top: 2rem;
    animation: fadeIn 0.5s ease;
}

#format-tabs-container.hidden {
    display: none;
}

.format-tab-nav {
    display: flex;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.format-tab-btn {
    padding: 0.8rem 1.2rem;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-family);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
}

.format-tab-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.format-tab-content {
    display: none;
}

.format-tab-content.active {
    display: block;
    animation: fadeIn 0.5s ease;
}


/* --- Toast Notifications --- */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.toast {
    background: var(--surface);
    color: var(--text-primary);
    padding: 1rem 1.5rem;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    border-left: 4px solid;
    animation: toastIn 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}

@keyframes toastIn {
    from { transform: translateX(120%); }
    to { transform: translateX(0); }
}

.toast.success { border-color: #22c55e; }
.toast.error { border-color: #ef4444; }
.toast.info { border-color: #3b82f6; }

.toast i {
    font-size: 1.25rem;
}
.toast.success i { color: #22c55e; }
.toast.error i { color: #ef4444; }
.toast.info i { color: #3b82f6; }


@media (max-width: 640px) {
    body {
        padding: 10px;
    }
    .container {
        margin-top: 2vh;
    }
    .tab-nav {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 0.5rem;
    }
} 