/* ========================================
   DocuVault - CSS Stylesheet
   Modern, responsive document management UI
   Dark Mode Default
   ======================================== */

/* ===== CSS Variables - Dark Mode Default ===== */
:root {
    /* Colors */
    --color-primary: #3b82f6;
    --color-primary-dark: #2563eb;
    --color-primary-light: #60a5fa;
    --color-secondary: #6b7280;
    --color-success: #10b981;
    --color-danger: #ef4444;
    --color-warning: #f59e0b;
    --color-info: #06b6d4;
    
    /* Dark Mode Colors */
    --color-bg: #0f172a;
    --color-surface: #1e293b;
    --color-surface-hover: #334155;
    --color-border: #334155;
    --color-text: #f1f5f9;
    --color-text-muted: #94a3b8;
    --color-text-light: #64748b;
    
    /* Sidebar */
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 70px;
    --sidebar-bg: #1e293b;
    --sidebar-text: #e2e8f0;
    --sidebar-active: #3b82f6;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    
    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    --font-size-sm: 0.875rem;
    --font-size-md: 1rem;
    --font-size-lg: 1.25rem;
    --font-size-xl: 1.5rem;
    
    /* Effects */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.5);
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition: all 0.2s ease;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    font-size: var(--font-size-md);
    line-height: 1.5;
    color: var(--color-text);
    background: var(--color-bg);
    min-height: 100vh;
}

a {
    color: var(--color-primary);
    text-decoration: none;
}

a:hover {
    color: var(--color-primary-dark);
}

/* ===== Login Screen ===== */
.auth-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--sidebar-bg) 0%, #0f172a 100%);
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: var(--spacing-xl);
}

.auth-logo {
    text-align: center;
    margin-bottom: var(--spacing-xl);
    color: white;
}

.auth-logo .logo-icon {
    font-size: 4rem;
    display: block;
    margin-bottom: var(--spacing-sm);
}

.auth-logo h1 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: var(--spacing-xs);
}

.auth-logo p {
    color: var(--color-text-light);
}

.auth-form {
    background: var(--color-surface);
    padding: var(--spacing-xl);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
}

/* ===== Form Elements ===== */
.form-group {
    margin-bottom: var(--spacing-md);
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: var(--spacing-xs);
    color: var(--color-text);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-md);
    font-family: inherit;
    transition: var(--transition);
    background: var(--color-surface);
    color: var(--color-text);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--color-text-muted);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.form-group input[type="color"] {
    height: 45px;
    padding: 5px;
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

.form-hint {
    display: block;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-top: var(--spacing-xs);
}

.input-group {
    display: flex;
    gap: var(--spacing-sm);
}

.input-group input {
    flex: 1;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    cursor: pointer;
}

.checkbox-label input[type="checkbox"] {
    width: auto;
    margin: 0;
}

.form-message {
    padding: var(--spacing-sm);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    margin-bottom: var(--spacing-md);
    display: none;
}

.form-message.error {
    display: block;
    background: rgba(239, 68, 68, 0.2);
    color: var(--color-danger);
    border: 1px solid var(--color-danger);
}

.form-message.success {
    display: block;
    background: rgba(16, 185, 129, 0.2);
    color: var(--color-success);
    border: 1px solid var(--color-success);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: var(--radius-sm);
    font-size: var(--font-size-md);
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--color-primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: var(--color-primary-dark);
}

.btn-secondary {
    background: var(--color-secondary);
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #5a6268;
}

.btn-danger {
    background: var(--color-danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #c0392b;
}

.btn-success {
    background: var(--color-success);
    color: white;
}

.btn-block {
    width: 100%;
}

.btn .btn-loading {
    display: none;
}

.btn.loading .btn-text {
    display: none;
}

.btn.loading .btn-loading {
    display: inline;
}

.btn-icon {
    background: transparent;
    border: none;
    padding: var(--spacing-sm);
    cursor: pointer;
    border-radius: var(--radius-sm);
    font-size: 1.25rem;
    transition: var(--transition);
}

.btn-icon:hover {
    background: rgba(0,0,0,0.05);
}

.link {
    color: var(--color-primary);
    cursor: pointer;
}

.link:hover {
    text-decoration: underline;
}

/* ===== App Layout ===== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 100;
    transition: width 0.3s ease;
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar.collapsed .logo-text,
.sidebar.collapsed .nav-text,
.sidebar.collapsed .user-name {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
}

.sidebar.collapsed .nav-item {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-lg);
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header .logo-icon {
    font-size: 1.75rem;
}

.sidebar-header .logo-text {
    font-size: var(--font-size-lg);
    font-weight: 700;
}

.sidebar-toggle {
    margin-left: auto;
    background: transparent;
    border: none;
    color: var(--sidebar-text);
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--radius-sm);
}

.sidebar-toggle:hover {
    background: rgba(255,255,255,0.1);
}

.sidebar-nav {
    flex: 1;
    padding: var(--spacing-md) 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: 0.875rem var(--spacing-lg);
    color: var(--sidebar-text);
    transition: var(--transition);
    text-decoration: none;
}

.nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}

.nav-item.active {
    background: var(--sidebar-active);
    color: white;
}

.nav-icon {
    font-size: 1.25rem;
    width: 28px;
    text-align: center;
}

.nav-badge {
    margin-left: auto;
    background: var(--color-danger);
    color: white;
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.nav-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: var(--spacing-md) var(--spacing-lg);
}

.sidebar-footer {
    padding: var(--spacing-md) var(--spacing-lg);
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-sm);
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: var(--color-primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: var(--font-size-sm);
}

.user-name {
    font-size: var(--font-size-sm);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-actions {
    display: flex;
    gap: var(--spacing-sm);
}

.user-actions .btn-icon {
    color: var(--sidebar-text);
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: var(--spacing-lg);
    transition: margin-left 0.3s ease;
    min-height: 100vh;
}

.sidebar.collapsed + .main-content {
    margin-left: var(--sidebar-collapsed-width);
}

/* ===== Views ===== */
.view {
    display: none;
}

.view.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.view-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-lg);
}

.view-header h1 {
    font-size: var(--font-size-xl);
    font-weight: 600;
}

.header-actions {
    display: flex;
    gap: var(--spacing-sm);
}

/* ===== Dashboard ===== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-lg);
    margin-bottom: var(--spacing-xl);
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    box-shadow: var(--shadow-sm);
}

.stat-icon {
    font-size: 2.5rem;
}

.stat-value {
    display: block;
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--color-text);
}

.stat-label {
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
}

.dashboard-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: var(--spacing-lg);
}

.card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--color-border);
}

.card-header h3 {
    font-size: var(--font-size-md);
    font-weight: 600;
}

.card-body {
    padding: var(--spacing-lg);
}

/* ===== Scan Status Card ===== */
.scan-status-card {
    margin-bottom: var(--spacing-lg);
}

.scan-status-card .card-header {
    background: var(--color-surface-hover);
}

.scan-status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--spacing-md);
}

.scan-info {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.scan-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.scan-value {
    font-weight: 600;
    color: var(--color-text);
}

.scan-value.success {
    color: var(--color-success);
}

.scan-value.error {
    color: var(--color-danger);
}

.scan-value.running {
    color: var(--color-warning);
}

.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: var(--font-size-sm);
}

/* ===== Toolbar ===== */
.toolbar {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    flex-wrap: wrap;
}

.search-box {
    display: flex;
    flex: 1;
    max-width: 400px;
}

.search-box input {
    flex: 1;
    padding: 0.625rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    font-size: var(--font-size-md);
    background: var(--color-surface);
    color: var(--color-text);
}

.search-box input::placeholder {
    color: var(--color-text-muted);
}

.search-box input:focus {
    outline: none;
    border-color: var(--color-primary);
}

.search-box .search-btn {
    padding: 0.625rem 1rem;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    cursor: pointer;
}

.filter-group {
    display: flex;
    gap: var(--spacing-sm);
}

.filter-group select {
    padding: 0.625rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
}

.filter-group select:focus {
    outline: none;
    border-color: var(--color-primary);
}

.view-toggle {
    display: flex;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-sm);
}

.view-toggle .btn-icon {
    border-radius: 0;
}

.view-toggle .btn-icon.active {
    background: var(--color-primary);
    color: white;
}

/* ===== Bulk Actions ===== */
.bulk-actions {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md);
    background: var(--color-primary-light);
    color: white;
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-lg);
}

.selected-count {
    font-weight: 500;
}

/* ===== Documents Grid ===== */
.documents-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: var(--spacing-lg);
}

.documents-grid.list-view {
    grid-template-columns: 1fr;
    gap: var(--spacing-sm);
}

.document-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.document-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.document-card.selected {
    outline: 2px solid var(--color-primary);
}

.document-card .card-checkbox {
    position: absolute;
    top: var(--spacing-sm);
    left: var(--spacing-sm);
    z-index: 2;
    opacity: 0;
    transition: opacity 0.2s;
}

.document-card:hover .card-checkbox,
.document-card.selected .card-checkbox {
    opacity: 1;
}

.document-thumbnail {
    height: 140px;
    background: var(--color-bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3rem;
    overflow: hidden;
    position: relative;
}

.document-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: white;
}

.document-thumbnail .pdf-preview {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: white;
}

.document-thumbnail .file-icon {
    font-size: 3rem;
    opacity: 0.6;
}

.document-info {
    padding: var(--spacing-md);
}

.document-title {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: var(--spacing-xs);
    font-size: 0.85rem;
}

.document-summary {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: var(--spacing-xs);
    line-height: 1.4;
    min-height: 4.2em;
}

.document-meta {
    display: flex;
    justify-content: space-between;
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.document-category {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
    background: var(--color-primary-light);
    color: white;
}

/* List View */
.documents-grid.list-view .document-card {
    display: flex;
    align-items: center;
}

.documents-grid.list-view .document-thumbnail {
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.documents-grid.list-view .document-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: var(--spacing-lg);
}

.documents-grid.list-view .document-title {
    flex: 1;
    margin-bottom: 0;
}

/* ===== Categories Grid ===== */
.categories-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: var(--spacing-lg);
}

.category-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--color-primary);
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-md);
}

.category-icon {
    font-size: 2rem;
}

.category-content {
    flex: 1;
}

.category-name {
    font-weight: 600;
    margin-bottom: var(--spacing-xs);
}

.category-description {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-bottom: var(--spacing-sm);
}

.category-count {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.category-actions {
    display: flex;
    gap: var(--spacing-xs);
}

/* ===== Detail Panel ===== */
.detail-panel {
    position: fixed;
    right: -450px;
    top: 0;
    bottom: 0;
    width: 450px;
    background: var(--color-surface);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.detail-panel.open {
    right: 0;
}

.detail-panel .panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--color-border);
}

.detail-panel .panel-header h2 {
    font-size: var(--font-size-lg);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.detail-panel .panel-body {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-lg);
}

.document-preview {
    background: var(--color-surface-hover);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
    margin-bottom: var(--spacing-lg);
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.document-preview img,
.document-preview embed,
.document-preview iframe {
    max-width: 100%;
    max-height: 400px;
}

.document-meta h3 {
    font-size: var(--font-size-md);
    margin-bottom: var(--spacing-md);
}

.document-meta dl {
    display: grid;
    grid-template-columns: 120px 1fr;
    gap: var(--spacing-sm);
}

.document-meta dt {
    font-weight: 500;
    color: var(--color-text-muted);
}

.document-meta dd {
    word-break: break-word;
}

.document-actions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-lg);
    padding-top: var(--spacing-lg);
    border-top: 1px solid var(--color-border);
}

/* ===== Modals ===== */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 300;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-backdrop.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    z-index: 301;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.modal.modal-small {
    max-width: 400px;
}

.modal.modal-large {
    max-width: 700px;
}

/* Fullscreen Modal */
.modal.modal-fullscreen {
    width: 95vw;
    height: 95vh;
    max-width: none;
    max-height: none;
    display: flex;
    flex-direction: column;
}

.modal.modal-fullscreen .modal-body {
    flex: 1;
    overflow: hidden;
    padding: 0;
}

.doc-view-body {
    display: flex;
    height: 100%;
}

.doc-view-main {
    flex: 1;
    background: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.doc-view-preview {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.doc-view-preview embed,
.doc-view-preview iframe {
    width: 100%;
    height: 100%;
    border: none;
}

.doc-view-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.doc-view-sidebar {
    width: 350px;
    background: var(--color-bg-secondary);
    border-left: 1px solid var(--color-border);
    overflow-y: auto;
    padding: var(--spacing-lg);
}

.doc-view-section {
    margin-bottom: var(--spacing-lg);
    padding-bottom: var(--spacing-lg);
    border-bottom: 1px solid var(--color-border);
}

.doc-view-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.doc-view-section h3 {
    font-size: var(--font-size-md);
    margin-bottom: var(--spacing-md);
    color: var(--color-text);
}

.doc-details-list {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: var(--spacing-xs) var(--spacing-md);
    font-size: var(--font-size-sm);
}

.doc-details-list dt {
    color: var(--color-text-muted);
}

.doc-details-list dd {
    color: var(--color-text);
    word-break: break-word;
}

.doc-summary-text {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    line-height: 1.6;
}

.doc-tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: var(--spacing-xs);
}

.doc-tag {
    display: inline-block;
    padding: 4px 10px;
    background: var(--color-bg-tertiary);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.doc-view-actions .action-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.btn-block {
    width: 100%;
    justify-content: flex-start;
    text-align: left;
}

@media (max-width: 900px) {
    .doc-view-body {
        flex-direction: column;
    }
    
    .doc-view-sidebar {
        width: 100%;
        max-height: 50vh;
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--color-border);
}

.modal-header h2 {
    font-size: var(--font-size-lg);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    padding: var(--spacing-xs);
    color: var(--color-text-muted);
}

.modal-close:hover {
    color: var(--color-text);
}

.modal-body {
    padding: var(--spacing-lg);
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-sm);
    padding: var(--spacing-lg);
    border-top: 1px solid var(--color-border);
}

/* ===== Upload Area ===== */
.upload-area {
    border: 2px dashed var(--color-border);
    border-radius: var(--radius-md);
    padding: var(--spacing-xl);
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--color-primary);
    background: rgba(52, 152, 219, 0.05);
}

.upload-icon {
    font-size: 3rem;
    margin-bottom: var(--spacing-md);
}

.upload-hint {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    margin-top: var(--spacing-sm);
}

.upload-queue {
    margin-top: var(--spacing-lg);
}

.upload-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm);
    background: var(--color-surface-hover);
    border-radius: var(--radius-sm);
    margin-bottom: var(--spacing-sm);
}

.upload-item-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upload-item-status {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

.upload-item-progress {
    width: 100px;
    height: 6px;
    background: var(--color-border);
    border-radius: 3px;
    overflow: hidden;
}

.upload-item-progress-bar {
    height: 100%;
    background: var(--color-primary);
    transition: width 0.3s;
}

/* ===== Admin Panels ===== */
.admin-tabs {
    display: flex;
    gap: var(--spacing-sm);
    margin-bottom: var(--spacing-lg);
    border-bottom: 2px solid var(--color-border);
    padding-bottom: var(--spacing-sm);
    flex-wrap: wrap;
}

.tab-btn {
    padding: 0.5rem 1rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: var(--font-size-md);
    color: var(--color-text-muted);
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
    transition: var(--transition);
}

.tab-btn:hover {
    color: var(--color-text);
}

.tab-btn.active {
    color: var(--color-primary);
    border-bottom: 2px solid var(--color-primary);
    margin-bottom: -2px;
}

.admin-panel {
    display: none;
}

.admin-panel.active {
    display: block;
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--spacing-lg);
}

.panel-header h3 {
    font-size: var(--font-size-lg);
}

/* ===== Tables ===== */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--color-surface);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.data-table th,
.data-table td {
    padding: var(--spacing-md);
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

.data-table th {
    background: var(--color-surface-hover);
    font-weight: 600;
    white-space: nowrap;
}

.data-table tr:hover td {
    background: rgba(52, 152, 219, 0.05);
}

.status-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.status-badge.active {
    background: rgba(16, 185, 129, 0.2);
    color: var(--color-success);
}

.status-badge.inactive {
    background: rgba(239, 68, 68, 0.2);
    color: var(--color-danger);
}

/* ===== Pagination ===== */
.pagination {
    display: flex;
    justify-content: center;
    gap: var(--spacing-xs);
    margin-top: var(--spacing-lg);
}

.pagination button,
.pagination span {
    padding: 0.5rem 0.875rem;
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.pagination button:hover:not(:disabled) {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.pagination button.active {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== Toast Notifications ===== */
.toast-container {
    position: fixed;
    bottom: var(--spacing-lg);
    right: var(--spacing-lg);
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.toast {
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--color-text);
    color: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.success {
    background: var(--color-success);
}

.toast.error {
    background: var(--color-danger);
}

.toast.warning {
    background: var(--color-warning);
}

.toast-close {
    background: none;
    border: none;
    color: inherit;
    cursor: pointer;
    opacity: 0.7;
}

.toast-close:hover {
    opacity: 1;
}

/* ===== Info Banner ===== */
.info-banner {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-md) var(--spacing-lg);
    background: var(--color-surface);
    border-radius: var(--radius-md);
    margin-bottom: var(--spacing-lg);
    color: var(--color-primary-light);
}

.info-icon {
    font-size: 1.5rem;
}

/* ===== Activity List ===== */
.activity-list {
    max-height: 400px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--color-border);
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-icon {
    width: 32px;
    height: 32px;
    background: var(--color-surface);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.activity-content {
    flex: 1;
}

.activity-text {
    font-size: var(--font-size-sm);
}

.activity-time {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* ===== Document List (compact) ===== */
.document-list {
    max-height: 400px;
    overflow-y: auto;
}

.document-list-item {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--color-border);
    cursor: pointer;
}

.document-list-item:hover {
    background: rgba(52, 152, 219, 0.05);
}

.document-list-item:last-child {
    border-bottom: none;
}

.document-list-item .doc-icon {
    font-size: 1.5rem;
}

.document-list-item .doc-info {
    flex: 1;
    min-width: 0;
}

.document-list-item .doc-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
}

.document-list-item .doc-meta {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
}

/* ===== Loading State ===== */
.loading {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--color-text-muted);
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--color-border);
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: var(--spacing-sm);
    vertical-align: middle;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--color-text-muted);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: var(--spacing-md);
    opacity: 0.5;
}

.empty-state-text {
    font-size: var(--font-size-lg);
    margin-bottom: var(--spacing-sm);
}

/* ===== System Info ===== */
.system-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: var(--spacing-lg);
}

.info-section {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: var(--spacing-lg);
}

.info-section h4 {
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--color-border);
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--color-border);
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    color: var(--color-text-muted);
}

.info-value {
    font-weight: 500;
}

.info-value.success {
    color: var(--color-success);
}

.info-value.error {
    color: var(--color-danger);
}

/* ===== Responsive ===== */

/* Tablet Landscape & Desktop Small */
@media (max-width: 1024px) {
    .dashboard-row {
        grid-template-columns: 1fr;
    }
    
    .detail-panel {
        width: 100%;
        right: -100%;
    }
    
    .documents-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }
}

/* Tablet Portrait (iPad, Android Tablets) */
@media (max-width: 900px) {
    .doc-view-body {
        flex-direction: column;
    }
    
    .doc-view-sidebar {
        width: 100%;
        max-height: 50vh;
    }
    
    .sidebar {
        width: 280px;
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .documents-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: var(--spacing-md);
    }
}

/* Mobile (iPhone, Android Phones) */
@media (max-width: 768px) {
    :root {
        --sidebar-width: 100%;
        --spacing-lg: 1rem;
        --spacing-xl: 1.5rem;
    }
    
    .sidebar {
        width: 85%;
        max-width: 320px;
        transform: translateX(-100%);
        box-shadow: var(--shadow-lg);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        padding: var(--spacing-md);
        padding-bottom: 80px; /* Space for mobile nav */
    }
    
    .view-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--spacing-md);
    }
    
    .view-header h1 {
        font-size: var(--font-size-lg);
    }
    
    .header-actions {
        width: 100%;
        flex-wrap: wrap;
    }
    
    .toolbar {
        flex-direction: column;
        align-items: stretch;
        gap: var(--spacing-sm);
    }
    
    .search-box {
        max-width: none;
        width: 100%;
    }
    
    .filter-group {
        flex-wrap: wrap;
        width: 100%;
    }
    
    .filter-group select {
        flex: 1;
        min-width: 120px;
    }
    
    .documents-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }
    
    .document-card {
        padding: var(--spacing-sm);
    }
    
    .document-card .document-title {
        font-size: var(--font-size-sm);
    }
    
    .document-card .document-summary {
        font-size: 0.75rem;
        -webkit-line-clamp: 2;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    /* Dashboard stats */
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--spacing-sm);
    }
    
    .stat-card {
        padding: var(--spacing-md);
    }
    
    .stat-value {
        font-size: var(--font-size-lg);
    }
    
    /* Modal adjustments */
    .modal {
        width: 95%;
        max-width: none;
        margin: var(--spacing-sm);
        max-height: 90vh;
    }
    
    .modal-fullscreen {
        width: 100%;
        height: 100%;
        max-width: 100%;
        max-height: 100%;
        margin: 0;
        border-radius: 0;
    }
    
    .modal-fullscreen .doc-view-body {
        flex-direction: column;
    }
    
    .modal-fullscreen .doc-view-preview {
        height: 40vh;
        min-height: 200px;
    }
    
    .modal-fullscreen .doc-view-sidebar {
        width: 100%;
        max-height: none;
        overflow-y: auto;
    }
    
    /* Toast position */
    .toast-container {
        left: var(--spacing-md);
        right: var(--spacing-md);
        bottom: 80px;
    }
    
    .toast {
        max-width: none;
    }
    
    /* Tables scroll */
    .data-table {
        font-size: var(--font-size-sm);
    }
    
    .data-table th,
    .data-table td {
        padding: var(--spacing-sm);
    }
    
    /* Admin tabs */
    .admin-tabs {
        overflow-x: auto;
        flex-wrap: nowrap;
        -webkit-overflow-scrolling: touch;
    }
    
    .tab-btn {
        white-space: nowrap;
        flex-shrink: 0;
    }
}

/* Small phones */
@media (max-width: 375px) {
    .documents-grid {
        grid-template-columns: 1fr;
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .header-actions .btn {
        width: 100%;
    }
}

/* ===== Mobile Floating Menu Button ===== */
.mobile-menu-btn {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--color-primary);
    color: white;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    z-index: 150;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
    transition: var(--transition);
}

.mobile-menu-btn:hover {
    background: var(--color-primary-dark);
    transform: scale(1.05);
}

.mobile-menu-btn:active {
    transform: scale(0.95);
}

.mobile-menu-btn.open {
    background: var(--color-danger);
}

.mobile-menu-btn.open::before {
    content: '✕';
}

@media (max-width: 900px) {
    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* ===== Mobile Overlay ===== */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mobile-overlay.active {
    display: block;
    opacity: 1;
}

/* ===== Safe Area for iOS ===== */
@supports (padding: max(0px)) {
    .main-content {
        padding-bottom: max(80px, env(safe-area-inset-bottom));
    }
    
    .mobile-menu-btn {
        bottom: max(20px, calc(env(safe-area-inset-bottom) + 10px));
    }
    
    .toast-container {
        bottom: max(80px, calc(env(safe-area-inset-bottom) + 70px));
    }
}
