/* Force light theme */
html {
    color-scheme: light;
}

/* Bulma Color Overrides */
:root {
    --bulma-primary: #4361ee;
    --bulma-primary-h: 229;
    --bulma-primary-s: 84%;
    --bulma-primary-l: 60%;
    --bulma-link: #4361ee;
    --bulma-link-h: 229;
    --bulma-link-s: 84%;
    --bulma-link-l: 60%;
}

/* Sidebar Layout */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 220px;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    z-index: 30;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 1.5rem;
    text-align: center;
    border-bottom: 1px solid #e0e0e0;
}

.sidebar-brand a {
    display: inline-block;
}

.sidebar-menu {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
}

.sidebar-link {
    display: block;
    padding: 0.5rem 1.5rem;
    color: #363636;
    text-decoration: none;
    font-size: 0.95rem;
    transition: background-color 0.15s, color 0.15s;
}

.sidebar-link:hover {
    background: #f5f5f5;
    color: #363636;
}

.sidebar-link.is-active {
    background: #4361ee;
    color: #fff;
}

.sidebar-link.is-active:hover {
    background: #3a56d4;
    color: #fff;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e0e0e0;
    font-size: 0.85rem;
    color: #666;
    word-break: break-all;
}

.main-content {
    margin-left: 220px;
    min-height: 100vh;
}

/* Mobile Sidebar Toggle */
.sidebar-toggle {
    display: none;
    position: fixed;
    top: 1rem;
    left: 1rem;
    z-index: 40;
    width: 40px;
    height: 40px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px;
}

.sidebar-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: #363636;
    transition: transform 0.3s;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 25;
}

/* Login Page */
.login-page {
    background: linear-gradient(135deg, #667eea 0%, #4361ee 25%, #764ba2 50%, #6b48c8 75%, #4361ee 100%);
    background-size: 300% 300%;
    animation: login-gradient 12s ease infinite;
    position: relative;
    overflow: hidden;
}

.login-page::before,
.login-page::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    opacity: 0.08;
    background: #fff;
}

.login-page::before {
    width: 600px;
    height: 600px;
    top: -200px;
    right: -100px;
    animation: login-float 8s ease-in-out infinite;
}

.login-page::after {
    width: 400px;
    height: 400px;
    bottom: -100px;
    left: -80px;
    animation: login-float 10s ease-in-out infinite reverse;
}

.login-page .box {
    backdrop-filter: blur(4px);
    background: rgba(255, 255, 255, 0.95);
    padding: 2.5rem;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.login-page .box .input {
    padding: 1.4em 1em;
    border-radius: 10px;
}

.login-page .box .button {
    padding: 1.4em;
    border-radius: 10px;
    font-weight: 600;
    letter-spacing: 0.02em;
    transition: transform 0.15s, box-shadow 0.15s;
}

.login-page .box .button:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(67, 97, 238, 0.35);
}

@keyframes login-gradient {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

@keyframes login-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-30px); }
}

/* Upload Area */
.upload-area {
    border: 2px dashed #ddd;
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.upload-area:hover {
    border-color: #4361ee;
    background-color: #f9f9ff;
}

.upload-area.drag-over {
    border-color: #4361ee;
    background-color: #f0f0ff;
}

.upload-area svg {
    color: #999;
    margin-bottom: 16px;
}

.upload-area p {
    color: #666;
    margin-bottom: 8px;
}

.upload-hint {
    font-size: 12px;
    color: #999;
}

/* Progress Bar */
.progress-fill {
    height: 100%;
    background: #4361ee;
    transition: width 0.3s;
}

/* Import Results */
.import-results {
    margin-top: 24px;
    padding: 16px;
    background-color: #f9f9f9;
    border-radius: 4px;
}

.result-item {
    padding: 8px;
    margin-bottom: 8px;
    border-radius: 4px;
}

.result-item.success {
    background-color: #d4edda;
    color: #155724;
}

.result-item.error {
    background-color: #f8d7da;
    color: #721c24;
}

/* Sortable table headers */
th.sortable {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 1.2em;
}

th.sortable:hover {
    background-color: #f5f5f5;
}

th.sortable::after {
    content: '';
    position: absolute;
    right: 0.4em;
    top: 50%;
    transform: translateY(-50%);
    border: 4px solid transparent;
    border-bottom-color: #ccc;
    margin-top: -6px;
}

th.sortable::before {
    content: '';
    position: absolute;
    right: 0.4em;
    top: 50%;
    transform: translateY(-50%);
    border: 4px solid transparent;
    border-top-color: #ccc;
    margin-top: 4px;
}

th.sortable.sort-asc::after {
    border-bottom-color: #363636;
}

th.sortable.sort-asc::before {
    border-top-color: #ccc;
}

th.sortable.sort-desc::before {
    border-top-color: #363636;
}

th.sortable.sort-desc::after {
    border-bottom-color: #ccc;
}

/* Document link in table */
.doc-link {
    color: #4361ee;
    text-decoration: none;
}

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

/* Document view page */
.document-container {
    max-width: 900px;
    margin: 0 auto;
}

.document-header {
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #e2e8f0;
}

.document-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: #1e293b;
    margin-bottom: 0.5rem;
}

.document-meta {
    font-size: 0.875rem;
    color: #64748b;
}

.document-meta span {
    margin-right: 1.5rem;
}

.document-content {
    background-color: #fff;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.7;
    color: #334155;
    max-height: 70vh;
    overflow-y: auto;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: #4361ee;
    text-decoration: none;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

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

/* Error message */
.error-message {
    padding: 12px;
    background-color: #fee;
    border: 1px solid #fcc;
    border-radius: 4px;
    color: #c33;
    font-size: 14px;
}

/* Mobile Responsive */
@media (max-width: 1023px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.is-active {
        transform: translateX(0);
    }

    .sidebar-toggle {
        display: flex;
    }

    .sidebar-overlay.is-active {
        display: block;
    }

    .main-content {
        margin-left: 0;
    }
}
