/**
 * PDF to HTML Converter - Unified Design
 * Focus on conversion functionality
 */

:root {
    --bg-primary: #0a0e27;
    --bg-secondary: #151932;
    --bg-tertiary: #1a1f3a;
    --accent-blue: #3b82f6;
    --accent-green: #10b981;
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    --border: #2d3548;
    --success: #10b981;
    --error: #ef4444;
}

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

html {
    overflow-y: scroll;
    overflow-x: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, var(--bg-primary) 0%, #0f1423 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    position: relative;
}

/* Container */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 40px 20px;
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 60px;
}

.title {
    font-size: 2.5em;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-blue), var(--accent-green));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 12px;
}

.subtitle {
    font-size: 1.1em;
    color: var(--text-secondary);
    font-weight: 400;
}

/* Main Content */
.main {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Section */
.section {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 24px;
    transition: all 0.3s ease;
}

.section-title {
    font-size: 1.25em;
    font-weight: 700;
    margin-bottom: 16px;
    color: var(--text-primary);
}

/* API Section */
.api-section {
    border-left: 3px solid var(--accent-blue);
}

/* API Mode Toggle */
.api-mode-toggle {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.api-mode-btn {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 16px 20px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    border-radius: 12px;
    color: var(--text-secondary);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.api-mode-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.api-mode-btn:hover {
    border-color: var(--accent-blue);
    transform: translateY(-2px);
}

.api-mode-btn.active {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.1), rgba(59, 130, 246, 0.05));
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
}

.api-mode-btn span {
    flex: 1;
}

/* API Input Containers */
.api-input-container {
    animation: fadeInUp 0.3s ease;
}

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

/* License Status */
.license-status {
    margin-top: 16px;
    padding: 16px;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.1), rgba(16, 185, 129, 0.05));
    border: 2px solid var(--accent-green);
    border-radius: 12px;
    animation: fadeInUp 0.3s ease;
    transition: all 0.3s ease;
}

/* Error state */
.license-status.error {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.1), rgba(220, 38, 38, 0.05));
    border-color: #ef4444;
}

.license-status.error .license-icon {
    color: #ef4444 !important;
    animation: shake 0.5s ease;
}

.license-status.error .license-info strong {
    color: #ef4444 !important;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-5px); }
    20%, 40%, 60%, 80% { transform: translateX(5px); }
}

.license-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.license-icon {
    width: 24px;
    height: 24px;
    color: var(--accent-green);
    flex-shrink: 0;
}

.license-info div {
    flex: 1;
}

.license-info strong {
    display: block;
    color: var(--text-primary);
    font-size: 15px;
    margin-bottom: 4px;
}

.license-info span {
    display: block;
    color: var(--text-secondary);
    font-size: 13px;
}

.input-group {
    display: flex;
    gap: 12px;
    margin-bottom: 12px;
}

.input-field {
    flex: 1;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1em;
    font-family: inherit;
    transition: all 0.3s ease;
}

.input-field:focus {
    outline: none;
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.input-field.saved {
    border-color: var(--accent-green);
}

.help-text {
    font-size: 0.9em;
    color: var(--text-muted);
}

.link {
    color: var(--accent-green);
    text-decoration: none;
    font-weight: 600;
}

.link:hover {
    text-decoration: underline;
}

/* Mode Section */
.mode-section {
    border-left: 3px solid var(--accent-green);
}

.mode-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.mode-btn {
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 16px 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-family: inherit;
}

.mode-btn:hover {
    border-color: var(--accent-green);
    transform: translateY(-2px);
}

.mode-btn.active {
    border-color: var(--accent-green);
    background: rgba(16, 185, 129, 0.1);
}

.mode-name {
    font-size: 1em;
    font-weight: 600;
    color: var(--text-primary);
}

.mode-btn.active .mode-name {
    color: var(--accent-green);
}

.mode-desc {
    font-size: 0.85em;
    color: var(--text-muted);
}

/* Quality Section */
.quality-section {
    border-left: 3px solid var(--accent-blue);
}

/* JSONL Section */
.jsonl-section {
    border-left: 3px solid var(--accent-green);
}

.jsonl-controls {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.jsonl-mode-toggle {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.jsonl-mode-btn {
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 16px 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-family: inherit;
}

.jsonl-mode-btn:hover {
    border-color: var(--accent-green);
    transform: translateY(-2px);
}

.jsonl-mode-btn.active {
    border-color: var(--accent-green);
    background: rgba(16, 185, 129, 0.1);
}

.jsonl-mode-btn span {
    font-size: 1em;
    font-weight: 600;
    color: var(--text-primary);
}

.jsonl-mode-btn.active span {
    color: var(--accent-green);
}

.jsonl-mode-btn small {
    font-size: 0.85em;
    color: var(--text-muted);
}

.jsonl-count-input {
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 20px;
}

.jsonl-count-input label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.jsonl-count-input input[type="number"] {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 2px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-size: 1.1em;
    font-family: inherit;
    transition: all 0.3s ease;
}

.jsonl-count-input input[type="number"]:focus {
    outline: none;
    border-color: var(--accent-green);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.jsonl-count-input small {
    display: block;
    margin-top: 8px;
    font-size: 0.85em;
    color: var(--text-muted);
}

.quality-options {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.quality-btn {
    background: var(--bg-tertiary);
    border: 2px solid var(--border);
    border-radius: 8px;
    padding: 16px 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    font-family: inherit;
}

.quality-btn:hover {
    border-color: var(--accent-blue);
    transform: translateY(-2px);
}

.quality-btn.active {
    border-color: var(--accent-green);
    background: rgba(16, 185, 129, 0.1);
}

.quality-name {
    font-size: 1em;
    font-weight: 600;
    color: var(--text-primary);
}

.quality-btn.active .quality-name {
    color: var(--accent-green);
}

.quality-desc {
    font-size: 0.85em;
    color: var(--text-muted);
}

/* Convert Section - MAIN FOCUS */
.convert-section {
    border: 3px solid var(--accent-green);
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05), rgba(59, 130, 246, 0.05));
    padding: 40px;
}

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

.convert-title {
    font-size: 2em;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-green), var(--accent-blue));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 32px;
}

/* Upload Zone */
.upload-zone {
    margin-bottom: 24px;
    transition: opacity 0.3s ease;
}

.upload-zone.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.file-input {
    display: none;
}

.upload-area {
    display: block;
    padding: 60px 40px;
    background: var(--bg-tertiary);
    border: 3px dashed var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.upload-area:hover {
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.05);
}

.upload-zone.dragover .upload-area {
    border-color: var(--accent-green);
    background: rgba(16, 185, 129, 0.1);
    transform: scale(1.02);
}

.upload-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.upload-icon {
    width: 80px;
    height: 80px;
    color: var(--accent-blue);
}

.upload-text {
    font-size: 1.2em;
    font-weight: 600;
    color: var(--text-primary);
}

.upload-hint {
    font-size: 0.9em;
    color: var(--text-muted);
}

/* Buttons */
.btn {
    padding: 14px 28px;
    border: none;
    border-radius: 8px;
    font-size: 1em;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-primary {
    background: var(--accent-blue);
    color: white;
}

.btn-primary:hover {
    background: #2563eb;
    transform: translateY(-2px);
}

.btn-convert {
    width: 100%;
    padding: 20px 40px;
    background: linear-gradient(135deg, var(--accent-green), #059669);
    color: white;
    font-size: 1.3em;
    font-weight: 700;
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.3);
    border-radius: 12px;
}

.btn-convert:hover:not(:disabled) {
    transform: translateY(-3px);
    box-shadow: 0 12px 32px rgba(16, 185, 129, 0.4);
}

.btn-convert:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-small {
    padding: 10px 20px;
    font-size: 0.95em;
    background: var(--accent-blue);
    color: white;
}

.btn-small:hover {
    background: #2563eb;
}

.btn-download {
    background: var(--accent-green);
}

.btn-download:hover {
    background: #059669;
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--border);
    color: var(--text-primary);
}

.btn-outline:hover {
    border-color: var(--accent-blue);
    background: rgba(59, 130, 246, 0.1);
}

/* Loading */
.loading-section {
    display: none;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 60px 40px;
    text-align: center;
}

.loading-section.active {
    display: block;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border);
    border-top-color: var(--accent-green);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 24px;
}

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

.loading-title {
    font-size: 1.5em;
    font-weight: 700;
    margin-bottom: 8px;
}

.loading-text {
    color: var(--text-secondary);
}

/* Error */
.error-section {
    display: none;
    background: rgba(239, 68, 68, 0.1);
    border: 2px solid var(--error);
    border-left: 4px solid var(--error);
    border-radius: 8px;
    padding: 16px 20px;
    color: #fca5a5;
}

.error-section.active {
    display: block;
}

/* Success Message */
.success-message {
    background: rgba(16, 185, 129, 0.1);
    border: 2px solid var(--success);
    border-left: 4px solid var(--success);
    border-radius: 8px;
    padding: 12px 16px;
    color: #6ee7b7;
    margin-top: 12px;
    font-size: 0.9em;
}

/* Result Section */
.result-section {
    display: none;
    border-left: 3px solid var(--accent-green);
}

.result-section.active {
    display: block;
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 16px;
}

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

.result-tabs {
    display: flex;
    gap: 8px;
    border-bottom: 2px solid var(--border);
    margin-bottom: 20px;
}

.tab-btn {
    padding: 12px 24px;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-muted);
    font-size: 1em;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    bottom: -2px;
}

.tab-btn:hover {
    color: var(--text-secondary);
}

.tab-btn.active {
    color: var(--accent-green);
    border-bottom-color: var(--accent-green);
}

.result-content {
    position: relative;
}

.result-preview {
    width: 100%;
    height: 700px;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: white;
}

.result-code {
    display: none;
    background: #1e1e1e;
    color: #d4d4d4;
    padding: 20px;
    border-radius: 8px;
    height: 700px;
    overflow: auto;
    font-family: 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    border: 2px solid var(--border);
}

.result-code.active {
    display: block;
}

/* GitHub Floating Button */
.github-float-btn {
    position: absolute;
    top: 15px;
    left: 15px;
    height: 56px;
    width: 56px;
    padding: 0;
    border-radius: 28px;
    background: var(--bg-secondary);
    border: 2px solid var(--accent-green);
    color: var(--accent-green);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    z-index: 1000;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                padding 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                gap 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                background 0.3s ease,
                color 0.3s ease,
                transform 0.3s ease,
                box-shadow 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    overflow: hidden;
    animation: slideIn 0.8s ease-out;
}

.github-float-btn.expanded {
    width: auto;
    padding: 0 20px;
    gap: 10px;
    justify-content: flex-start;
}

.github-float-btn.can-hover:hover {
    background: var(--accent-green);
    color: var(--bg-primary);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
    width: auto;
    padding: 0 20px;
}

.github-float-btn.can-hover:hover .github-float-text {
    opacity: 1;
    max-width: 200px;
}

.github-float-btn:active {
    transform: translateY(0);
}

.github-float-btn svg {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    min-width: 32px;
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.github-float-btn.expanded svg {
    width: 22px;
    height: 22px;
    min-width: 22px;
}

.github-float-text {
    font-size: 0.9em;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    max-width: 0;
    overflow: hidden;
    transition: opacity 0.5s cubic-bezier(0.4, 0, 0.2, 1),
                max-width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.github-float-btn.expanded .github-float-text {
    opacity: 1;
    max-width: 200px;
    margin-left: 4px;
}

.github-float-btn.expanded:hover {
    background: var(--accent-green);
    color: var(--bg-primary);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

/* GitHub Mini Card */
.github-mini-card {
    position: absolute;
    top: 80px;
    left: 15px;
    width: 300px;
    background: var(--bg-secondary);
    border: 2px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 999;
    opacity: 0;
    transform: translateX(-20px);
    pointer-events: none;
    transition: all 0.3s ease;
}

.github-mini-card.active {
    opacity: 1;
    transform: translateX(0);
    pointer-events: all;
}

.github-mini-content {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.github-mini-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 3px solid var(--accent-green);
    flex-shrink: 0;
}

.github-mini-info {
    flex: 1;
    min-width: 0;
}

.github-mini-name {
    font-size: 1.1em;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.github-mini-username {
    font-size: 0.9em;
    color: var(--accent-green);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.github-view-btn {
    display: block;
    width: 100%;
    padding: 12px;
    background: var(--accent-green);
    color: var(--bg-primary);
    text-align: center;
    text-decoration: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95em;
    transition: all 0.3s ease;
}

.github-view-btn:hover {
    background: #0d9668;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* GitHub Card Loading State */
.github-mini-card.loading .github-mini-avatar {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--border) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Initial animation on page load */
@keyframes slideIn {
    0% {
        transform: translateX(-100px);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive for GitHub Button */
@media (max-width: 768px) {
    .github-float-btn {
        height: 50px;
        width: 50px;
        border-radius: 25px;
        top: 8px;
        left: 12px;
    }
    
    .github-float-btn.expanded {
        padding: 0 16px;
    }
    
    .github-float-btn.can-hover:hover {
        padding: 0 16px;
    }
    
    .github-float-text {
        font-size: 0.75em;
    }
    
    .github-float-btn svg {
        width: 28px;
        height: 28px;
        min-width: 28px;
    }
    
    .github-float-btn.expanded svg {
        width: 20px;
        height: 20px;
        min-width: 20px;
    }
    
    .github-mini-card {
        width: calc(100vw - 40px);
        max-width: 300px;
        top: 66px;
        left: 12px;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .github-float-btn {
        height: 46px;
        width: 46px;
        border-radius: 23px;
        top: 6px;
        left: 10px;
    }
    
    .github-float-text {
        font-size: 0.7em;
    }
    
    .github-float-btn.expanded {
        padding: 0 14px;
    }
    
    .github-float-btn svg {
        width: 26px;
        height: 26px;
        min-width: 26px;
    }
    
    .github-float-btn.expanded svg {
        width: 18px;
        height: 18px;
        min-width: 18px;
    }
    
    .github-mini-card {
        top: 60px;
        left: 10px;
        width: calc(100vw - 30px);
    }
}

/* Footer */
.footer {
    text-align: center;
    padding: 40px 20px 20px;
    color: var(--text-muted);
    font-size: 0.9em;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 5px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--accent-blue);
}

::selection {
    background: var(--accent-blue);
    color: white;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        padding: 24px 16px;
    }
    
    .title {
        font-size: 2em;
    }
    
    .header {
        margin-bottom: 40px;
    }
    
    .section {
        padding: 20px;
    }
    
    .convert-section {
        padding: 32px 20px;
    }
    
    .convert-title {
        font-size: 1.6em;
    }
    
    .mode-options {
        grid-template-columns: 1fr;
    }
    
    .quality-options {
        grid-template-columns: 1fr;
    }
    
    .jsonl-mode-toggle {
        grid-template-columns: 1fr;
    }
    
    .input-group {
        flex-direction: column;
    }
    
    .upload-area {
        padding: 40px 24px;
    }
    
    .upload-icon {
        width: 60px;
        height: 60px;
    }
    
    .result-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .result-actions {
        width: 100%;
        flex-direction: column;
    }
    
    .result-actions .btn {
        width: 100%;
    }
    
    .result-preview,
    .result-code {
        height: 500px;
    }
}
