/* ==========================================================================
   MinuteArchivist (妙记归档员) - Premium Styling System
   ========================================================================== */

:root {
    --bg-dark: #090a0f;
    --card-bg: rgba(17, 19, 28, 0.65);
    --border-color: rgba(255, 255, 255, 0.08);
    --border-active: rgba(139, 92, 246, 0.4);
    
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;
    
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --primary-glow: rgba(139, 92, 246, 0.3);
    
    --cyan: #06b6d4;
    --cyan-hover: #0891b2;
    --cyan-glow: rgba(6, 182, 212, 0.3);
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.2);
    --error: #f43f5e;
    --error-glow: rgba(244, 63, 94, 0.2);
    --warning: #f59e0b;
    
    --font-sans: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base Reset & Typography */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    overflow-x: hidden;
    position: relative;
}

/* Background Glowing Orbs */
.bg-glow {
    position: fixed;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(160px);
    opacity: 0.12;
    pointer-events: none;
    z-index: 0;
    transition: var(--transition-smooth);
}

.bg-glow-purple {
    background: var(--primary);
    top: -200px;
    right: -100px;
}

.bg-glow-cyan {
    background: var(--cyan);
    bottom: -200px;
    left: -100px;
}

/* App Wrapper */
#app {
    position: relative;
    z-index: 1;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* View Container System */
.view-container {
    display: none;
    flex-direction: column;
    flex: 1;
    opacity: 0;
    transform: translateY(15px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.view-container.active {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

/* Glassmorphism card template */
.glassmorphism {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 18px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* ==========================================================================
   1. AUTH SCREEN
   ========================================================================== */
#auth-screen {
    justify-content: center;
    align-items: center;
    min-height: 100vh;
}

.auth-card {
    width: 100%;
    max-width: 440px;
    padding: 40px;
    text-align: center;
}

.auth-header {
    margin-bottom: 30px;
}

.logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 26px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 1px;
}

.logo-icon {
    background: linear-gradient(135deg, var(--primary), var(--cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-size: 28px;
}

.subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 3px;
    margin-top: 4px;
}

.auth-tabs {
    display: flex;
    background: rgba(255, 255, 255, 0.04);
    padding: 4px;
    border-radius: 10px;
    margin-bottom: 30px;
    border: 1px solid var(--border-color);
}

.auth-tab {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 10px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 8px;
    transition: var(--transition-smooth);
}

.auth-tab.active {
    background: var(--primary);
    color: var(--text-primary);
    box-shadow: 0 4px 12px var(--primary-glow);
}

/* Inputs & Form layout */
.input-group {
    display: flex;
    flex-direction: column;
    text-align: left;
    margin-bottom: 20px;
}

.input-group label {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-weight: 500;
}

.input-group label i {
    margin-right: 4px;
}

.input-group input {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 14px;
    outline: none;
    transition: var(--transition-smooth);
}

.input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
    background: rgba(255, 255, 255, 0.05);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 10px;
    border: none;
    cursor: pointer;
    font-family: var(--font-sans);
    transition: var(--transition-smooth);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: var(--text-primary);
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--primary-glow);
}

.btn-cyan {
    background: linear-gradient(135deg, var(--cyan), var(--cyan-hover));
    color: var(--text-primary);
    box-shadow: 0 4px 15px var(--cyan-glow);
}

.btn-cyan:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px var(--cyan-glow);
}

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

.btn-outline:hover {
    border-color: var(--text-secondary);
    color: var(--text-primary);
}

.btn-outline-success {
    background: transparent;
    border: 1px solid var(--success);
    color: var(--success);
    padding: 6px 14px;
    font-size: 12px;
}

.btn-outline-success:hover {
    background: var(--success);
    color: var(--bg-dark);
}

.btn-block {
    width: 100%;
}

.error-text {
    color: var(--error);
    font-size: 13px;
    margin-top: 15px;
    text-align: center;
}

.hidden {
    display: none !important;
}

/* ==========================================================================
   2. DASHBOARD HEADER
   ========================================================================== */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 32px;
    margin: 20px 20px 0 20px;
    border-radius: 16px;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.version-tag {
    font-size: 10px;
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-secondary);
    padding: 2px 8px;
    border-radius: 20px;
    font-weight: 500;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 24px;
}

/* Feishu status badge styling */
.feishu-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.03);
    padding: 6px 12px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
    font-size: 13px;
}

.feishu-badge.bound {
    border-color: rgba(16, 185, 129, 0.3);
    background: rgba(16, 185, 129, 0.05);
}

.feishu-icon {
    color: #3b82f6; /* Feishu Blue */
    font-size: 16px;
}

.feishu-badge.bound .feishu-icon {
    color: var(--success);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
}

.user-profile .avatar {
    font-size: 20px;
    color: var(--text-secondary);
}

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-smooth);
}

.btn-icon:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.06);
}

.btn-danger-icon:hover {
    color: var(--error);
    background: var(--error-glow);
}

/* ==========================================================================
   DASHBOARD GRID & PANELS
   ========================================================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 420px 1fr;
    gap: 20px;
    padding: 20px;
    flex: 1;
    height: calc(100vh - 120px);
}

.panel-card {
    height: 100%;
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.flex-column {
    display: flex;
    flex-direction: column;
}

h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Task creation tabs */
.task-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 24px;
}

.task-tab {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-secondary);
    padding: 12px;
    font-weight: 500;
    cursor: pointer;
    font-family: var(--font-sans);
    border-bottom: 2px solid transparent;
    transition: var(--transition-smooth);
}

.task-tab i {
    margin-right: 6px;
}

.task-tab.active {
    color: var(--text-primary);
    border-bottom-color: var(--primary);
}

/* Form switch controls */
.task-form {
    display: none;
    flex-direction: column;
    flex: 1;
}

.task-form.active {
    display: flex;
}

.form-desc {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 24px;
}

/* ASR badge status */
.asr-badge {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    background: rgba(255, 255, 255, 0.05);
    margin-left: 6px;
    border: 1px solid var(--border-color);
}

.asr-badge.whisper-ok {
    background: var(--success-glow);
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.3);
}

.asr-badge.whisper-sim {
    background: rgba(6, 182, 212, 0.08);
    color: var(--cyan);
    border-color: rgba(6, 182, 212, 0.3);
}

/* Drag and drop upload area */
.drag-drop-zone {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.01);
    margin-bottom: 20px;
    transition: var(--transition-smooth);
}

.drag-drop-zone:hover {
    border-color: var(--cyan);
    box-shadow: 0 0 15px var(--cyan-glow);
    background: rgba(6, 182, 212, 0.03);
}

.upload-icon {
    font-size: 32px;
    color: var(--text-muted);
    margin-bottom: 12px;
    transition: var(--transition-smooth);
}

.drag-drop-zone:hover .upload-icon {
    color: var(--cyan);
    transform: translateY(-3px);
}

.drag-text {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.browse-link {
    color: var(--cyan);
    font-weight: 600;
    text-decoration: underline;
}

.file-limits {
    font-size: 11px;
    color: var(--text-muted);
}

.selected-file-info {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 13px;
}

.selected-file-info i {
    color: var(--cyan);
}

.selected-file-info .file-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ==========================================================================
   TASK LIST (RIGHT PANEL)
   ========================================================================== */
.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.panel-header h3 {
    margin-bottom: 0;
}

.task-list-wrapper {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 4px;
}

/* Task list scrollbar */
.task-list-wrapper::-webkit-scrollbar {
    width: 6px;
}

.task-list-wrapper::-webkit-scrollbar-track {
    background: transparent;
}

.task-list-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.task-list-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Task cards styling */
.task-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 16px 20px;
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 12px;
    transition: var(--transition-smooth);
}

.task-card:hover {
    border-color: rgba(255, 255, 255, 0.15);
    background: rgba(255, 255, 255, 0.03);
}

.task-info-col {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0; /* allows text truncation */
}

.task-title-row {
    display: flex;
    align-items: center;
    gap: 10px;
}

.task-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Badge styles */
.badge {
    display: inline-flex;
    align-items: center;
    font-size: 10px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 4px;
    text-transform: uppercase;
}

.badge-feishu {
    background: rgba(59, 130, 246, 0.1);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.badge-local {
    background: rgba(6, 182, 212, 0.1);
    color: #22d3ee;
    border: 1px solid rgba(6, 182, 212, 0.2);
}

.task-meta-row {
    display: flex;
    gap: 16px;
    font-size: 11px;
    color: var(--text-secondary);
}

.task-meta-row span i {
    margin-right: 4px;
}

/* Progress bar container */
.task-progress-row {
    margin-top: 6px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.progress-track {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    overflow: hidden;
    position: relative;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--cyan));
    border-radius: 10px;
    width: 0%;
    transition: width 0.4s ease;
}

.progress-text {
    font-size: 11px;
    font-weight: 600;
    color: var(--cyan);
    min-width: 30px;
    text-align: right;
}

/* Status badge */
.status-indicator {
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-indicator.pending {
    color: var(--text-muted);
}
.status-indicator.processing {
    color: var(--cyan);
}
.status-indicator.completed {
    color: var(--success);
}
.status-indicator.failed {
    color: var(--error);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
}

.status-indicator.processing .status-dot {
    animation: statusPulse 1.5s infinite;
}

@keyframes statusPulse {
    0% { transform: scale(0.8); opacity: 0.5; }
    50% { transform: scale(1.2); opacity: 1; box-shadow: 0 0 8px currentColor; }
    100% { transform: scale(0.8); opacity: 0.5; }
}

.task-actions-col {
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 8px;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
}

.task-error-msg {
    grid-column: 1 / -1;
    background: rgba(244, 63, 94, 0.05);
    border: 1px solid rgba(244, 63, 94, 0.15);
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 12px;
    color: var(--error);
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 40px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 40px;
    margin-bottom: 12px;
    opacity: 0.6;
}

.empty-state p {
    font-size: 13px;
}

/* ==========================================================================
   3. WORKSPACE VIEW (SPLIT LAYOUT)
   ========================================================================== */
#workspace-screen {
    height: 100vh;
    padding: 20px;
    background: var(--bg-dark);
}

.workspace-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.workspace-title-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

#ws-task-title {
    font-size: 18px;
    font-weight: 600;
}

.workspace-split {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 20px;
    flex: 1;
    height: calc(100vh - 110px);
    overflow: hidden;
}

.workspace-left, .workspace-right {
    height: 100%;
    padding: 24px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.section-title {
    margin-bottom: 20px;
}

.section-title h3 {
    margin-bottom: 6px;
}

.section-title p {
    font-size: 12px;
    color: var(--text-secondary);
    line-height: 1.6;
}

.speaker-mapping-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-right: 4px;
    margin-bottom: 20px;
}

.speaker-mapping-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
    padding: 10px 14px;
    border-radius: 8px;
}

.speaker-mapping-item label {
    font-size: 11px;
    color: var(--cyan);
    font-weight: 600;
}

.speaker-mapping-item input {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px 12px;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 13px;
    outline: none;
}

.speaker-mapping-item input:focus {
    border-color: var(--cyan);
}

.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 12px;
}

.preview-header h3 {
    margin-bottom: 0;
}

.markdown-preview-container {
    flex: 1;
    overflow-y: auto;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 20px;
}

.markdown-preview-container pre {
    white-space: pre-wrap;
    word-break: break-all;
    font-family: 'Courier New', Courier, monospace;
    font-size: 13px;
    line-height: 1.6;
    color: var(--text-primary);
}

/* ==========================================================================
   TOAST NOTIFICATION
   ========================================================================== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(0);
    background: rgba(17, 24, 39, 0.9);
    border: 1px solid var(--primary);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 15px var(--primary-glow);
    padding: 12px 24px;
    border-radius: 50px;
    z-index: 9999;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    font-weight: 500;
    transition: opacity 0.3s, transform 0.3s;
    opacity: 1;
}

.toast.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    pointer-events: none;
}

.toast i {
    color: var(--primary);
    font-size: 16px;
}

.toast.success {
    border-color: var(--success);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 15px var(--success-glow);
}

.toast.success i {
    color: var(--success);
}

.toast.error {
    border-color: var(--error);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5), 0 0 15px var(--error-glow);
}

.toast.error i {
    color: var(--error);
}

/* ==========================================================================
   DIRECT FEISHU LOGIN BUTTON & SEPARATOR
   ========================================================================== */
.auth-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 20px 0;
    color: var(--text-muted);
    font-size: 13px;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-color);
}

.auth-divider:not(:empty)::before {
    margin-right: .5em;
}

.auth-divider:not(:empty)::after {
    margin-left: .5em;
}

.btn-feishu {
    background: #3370ff;
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(51, 112, 255, 0.3);
}

.btn-feishu:hover {
    background: #2b5fd9;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(51, 112, 255, 0.4);
    color: #ffffff;
}

/* Browser extension download button (below Feishu login) */
.btn-extension {
    background: transparent;
    color: var(--text-muted);
    border: 1px dashed var(--border-color);
    margin-top: 10px;
    font-size: 13px;
    text-decoration: none;
    transition: all 0.25s ease;
}

.btn-extension:hover {
    color: var(--text);
    border-color: #6e7681;
    background: rgba(110, 118, 129, 0.08);
    transform: translateY(-1px);
}

.btn-extension.btn-edge:hover {
    color: #0078d4;
    border-color: #0078d4;
    background: rgba(0, 120, 212, 0.12);
}

.btn-extension i {
    margin-right: 6px;
}
