:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-color: #f8fafc;
    --text-muted: #94a3b8;
    --accent: #10b981;
    --card-bg: rgba(30, 41, 59, 0.7);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', 'Noto Sans SC', system-ui, -apple-system, sans-serif;
    background: var(--bg-gradient);
    color: var(--text-color);
    min-height: 100vh;
}

.app-layout {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

.background-blobs {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.blob {
    position: absolute;
    width: 600px;
    height: 600px;
    background: var(--primary);
    filter: blur(120px);
    opacity: 0.1;
    border-radius: 50%;
    animation: move 20s infinite alternate;
}

.blob-1 {
    top: -200px;
    right: -200px;
}

.blob-2 {
    bottom: -200px;
    left: -200px;
    background: #8b5cf6;
    animation-delay: -5s;
}

.blob-3 {
    top: 40%;
    left: 30%;
    background: #06b6d4;
    animation-delay: -10s;
}

@keyframes move {
    from {
        transform: translate(0, 0) scale(1);
    }

    to {
        transform: translate(100px, 100px) scale(1.1);
    }
}

/* Sidebar */
aside {
    width: 300px;
    min-width: 300px;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(20px);
    border-right: 1px solid var(--glass-border);
    padding: 3rem 2rem;
    display: flex;
    flex-direction: column;
}

.brand {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 3rem;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.brand span {
    color: var(--primary);
}

nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.8rem 1rem;
    text-align: left;
    cursor: pointer;
    border-radius: 0.5rem;
    transition: all 0.2s;
    font-size: 1rem;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: white;
}

.nav-item.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

.logo,
.brand {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 3rem;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Main Content */
main {
    flex: 1;
    padding: 3rem;
    overflow-y: auto;
    height: 100vh;
}

.hidden {
    display: none !important;
}

header {
    margin-bottom: 3rem;
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--text-muted);
    font-size: 1.1rem;
}

.accent {
    color: var(--primary);
}

/* Glass Card */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: 1.5rem;
    padding: 2rem;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-muted);
    font-size: 0.9rem;
}

.glass-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glass-border);
    padding: 1rem;
    border-radius: 0.8rem;
    color: white;
    font-size: 1rem;
    transition: 0.3s;
    appearance: none;
    /* Remove default browser arrow */
}

select.glass-input {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='white'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M19 9l-7 7-7-7'%3E%3C/path%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 1.2rem;
    padding-right: 3rem;
    cursor: pointer;
}

select.glass-input option {
    background: #1e293b;
    color: white;
}

.glass-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

/* Buttons */
.primary-btn {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 1rem;
    border-radius: 0.8rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.3s;
}

.primary-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.primary-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* Task List */
.task-grid {
    display: grid;
    gap: 1.5rem;
}

.task-card {
    background: var(--card-bg);
    border: 1px solid var(--glass-border);
    border-radius: 1rem;
    padding: 1.5rem;
    transition: 0.3s;
    position: relative;
    overflow: hidden;
}

.task-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    border-color: var(--primary);
}

.task-info {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.task-title {
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 0.3rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 80%;
}

.task-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.badge {
    padding: 0.25rem 0.6rem;
    border-radius: 2rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.badge.pending {
    background: rgba(255, 193, 7, 0.15);
    color: #ffc107;
}

.badge.processing {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    animation: pulse 2s infinite;
}

.badge.completed {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.badge.failed {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

.progress-container {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-bar {
    height: 100%;
    background: var(--primary);
    transition: width 0.5s ease;
    border-radius: 3px;
}

.task-status-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.task-actions {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    gap: 0.5rem;
}

.action-btn {
    flex: 1;
    padding: 0.6rem;
    border: none;
    border-radius: 0.5rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: 0.2s;
    color: white;
}

.btn-docx {
    background: #2563eb;
}

.btn-docx:hover {
    background: #1d4ed8;
}

.btn-audio {
    background: #7c3aed;
}

.btn-audio:hover {
    background: #6d28d9;
}

.btn-retry {
    background: #10b981;
    flex: 2;
}

.btn-retry:hover {
    background: #059669;
}

.btn-delete {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    flex: 0 0 40px;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.btn-delete:hover {
    background: #ef4444;
    color: white;
}

.empty-state {
    text-align: center;
    padding: 4rem;
    color: var(--text-muted);
}

/* Tabs & Upload Zone */
.tabs {
    display: flex;
    gap: 1rem;
    margin-bottom: 2rem;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 0.5rem;
}

.tab-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 0.5rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    border-bottom: 2px solid transparent;
}

.tab-btn.active {
    color: white;
    border-bottom-color: var(--primary);
}

.upload-zone {
    border: 2px dashed var(--glass-border);
    border-radius: 1rem;
    padding: 3rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: rgba(0, 0, 0, 0.1);
    color: var(--text-muted);
}

.upload-zone:hover,
.upload-zone.highlight {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.02);
    color: white;
}

.file-list {
    margin: 1rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.file-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 0.8rem;
    border-radius: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.hint-text {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    text-align: center;
}

/* Chat Interface */
.chat-layout {
    display: flex;
    gap: 1.5rem;
    height: 75vh;
}

.chat-sidebar {
    width: 260px;
    display: flex;
    flex-direction: column;
    padding: 1.5rem !important;
}

.session-list {
    flex: 1;
    overflow-y: auto;
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.session-item {
    padding: 0.8rem 1rem;
    border-radius: 0.8rem;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    transition: 0.2s;
    font-size: 0.9rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-item:hover {
    background: rgba(255, 255, 255, 0.08);
}

.session-item.active {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--primary);
    color: white;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--glass-border);
}

.chat-current-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

#current-chat-title {
    font-weight: 600;
    font-size: 1.1rem;
}

.glass-input-small {
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    padding: 0.3rem 0.6rem;
    border-radius: 0.4rem;
    font-size: 0.8rem;
}

.chat-header-actions {
    display: flex;
    gap: 0.5rem;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.chat-input-area {
    margin-top: 1rem;
    display: flex;
    gap: 0.8rem;
    align-items: flex-end;
    /* Align button to bottom of textarea */
}

#chat-input {
    flex: 1;
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--glass-border);
    color: var(--text-color);
    padding: 1rem;
    border-radius: 0.8rem;
    resize: none;
    height: 70px;
    font-family: inherit;
    scrollbar-width: thin;
    scrollbar-color: var(--glass-border) transparent;
}

#btn-send-chat {
    width: 100px;
    height: 70px;
    margin-top: 0;
}

#chat-input::-webkit-scrollbar {
    width: 6px;
}

#chat-input::-webkit-scrollbar-thumb {
    background: var(--glass-border);
    border-radius: 3px;
}

#chat-input:focus {
    outline: none;
    border-color: var(--primary);
}

.icon-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    opacity: 0.7;
    transition: 0.2s;
}

.icon-btn:hover {
    opacity: 1;
    transform: scale(1.1);
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

.message.user {
    align-self: flex-end;
    align-items: flex-end;
}

.message.system {
    align-self: flex-start;
    align-items: flex-start;
}

.message.assistant {
    align-self: flex-start;
    align-items: flex-start;
}

.bubble {
    padding: 0.8rem 1rem;
    border-radius: 1rem;
    line-height: 1.5;
    word-wrap: break-word;
}

.message.user .bubble {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 0.2rem;
}

.message.system .bubble,
.message.assistant .bubble {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    border-bottom-left-radius: 0.2rem;
}

/* Thinking Process */
.think-block {
    background: rgba(0, 0, 0, 0.2);
    border-left: 3px solid var(--accent);
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: var(--text-muted);
    border-radius: 0.3rem;
    margin-top: 0.5rem;
}

.think-header {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: bold;
    user-select: none;
}

.think-content {
    margin-top: 0.5rem;
    white-space: pre-wrap;
    display: none;
    padding: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.think-block.open .think-content {
    display: block;
}

.think-icon {
    transition: transform 0.3s;
    display: inline-block;
}

.think-block.open .think-icon {
    transform: rotate(90deg);
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(5px);
}

.modal.hidden {
    display: none;
}

.modal-content {
    width: 80%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.modal-header {
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
}

.close-modal {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-muted);
    cursor: pointer;
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
    font-size: 1.1rem;
    line-height: 1.8;
    color: #e0e0e0;
    background: rgba(0, 0, 0, 0.2);
}

.modal-body p {
    margin-bottom: 1rem;
    text-align: justify;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    background: rgba(255, 255, 255, 0.05);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    border: 1px solid var(--glass-border);
    padding: 0.8rem 2rem;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.3s;
}

.secondary-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}