/* base.css - Portal Academic Styles */

:root {
    --sidebar-width: 280px;
    --sidebar-collapsed: 80px;
    --header-height: 72px;
    --tools-width: 80px;
    
    --primary-50: #f5f3ff;
    --primary-100: #ede9fe;
    --primary-200: #ddd6fe;
    --primary-300: #c4b5fd;
    --primary-400: #a78bfa;
    --primary-500: #8b5cf6;
    --primary-600: #7c3aed;
    --primary-700: #6d28d9;
    --primary-800: #5b21b6;
    --primary-900: #4c1d95;
    
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --border-color: #e5e7eb;
    
    /* Semantic Colors */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1);
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;
    --border-color: #334155;
    
    /* Semantic Colors - Dark Theme */
    --success: #34d399;
    --warning: #fbbf24;
    --danger: #f87171;
    --info: #60a5fa;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
}

/* App Container */
.app-container {
    display: grid;
    grid-template-columns: var(--sidebar-width) 1fr var(--tools-width);
    height: 100vh;
    max-height: 100vh;
    transition: var(--transition);
    max-width: 100vw;
    overflow: hidden;
}

.app-container.sidebar-collapsed {
    grid-template-columns: var(--sidebar-collapsed) 1fr var(--tools-width);
}

/* Sidebar */
.sidebar {
    background: var(--bg-primary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-height: 100vh;
    overflow-y: auto;
    overflow-x: visible;
    position: sticky;
    top: 0;
    z-index: 1000;
}

.sidebar-header {
    height: var(--header-height);
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid var(--border-color);
    position: relative;
    overflow: hidden;
}

.sidebar-toggle {
    position: fixed;
    left: calc(var(--sidebar-width) - 12px);
    top: calc((var(--header-height) - 24px) / 2);
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary-600);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    box-shadow: var(--shadow-md);
    transition: left 0.3s ease;
}

.sidebar-toggle:hover {
    background: var(--primary-700);
}

.sidebar-toggle i {
    width: 14px;
    height: 14px;
    transition: transform 0.3s ease;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--primary-600);
}

.logo i {
    width: 32px;
    height: 32px;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px 12px;
    min-height: 0;
}

.nav-section {
    margin-bottom: 24px;
}

.nav-label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    padding: 0 12px;
    margin-bottom: 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 4px;
}

.nav-item:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.nav-item.active {
    background: var(--primary-50);
    color: var(--primary-700);
    font-weight: 600;
}

.nav-item i {
    width: 20px !important;
    height: 20px !important;
    flex-shrink: 0;
}

/* Main Content */
.main-content {
    height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 100%;
    overflow: hidden;
}

/* Header */
.top-header {
    height: var(--header-height);
    min-height: var(--header-height);
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 50;
    gap: 24px;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    min-width: 0;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-md);
    flex-shrink: 0;
}

.mobile-menu-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.breadcrumb {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
    padding: 8px 14px;
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    background: var(--bg-secondary);
    font-size: 0.9375rem;
    color: var(--text-secondary);
    line-height: 1;
}

.breadcrumb a,
.breadcrumb span {
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.breadcrumb a {
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s ease;
}

.breadcrumb a:hover {
    color: var(--text-primary);
}

.breadcrumb span {
    color: var(--text-primary);
    font-weight: 600;
}

.breadcrumb i,
.breadcrumb svg {
    width: 14px;
    height: 14px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.header-center {
    flex: 1;
    max-width: 600px;
}

.global-search {
    position: relative;
    display: flex;
    align-items: center;
    flex: 1;
    max-width: 600px;
    min-width: 280px;
}

.global-search i,
.global-search svg {
    position: absolute;
    left: 16px;
    color: var(--text-tertiary);
    width: 20px;
    height: 20px;
    pointer-events: none;
    z-index: 1;
}

.global-search input {
    width: 100%;
    padding: 12px 100px 12px 48px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    background: var(--bg-secondary);
    font-size: 0.9375rem;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.global-search input:hover {
    background: var(--bg-primary);
    border-color: var(--primary-300);
}

.global-search input:focus {
    outline: none;
    border-color: var(--primary-500);
    background: var(--bg-primary);
    box-shadow: 0 0 0 4px var(--primary-100), 0 4px 12px rgba(0, 0, 0, 0.08);
}

.global-search input::placeholder {
    color: var(--text-tertiary);
}

.global-search kbd {
    position: absolute;
    right: 12px;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    padding: 4px 8px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-tertiary);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
}

.global-search kbd:first-of-type {
    right: 42px;
}

/* Global Search Dropdown */
.global-search-dropdown {
    position: fixed;
    top: auto;
    left: auto;
    right: auto;
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.35), 0 10px 30px rgba(0, 0, 0, 0.2);
    max-height: 500px;
    overflow-y: auto;
    z-index: 10000;
    display: none;
    border: 1px solid var(--border-color);
    min-width: 400px;
    max-width: min(600px, calc(100vw - 40px));
    backdrop-filter: blur(20px);
    background: rgba(255, 255, 255, 0.98);
}

.global-search-dropdown.show {
    display: block;
    animation: globalDropdownFadeIn 0.2s ease;
}

@keyframes globalDropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.global-search-section {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.global-search-section:last-of-type {
    border-bottom: none;
}

.global-search-section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-tertiary);
    background: var(--bg-secondary);
}

.global-search-section-header i,
.global-search-section-header svg {
    width: 14px;
    height: 14px;
}

.global-search-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.15s ease;
    text-decoration: none;
    color: inherit;
    border-left: 3px solid transparent;
}

.global-search-item:hover {
    background: var(--bg-secondary);
    border-left-color: var(--primary-500);
}

.global-search-item.selected {
    background: var(--primary-50);
    border-left-color: var(--primary-500);
}

.global-search-item-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

.global-search-item-icon i,
.global-search-item-icon svg {
    width: 20px;
    height: 20px;
}

.global-search-item-icon.page-icon {
    background: linear-gradient(135deg, var(--primary-100), var(--primary-200));
    color: var(--primary-600);
}

.global-search-item-icon.settings-icon {
    background: linear-gradient(135deg, #dbeafe, #bfdbfe);
    color: #2563eb;
}

.global-search-item-icon.tool-icon {
    background: linear-gradient(135deg, #fef3c7, #fde68a);
    color: #d97706;
}

.global-search-item-icon.file-icon {
    background: linear-gradient(135deg, #d1fae5, #a7f3d0);
    color: #059669;
}

.global-search-item-icon.quiz-icon {
    background: linear-gradient(135deg, #fce7f3, #fbcfe8);
    color: #db2777;
}

.global-search-item-icon.subject-icon {
    background: linear-gradient(135deg, #e0e7ff, #c7d2fe);
    color: #4f46e5;
}

.global-search-item-icon.update-icon {
    background: linear-gradient(135deg, #dcfce7, #bbf7d0);
    color: #15803d;
}

.global-search-item-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.global-search-item-title {
    font-weight: 500;
    font-size: 0.9375rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.global-search-item-subtitle {
    font-size: 0.8125rem;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.global-search-item-arrow {
    color: var(--text-tertiary);
    opacity: 0;
    transition: opacity 0.15s ease;
}

.global-search-item:hover .global-search-item-arrow {
    opacity: 1;
}

.global-search-empty {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    gap: 12px;
    color: var(--text-tertiary);
    text-align: center;
}

.global-search-empty i,
.global-search-empty svg {
    width: 48px;
    height: 48px;
    opacity: 0.5;
}

.global-search-loading {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    gap: 16px;
}

.global-search-loading .spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-500);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.animate-spin {
    animation: spin 0.8s linear infinite;
}

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

.global-search-shortcuts {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    font-size: 0.75rem;
    color: var(--text-tertiary);
    justify-content: center;
}

.global-search-shortcuts kbd {
    font-family: inherit;
    padding: 2px 6px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.6875rem;
}

/* Highlight matching text */
.global-search-item-title mark {
    background: var(--primary-200);
    color: var(--primary-800);
    padding: 0 2px;
    border-radius: 2px;
    font-weight: 600;
}

/* Responsive */
@media (max-width: 768px) {
    .global-search {
        min-width: auto;
        max-width: 100%;
    }
    
    .global-search input {
        padding-right: 16px;
    }
    
    .global-search kbd {
        display: none;
    }
    
    .global-search-dropdown {
        left: 10px !important;
        right: 10px !important;
        width: calc(100vw - 20px) !important;
        min-width: auto !important;
        max-width: calc(100vw - 20px) !important;
    }
}

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

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: none;
    background: none;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.icon-btn:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

/* User Menu */
.user-menu {
    position: relative;
}

.user-trigger {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    border-radius: var(--radius-lg);
    border: none;
    background: none;
    cursor: pointer;
    transition: var(--transition);
}

.user-trigger:hover {
    background: var(--bg-secondary);
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-600);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

.user-info {
    text-align: left;
    line-height: 1.2;
}

.user-name {
    display: block;
    font-size: 0.9375rem;
    font-weight: 600;
    color: var(--text-primary);
}

.user-role {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.user-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-xl);
    min-width: 200px;
    padding: 8px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: var(--transition);
}

.user-menu.active .user-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-dropdown a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.9375rem;
    transition: var(--transition);
}

.user-dropdown a:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.user-dropdown .separator {
    height: 1px;
    background: var(--border-color);
    margin: 8px 0;
}

/* Page Content */
.page-content {
    flex: 1;
    padding: 32px;
    overflow-y: auto;
    overflow-x: hidden;
    max-height: calc(100vh - var(--header-height));
}

/* Tools Panel - Simplified */
.tools-panel {
    background: var(--bg-primary) !important;
    border-left: 1px solid var(--border-color) !important;
    padding: 16px 12px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 16px !important;
    position: sticky !important;
    top: 0 !important;
    height: 100vh !important;
    max-height: 100vh !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    width: var(--tools-width) !important;
    min-width: var(--tools-width) !important;
    box-sizing: border-box !important;
}

.tools-header {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding-bottom: 12px !important;
    border-bottom: 1px solid var(--border-color) !important;
    width: 100% !important;
    justify-content: center !important;
    box-sizing: border-box !important;
}

.tools-header i {
    width: 18px !important;
    height: 18px !important;
    color: var(--primary-600) !important;
    flex-shrink: 0 !important;
}

.tools-header span {
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: var(--text-secondary) !important;
    white-space: nowrap !important;
}

.tools-group {
    display: flex !important;
    flex-direction: column !important;
    gap: 8px !important;
    align-items: center !important;
    width: 100% !important;
}

.tools-group-label {
    font-size: 0.65rem !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    color: var(--text-tertiary) !important;
    text-align: center !important;
    width: 100% !important;
}

.tool-btn {
    width: 48px !important;
    height: 48px !important;
    border-radius: var(--radius-lg) !important;
    border: 1px solid var(--border-color) !important;
    background: var(--bg-primary) !important;
    color: var(--text-secondary) !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    transition: var(--transition) !important;
    position: relative !important;
    box-sizing: border-box !important;
    padding: 0 !important;
    margin: 0 !important;
}

.tool-btn:hover {
    border-color: var(--tool-color, var(--primary-500));
    background: var(--bg-secondary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.tool-btn:hover i {
    color: var(--tool-color, var(--primary-600));
}

.tool-btn i {
    width: 22px !important;
    height: 22px !important;
    transition: color 0.2s !important;
    flex-shrink: 0 !important;
}

.tool-btn::after {
    content: attr(title);
    position: absolute;
    right: calc(100% + 10px);
    top: 50%;
    transform: translateY(-50%);
    background: var(--gray-800);
    color: white;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
    pointer-events: none;
    z-index: 1000;
}

.tool-btn:hover::after {
    opacity: 1;
    visibility: visible;
}

/* Tool Modal */
.tool-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.tool-modal {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 600px;
    height: 80vh;
    max-height: 700px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

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

.tool-modal-header {
    height: 56px;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
    flex-shrink: 0;
}

.tool-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    font-weight: 600;
}

.tool-title i {
    width: 22px;
    height: 22px;
}

.tool-close {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    border: 1px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.1);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.tool-close:hover {
    background: rgba(255,255,255,0.2);
}

.tool-modal-body {
    flex: 1;
    overflow: hidden;
    position: relative;
}

/* Calculator Styles */
.tool-calc {
    padding: 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: var(--bg-secondary);
}

.calc-display {
    background: var(--bg-primary);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 16px;
    text-align: right;
    font-size: 2.2rem;
    font-family: 'SF Mono', monospace;
    color: var(--text-primary);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
    min-height: 70px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    overflow-x: auto;
}

.calc-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    flex: 1;
}

.calc-grid button {
    padding: 16px;
    border: none;
    border-radius: 10px;
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 1.3rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.08);
}

.calc-grid button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.12);
}

.calc-grid button:active {
    transform: translateY(0);
}

.calc-grid button.zero {
    grid-column: span 2;
}

.calc-grid button.op {
    background: #e0e7ff;
    color: #4f46e5;
}

.calc-grid button.eq {
    background: #8b5cf6;
    color: white;
}

.calc-grid button.c {
    background: #fee2e2;
    color: #dc2626;
}

/* Translator Styles */
.tool-translator {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg-primary);
}

.trans-langs {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    justify-content: center;
}

.trans-langs select {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background: var(--bg-secondary);
    font-size: 0.9375rem;
}

.trans-langs button {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border-color);
    border-radius: 50%;
    background: var(--bg-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tool-translator textarea {
    flex: 1;
    padding: 16px;
    border: none;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
    font-size: 1rem;
    resize: none;
    outline: none;
}

.trans-btn {
    margin: 12px 16px;
    padding: 12px;
    background: var(--primary-600);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.trans-output {
    flex: 1;
    padding: 16px;
    background: var(--bg-secondary);
    overflow-y: auto;
}

/* Whiteboard Styles */
.tool-whiteboard {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: white;
}

.wb-tools {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.wb-tools button.color {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    cursor: pointer;
}

.wb-tools button.clear {
    margin-left: auto;
    padding: 8px 14px;
    background: #fee2e2;
    color: #dc2626;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

.tool-whiteboard canvas {
    flex: 1;
    cursor: crosshair;
}

/* Dictionary Styles */
.tool-dict {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg-primary);
}

.dict-search {
    display: flex;
    gap: 8px;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.dict-search input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
}

.dict-search button {
    padding: 12px 20px;
    background: var(--primary-600);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
}

.dict-result {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

/* Toast */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 14px 20px;
    box-shadow: var(--shadow-xl);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.toast.success { border-left: 4px solid #10b981; }
.toast.error { border-left: 4px solid #ef4444; }
.toast.info { border-left: 4px solid #3b82f6; }

/* Button Styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: var(--primary-700);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

.btn-secondary:hover {
    background: var(--bg-tertiary);
    border-color: var(--gray-300);
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
}

.btn-ghost:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.875rem;
}

.btn-lg {
    padding: 14px 28px;
    font-size: 1rem;
}

/* Form Elements */
.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 0.9375rem;
    transition: var(--transition);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-400);
    box-shadow: 0 0 0 3px var(--primary-100);
}

/* Hero Section - Ensures visibility in both modes */
.hero {
    position: relative;
    padding: 48px;
    border-radius: var(--radius-xl);
    margin-bottom: 32px;
    overflow: hidden;
    background: linear-gradient(135deg, var(--primary-600), var(--primary-800));
    color: white;
}

.hero-bg {
    position: absolute;
    inset: 0;
    opacity: 0.1;
    background-image: 
        radial-gradient(circle at 20% 50%, white 1px, transparent 1px),
        radial-gradient(circle at 80% 50%, white 1px, transparent 1px);
    background-size: 40px 40px;
}

.hero-content {
    position: relative;
    z-index: 1;
}

.hero-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: rgba(255,255,255,0.15);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 9999px;
    font-size: 0.875rem;
    font-weight: 600;
    margin-bottom: 24px;
    border: 1px solid rgba(255,255,255,0.2);
}

.hero h1 {
    font-size: 3rem;
    font-weight: 800;
    margin-bottom: 16px;
    line-height: 1.1;
    color: white;
}

.hero p {
    font-size: 1.25rem;
    opacity: 0.9;
    margin-bottom: 32px;
    color: rgba(255,255,255,0.9);
}

.hero-search {
    position: relative;
    display: flex;
    gap: 12px;
    max-width: 500px;
}

.hero-search > i {
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    width: 20px;
    height: 20px;
    z-index: 2;
}

.hero-search input {
    flex: 1;
    padding: 16px 20px 16px 52px;
    border-radius: var(--radius-lg);
    border: none;
    font-size: 1rem;
    background: white;
    color: var(--text-primary);
    box-shadow: var(--shadow-lg);
}

.hero-search input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.3);
}

.hero-search .btn {
    padding: 16px 28px;
    background: white;
    color: var(--primary-600);
    border: none;
    border-radius: var(--radius-lg);
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-lg);
}

/* Collapsed Sidebar Fix */
.app-container.sidebar-collapsed .logo-text,
.app-container.sidebar-collapsed .nav-label,
.app-container.sidebar-collapsed .nav-item span {
    display: none;
}

.app-container.sidebar-collapsed .nav-item {
    justify-content: center;
    padding: 12px;
}

.app-container.sidebar-collapsed .sidebar-header {
    justify-content: center;
}

.app-container.sidebar-collapsed .sidebar-toggle {
    left: calc(var(--sidebar-collapsed) - 12px);
}

.app-container.sidebar-collapsed .sidebar-toggle i {
    transform: rotate(180deg);
}

/* Responsive */
@media (max-width: 1200px) {
    /* Keep tools column visible on medium screens so the toolbar
       does not disappear when the browser window is resized or zoomed. */
    .app-container {
        grid-template-columns: var(--sidebar-width) 1fr var(--tools-width);
    }
    
    .tools-panel {
        display: flex;
    }
}

/* Mobile layout rules moved to mobile.css (loaded last) */

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

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

::-webkit-scrollbar-thumb {
    background: var(--gray-300);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-400);
}

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay[style*="flex"] {
    display: flex;
}

/* Modal Content */
.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary);
}

.modal-title i {
    width: 24px;
    height: 24px;
    color: var(--primary-600);
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

/* Utility Classes */
.card {
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.loading {
    color: var(--text-tertiary);
    font-style: italic;
}

/* Loading States */
.loading-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px;
    color: var(--text-secondary);
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border-color);
    border-top-color: var(--primary-600);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

/* Empty State */
.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 60px 40px;
    color: var(--text-secondary);
}

.empty-state i {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
    color: var(--text-tertiary);
}

.empty-state h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.empty-state p {
    font-size: 0.9375rem;
    color: var(--text-secondary);
}

/* Skeleton Loading */
.skeleton {
    background: linear-gradient(90deg, var(--bg-tertiary) 25%, var(--bg-secondary) 50%, var(--bg-tertiary) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: var(--radius-md);
}

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

.skeleton-text {
    height: 16px;
    background: var(--bg-tertiary);
    border-radius: 4px;
    margin-bottom: 8px;
}

.skeleton-text.short {
    width: 60%;
}

/* Calculator Widget Styles */
.calculator-widget {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 400px;
    height: 600px;
    background: var(--bg-primary);
    border-radius: var(--radius-xl);
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.35);
    z-index: 10000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.calculator-widget.minimized {
    width: 300px;
    height: 68px;
    border-radius: 36px;
}

.calculator-widget-header {
    height: 56px;
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: move;
    user-select: none;
    flex-shrink: 0;
}

.calculator-widget-title {
    display: flex;
    align-items: center;
    gap: 10px;
    color: white;
    font-weight: 600;
    font-size: 1rem;
}

.calculator-widget-controls {
    display: flex;
    gap: 8px;
}

.calculator-widget-btn {
    width: 28px;
    height: 28px;
    border-radius: 8px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    transition: all 0.2s;
}

.calculator-widget-btn:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.1);
}

.calculator-widget-body {
    flex: 1;
    overflow: hidden;
}

.calculator-widget-body iframe {
    width: 100%;
    height: 100%;
    border: none;
}

#tool-widgets {
    position: fixed;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    z-index: 10000;
    pointer-events: none;
}

#tool-widgets > * {
    pointer-events: all;
}

/* Calculator Widget Internal Styles */
.calc-embedded {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg-primary);
}

.calc-tabs {
    display: flex;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.calc-tab {
    flex: 1;
    padding: 12px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.calc-tab.active {
    color: var(--primary-600);
    border-bottom: 2px solid var(--primary-600);
}

.calc-display {
    padding: 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
}

.calc-display-value {
    font-size: 2.5rem;
    font-weight: 300;
    text-align: right;
    color: var(--text-primary);
    font-family: 'JetBrains Mono', monospace;
}

.calc-buttons {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    padding: 16px;
    flex: 1;
}

.calc-btn {
    height: 60px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1.25rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.calc-btn.num {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.calc-btn.num:hover {
    background: var(--bg-tertiary);
}

.calc-btn.op {
    background: var(--primary-100);
    color: var(--primary-600);
}

.calc-btn.op:hover {
    background: var(--primary-200);
}

.calc-btn.clear {
    background: #fee2e2;
    color: #dc2626;
}

.calc-btn.clear:hover {
    background: #fecaca;
}

.calc-btn.equals {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    color: white;
}

.calc-btn.equals:hover {
    filter: brightness(1.1);
}

.calc-btn.zero {
    grid-column: span 2;
}
