/* ============================================
   SMARTJUSS - MAIN STYLES
   Med komplett e-post UI
   ============================================ */

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

/* Lucide icons */
svg.lucide {
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
    display: inline-block;
    flex-shrink: 0;
}

:root {
    /* Primary colors - matches landing page warm gold palette */
    --primary: #C5A059;
    --primary-dark: #A88542;
    --primary-text: #8B7355; /* A11Y: Warm brown for text on white */
    --secondary: #3D3321;

    /* Background colors - warm beige palette */
    --bg-light: #F8F4E9;
    --bg-white: #FFFFFF;
    --bg-hover: #F0EBE0;
    --bg-disabled: #ccc;
    --bg-highlight: #FFFBF0;

    /* Text colors - warm brown tones */
    --text-dark: #3D3321;
    --text-light: #5A4E3B;
    --text-muted: #8A7E6B;
    --text-placeholder: #A89F8B;

    /* Border colors - warm */
    --border: #E6DFD0;
    --border-light: #F0EBE0;

    /* Shadows - warm */
    --shadow-sm: 0 2px 8px rgba(61,51,33,0.08);
    --shadow-md: 0 4px 16px rgba(61,51,33,0.12);
    --shadow-lg: 0 8px 32px rgba(61,51,33,0.16);

    /* Status colors */
    --success: #4caf50;
    --success-bg: #d4edda;
    --success-text: #155724;
    --danger: #f44336;
    --danger-bg: #f8d7da;
    --danger-text: #721c24;
    --danger-light: #fff5f5;
    --warning: #ff9800;
    --info: #2196f3;

    /* Gray scale - warmer tones */
    --gray-100: #FAF8F5;
    --gray-200: #F5F2ED;
    --gray-300: #E6DFD0;
    --gray-400: #A89F8B;
    --gray-500: #8A7E6B;
    --gray-600: #5A4E3B;
    --gray-700: #4A4030;
    --gray-800: #3D3321;
    --gray-900: #2A2318;
}

/* A11Y: Skip to content link */
.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--primary);
    color: white;
    padding: 8px 16px;
    z-index: 10000;
    text-decoration: none;
    font-weight: 500;
    border-radius: 0 0 8px 0;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 0;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-light);
    color: var(--text-light);
    line-height: 1.6;
}

/* Typography - Playfair Display for headings */
h1, h2, h3, h4, h5, h6,
.modal-header h2,
.profile-card h3,
.case-section h3,
.welcome-title {
    font-family: 'Playfair Display', Georgia, serif;
    color: var(--text-dark);
}

.hidden {
    display: none !important;
}

/* Screen reader only - for accessibility */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ============================================
   LOADING SCREEN
   ============================================ */

#loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg-white);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border);
    border-top-color: var(--primary-text); /* A11Y */
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* ============================================
   LOGIN PAGE (Landing Page)
   ============================================ */

/* #login-page styles are defined inline in index.html for the landing page */

/* Ensure app takes full height */
#app {
    min-height: 100vh;
}

.login-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    padding: 40px;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 450px;
    border: 1px solid var(--border);
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    color: var(--secondary);
    font-size: 32px;
    margin-bottom: 10px;
}

.login-tabs {
    display: flex;
    gap: 10px;
    margin-bottom: 30px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: 2px solid var(--border);
    background: transparent;
    cursor: pointer;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s;
}

.tab-btn.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary-text); /* A11Y */
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-weight: 600;
    color: var(--text-dark);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-text); /* A11Y */
    box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.3);
}

.form-group small {
    color: var(--text-light);
    font-size: 13px;
}

.btn-primary {
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
}

.btn-secondary {
    padding: 10px 20px;
    background: transparent;
    border: 2px solid var(--primary);
    color: var(--primary-text); /* A11Y: Better contrast */
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
}

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

.forgot-password {
    text-align: center;
    color: var(--primary-text); /* A11Y: Better contrast */
    text-decoration: none;
    font-size: 14px;
}

/* Forgot Password Modal - Improved Design */
#forgot-password-modal .modal-content {
    position: relative;
    padding: 40px;
    border-radius: 16px;
    text-align: center;
    max-width: 450px;
}

#forgot-password-modal h2 {
    margin: 0 0 15px 0;
    font-size: 24px;
    color: var(--text-dark);
}

#forgot-password-modal p {
    color: var(--text-light);
    margin-bottom: 25px;
    line-height: 1.5;
}

#forgot-password-modal .form-group {
    text-align: left;
    margin-bottom: 20px;
}

#forgot-password-modal .form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-dark);
}

#forgot-password-modal .form-group input {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border);
    border-radius: 10px;
    font-size: 15px;
    box-sizing: border-box;
}

#forgot-password-modal .form-group input:focus {
    outline: none;
    border-color: var(--primary-text); /* A11Y */
    box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.3);
}

#forgot-password-modal .btn-primary {
    width: 100%;
    padding: 14px;
    border-radius: 10px;
    font-size: 16px;
}

#forgot-password-modal .close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 28px;
    color: var(--text-light);
    cursor: pointer;
    background: none;
    border: none;
}

#forgot-password-modal .close-modal:hover {
    color: var(--text-dark);
}

#forgot-password-modal #forgot-password-message {
    padding: 12px;
    border-radius: 8px;
    text-align: center;
}

#forgot-password-modal #forgot-password-message.success {
    background: var(--success-bg);
    color: var(--success-text);
}

#forgot-password-modal #forgot-password-message.error {
    background: var(--danger-bg);
    color: var(--danger-text);
}

/* ============================================
   SIDEBAR LOGO
   ============================================ */

.sidebar-logo {
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.logo-brand {
    display: flex;
    align-items: center;
}

.sidebar-logo .logo-symbol {
    font-size: 28px;
    color: var(--primary);
    font-weight: bold;
}

.sidebar-logo .logo-text {
    font-size: 20px;
    color: var(--secondary);
    margin-left: 8px;
    font-family: 'Playfair Display', Georgia, serif;
}

.konto-toggle-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 7px;
    border-radius: 8px;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    transition: background 0.2s;
}

.konto-toggle-btn:hover {
    background: var(--bg-hover);
}

.konto-toggle-btn.active-section {
    color: var(--primary);
    background: var(--bg-hover);
}

.konto-dropdown {
    padding: 8px 12px 12px;
    border-bottom: 1px solid var(--border);
    margin-bottom: 10px;
}

.sidebar-btn-logout {
    color: var(--text-light);
}

.sidebar-btn-logout:hover {
    background: #fee2e2 !important;
    color: #dc2626 !important;
}

/* ============================================
   APP LAYOUT
   ============================================ */

.app-layout {
    display: flex;
    height: 100vh;
}

/* ============================================
   SIDEBAR
   ============================================ */

.sidebar {
    width: 280px;
    background: var(--bg-white);
    border-right: 1px solid var(--border);
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 20px 0;
    transition: width 0.25s ease;
    flex-shrink: 0;
}

.sidebar.collapsed {
    width: 64px;
}

.sidebar.collapsed .btn-label { display: none; }
.sidebar.collapsed .sidebar-section h3 { display: none; }
.sidebar.collapsed .logo-brand { display: none; }
.sidebar.collapsed .sidebar-mer-chevron { display: none; }
.sidebar.collapsed .konto-dropdown { display: none; }
.sidebar.collapsed #sidebar-mer-panel { display: none; }

.sidebar.collapsed .sidebar-btn {
    justify-content: center;
    padding: 12px 8px;
}

.sidebar.collapsed .btn-upgrade {
    margin: 10px 8px;
    padding: 12px 8px;
    justify-content: center;
}

.sidebar.collapsed .sidebar-section {
    padding: 0 8px;
}

.sidebar.collapsed .sidebar-logo {
    padding: 16px 8px;
    justify-content: space-between;
}

.sidebar-collapse-btn {
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 7px;
    border-radius: 8px;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.sidebar-collapse-btn:hover { background: var(--bg-hover); }

.sidebar-collapse-btn .icon-expand { display: none; }
.sidebar.collapsed .sidebar-collapse-btn .icon-collapse { display: none; }
.sidebar.collapsed .sidebar-collapse-btn .icon-expand { display: flex; }

.sidebar-section {
    padding: 0 20px;
    margin-bottom: 30px;
}

.sidebar-section h3 {
    font-size: 12px;
    color: var(--text-light);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
}

.sidebar-btn {
    width: 100%;
    padding: 12px 15px;
    background: transparent;
    border: none;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 5px;
    text-align: left;
    font-size: 15px;
    color: var(--text-dark);
}

.sidebar-btn:hover {
    background: var(--bg-hover);
}

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

.sidebar-btn.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.sidebar-btn .icon {
    font-size: 18px;
}

.sidebar-btn .badge {
    margin-left: auto;
    padding: 4px 8px;
    background: var(--primary);
    color: white;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.sidebar-btn .unread-count {
    background: var(--danger);
}

.btn-upgrade {
    margin: 20px;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 600;
    transition: transform 0.2s;
}

.btn-upgrade:hover {
    transform: translateY(-2px);
}

.sidebar-mer-trigger {
    margin-bottom: 0;
    border-top: 1px solid var(--border);
    padding-top: 10px;
}

.sidebar-mer-chevron {
    margin-left: auto;
    transition: transform 0.2s;
    font-size: 16px !important;
}

#sidebar-mer-btn.open .sidebar-mer-chevron {
    transform: rotate(180deg);
}

#sidebar-mer-btn.active-section {
    color: var(--primary);
    font-weight: 600;
}

#sidebar-mer-panel {
    border-top: 1px solid var(--border);
    padding-top: 5px;
}

/* ============================================
   MAIN CONTENT
   ============================================ */

.main-content {
    flex: 1;
    overflow-y: auto;
    background: var(--bg-white);
}

.view {
    height: 100%;
    display: flex;
    flex-direction: column;
}

/* ============================================
   CHAT VIEW
   ============================================ */

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

.chat-messages {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 30px;
    background: var(--bg-light);
}

.message {
    margin-bottom: 20px;
    padding: 15px 20px;
    border-radius: 12px;
    max-width: 80%;
}

.message.user {
    background: var(--primary);
    color: white;
    margin-left: auto;
}

.message.assistant {
    background: var(--bg-white);
    color: var(--text-dark);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
}

/* Markdown formatering i assistant messages */
.message.assistant h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary-text); /* A11Y */
    margin: 15px 0 10px 0;
    padding-bottom: 5px;
    border-bottom: 2px solid var(--border);
}

.message.assistant h3 {
    font-size: 16px;
    font-weight: 600;
    margin: 12px 0 8px 0;
}

.message.assistant p {
    margin: 10px 0;
    line-height: 1.6;
}

.message.assistant ul, .message.assistant ol {
    margin: 10px 0;
    padding-left: 25px;
}

.message.assistant li {
    margin: 5px 0;
    line-height: 1.5;
}

.message.assistant code {
    background: rgba(61,51,33,0.08);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 14px;
}

.message.assistant pre {
    background: rgba(61,51,33,0.08);
    padding: 15px;
    border-radius: 8px;
    overflow-x: hidden;
    white-space: pre-wrap;
    word-break: break-word;
    margin: 10px 0;
}

.message.assistant strong {
    font-weight: 600;
    color: var(--text-dark);
}

.message.assistant blockquote {
    border-left: 4px solid var(--primary);
    padding-left: 15px;
    margin: 10px 0;
    font-style: italic;
    color: #666;
}

/* AI Disclaimer - vises under hvert AI-svar */
.ai-disclaimer {
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    font-size: 12px;
    color: var(--text-muted);
}

/* Document Block Wrapper - for code/document blocks in chat */
.document-block-wrapper {
    position: relative;
    margin: 15px 0;
}

.document-block-wrapper pre {
    margin: 0;
    border-radius: 8px 8px 0 0;
}

/* HTML document preview inside chat — formatted A4-style rendering */
.document-html-preview {
    max-height: 520px;
    overflow-y: auto;
    border: 1px solid #d4c5a0;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    background: #fafaf8;
}

.document-html-preview .sj-doc {
    width: 100%;
    min-height: auto;
    padding: 24px 32px;
    box-shadow: none;
    background: #fafaf8;
    font-size: 10pt;
}

.document-html-preview .sj-doc-watermark {
    display: none;
}

.document-block-actions {
    display: flex;
    gap: 8px;
    padding: 8px 12px;
    background: var(--gray-200);
    border-radius: 0 0 8px 8px;
    border-top: 1px solid var(--border);
}

.btn-document-action {
    padding: 5px 10px;
    background: var(--bg-white);
    color: var(--text-dark);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s ease;
}

.btn-document-action:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-document-action:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Chat input - Claude style unified box */
.chat-input-container {
    padding: 12px 20px;
}

.chat-input-wrapper {
    border: 2px solid var(--border);
    border-radius: 16px;
    background: var(--bg-white);
    padding: 8px 14px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chat-input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(201, 165, 90, 0.15);
}

#chat-input {
    width: 100%;
    padding: 4px 0;
    border: none;
    background: transparent;
    resize: none;
    font-size: 15px;
    line-height: 1.4;
    outline: none;
    color: var(--text-dark);
    min-height: 24px;
    max-height: 150px;
}

#chat-input:focus {
    box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.3);
}

#chat-input::placeholder {
    color: var(--text-light);
}

.input-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 6px;
    margin-top: 4px;
}

.btn-icon {
    padding: 10px;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 20px;
    border-radius: 8px;
    transition: background 0.2s ease;
}

.btn-icon:hover {
    background: var(--bg-highlight);
}

.btn-send {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, transform 0.1s ease;
}

.btn-send:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.btn-send:active {
    transform: scale(0.95);
}

/* Chat file attachment styles */
.chat-input-wrapper.drag-over {
    border-color: #3b82f6;
    background: rgba(59, 130, 246, 0.05);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.chat-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 12px;
    margin-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.chat-attachments:empty {
    display: none;
    padding: 0;
    margin: 0;
    border: none;
}

.attachment-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-hover);
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-dark);
    border: 1px solid var(--border);
}

.attachment-summary {
    font-size: 13px;
    color: var(--text-muted, #888);
    padding: 2px 4px;
    margin-top: 4px;
}

.attachment-icon {
    font-size: 14px;
}

.attachment-name {
    max-width: 150px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attachment-remove {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px 8px;
    min-width: 44px;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    line-height: 1;
    transition: color 0.2s;
}

.attachment-remove:hover {
    color: #ef4444;
}

.search-input {
    padding: 10px 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    width: 100%;
    max-width: 300px;
}

/* ============================================
   EMAIL VIEWS
   ============================================ */

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

.email-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

/* Email list */
.email-list {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.email-select-all-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 30px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-light);
}

.email-item-selected {
    background: rgba(174, 139, 82, 0.08) !important;
}

.email-row-checkbox {
    flex-shrink: 0;
}

.email-delete-btn {
    flex-shrink: 0;
}

.email-item {
    padding: 14px 30px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    gap: 15px;
    align-items: flex-start;
}

.email-item:hover {
    background: var(--bg-light);
}

.email-item.unread {
    background: var(--bg-highlight);
    font-weight: 600;
}

.email-item-icon {
    font-size: 24px;
}

.email-item-content {
    flex: 1;
}

.email-item-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.email-item-from {
    font-weight: 600;
    color: var(--text-dark);
}

.email-item-date {
    color: var(--text-light);
    font-size: 13px;
}

.email-item-subject {
    color: var(--text-dark);
    margin-bottom: 5px;
}

.email-item-preview {
    color: var(--text-light);
    font-size: 14px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.email-item-attachments {
    color: var(--text-light);
    font-size: 13px;
    margin-top: 5px;
}

/* Email detail */
.email-detail-header {
    padding: 20px 30px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn-back {
    padding: 10px 20px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.email-detail-actions {
    display: flex;
    gap: 10px;
}

.email-detail-content {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
}

.email-detail-info {
    background: var(--bg-white);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 30px;
    border: 1px solid var(--border);
}

.email-detail-info-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.email-detail-info-row strong {
    min-width: 80px;
}

.email-detail-body {
    line-height: 1.8;
}

/* Attachment indicator in email subject */
.attachment-indicator {
    color: var(--primary);
    font-size: 1em;
}

/* Email Detail Attachments */
.email-detail-attachments {
    margin: 20px 0;
    padding: 15px;
    background: var(--bg-white);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.email-detail-attachments > strong {
    display: block;
    margin-bottom: 12px;
    color: var(--text-dark);
}

.email-attachment-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: var(--bg-white);
    border-radius: 6px;
    margin-bottom: 8px;
    border: 1px solid var(--border);
}

.email-attachment-item:last-child {
    margin-bottom: 0;
}

.email-attachment-icon {
    font-size: 1.2em;
}

.email-attachment-name {
    flex: 1;
    font-weight: 500;
    color: var(--text-dark);
}

.attachment-size {
    color: var(--text-muted);
    font-size: 0.85em;
}

.attachment-actions {
    display: flex;
    gap: 8px;
}

/* Highlight flash animation for documents */
.highlight-flash {
    animation: highlightFlash 2s ease-out;
}

@keyframes highlightFlash {
    0%, 50% {
        background-color: var(--primary);
        color: white;
    }
    100% {
        background-color: inherit;
        color: inherit;
    }
}

.email-attachments {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid var(--border);
}

.attachment-item {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 10px 15px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-right: 10px;
    margin-bottom: 10px;
}

/* Email compose */
.compose-header {
    padding: 20px 30px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.compose-actions {
    display: flex;
    gap: 10px;
}

.compose-form {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
}

.compose-form .form-group {
    margin-bottom: 20px;
}

.compose-form label {
    display: inline-block;
    min-width: 60px;
    font-weight: 600;
    margin-right: 10px;
}

.compose-form input[type="text"],
.compose-form select {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
}

/* AI Email Assistant */
.ai-email-assistant {
    background: var(--bg-highlight);
    padding: 15px;
    border-radius: 12px;
    border: 1px solid var(--primary);
    margin-bottom: 15px;
}

.ai-email-assistant label {
    display: block;
    margin-bottom: 10px;
    font-weight: 600;
    color: var(--secondary);
}

.ai-prompt-container {
    display: flex;
    gap: 10px;
    margin-bottom: 12px;
}

.ai-prompt-container input {
    flex: 1;
    padding: 12px 15px;
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
}

.ai-prompt-container input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.3);
}

.ai-prompt-container .btn-primary {
    white-space: nowrap;
    padding: 12px 20px;
}

.quick-templates {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.quick-label {
    font-size: 13px;
    color: var(--text-muted);
}

.quick-template-btn {
    padding: 6px 12px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.quick-template-btn:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.btn-link {
    background: transparent;
    border: none;
    color: var(--primary-text); /* A11Y */
    cursor: pointer;
    text-decoration: underline;
    margin-left: 10px;
}

/* Rich editor */
.editor-toolbar {
    display: flex;
    gap: 5px;
    padding: 10px;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    flex-wrap: wrap;
}

.toolbar-btn {
    padding: 8px 12px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.toolbar-btn:hover {
    background: var(--bg-light);
}

.toolbar-btn.juridisk {
    background: var(--primary);
    color: white;
    border-color: var(--primary-text); /* A11Y */
}

.toolbar-divider {
    width: 1px;
    background: var(--border);
    margin: 0 5px;
}

.rich-editor {
    min-height: 400px;
    padding: 20px;
    border: 1px solid var(--border);
    border-radius: 0 0 8px 8px;
    background: var(--bg-white);
    line-height: 1.8;
}

.rich-editor:focus {
    outline: none;
    border-color: var(--primary-text); /* A11Y */
    box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.3);
}

.rich-editor[placeholder]:empty:before {
    content: attr(placeholder);
    color: var(--text-light);
}

/* ============================================
   DOCUMENTS VIEW
   ============================================ */

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

.documents-list {
    padding: 30px;
}

.documents-count {
    display: block;
    font-size: 13px;
    color: var(--text-light);
    margin-top: 2px;
}

.documents-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.documents-table thead th {
    text-align: left;
    padding: 10px 16px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    border-bottom: 2px solid var(--border);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
}

.documents-table thead th:hover {
    color: var(--text-dark);
}

.documents-table thead th:last-child {
    cursor: default;
    text-align: right;
}

.sort-indicator {
    font-size: 10px;
    margin-left: 4px;
    opacity: 0.7;
}

.documents-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background 0.15s;
}

.documents-table tbody tr:hover {
    background: var(--bg-light);
}

.documents-table tbody tr:nth-child(even) {
    background: rgba(61, 51, 33, 0.02);
}

.documents-table tbody tr:nth-child(even):hover {
    background: var(--bg-light);
}

.documents-table td {
    padding: 12px 16px;
    vertical-align: middle;
}

.doc-name-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.doc-name-cell .doc-icon {
    font-size: 22px;
    flex-shrink: 0;
}

.doc-name-cell .doc-filename {
    font-weight: 500;
    color: var(--text-dark);
}

.doc-checkbox-cell {
    width: 36px;
    padding: 0 8px !important;
    text-align: center;
}

.doc-checkbox {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
    cursor: pointer;
}

.doc-actions-cell {
    text-align: right;
    white-space: nowrap;
}

.doc-actions-cell .btn-secondary,
.doc-actions-cell .btn-danger {
    margin-left: 6px;
}

.doc-row-selected {
    background: rgba(174, 139, 82, 0.08) !important;
}

.doc-bulk-bar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: var(--bg-light);
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.doc-bulk-count {
    font-size: 13px;
    font-weight: 600;
    color: var(--primary);
    margin-right: 4px;
}

.doc-bulk-clear {
    background: none;
    border: none;
    color: var(--text-light);
    font-size: 13px;
    cursor: pointer;
    margin-left: auto;
    padding: 4px 8px;
    border-radius: 4px;
}

.doc-bulk-clear:hover {
    color: var(--text-dark);
    background: var(--border);
}

.documents-empty {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.documents-empty-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.documents-empty h3 {
    margin: 0 0 8px;
    color: var(--text-dark);
    font-size: 18px;
}

.documents-empty p {
    margin: 0;
    font-size: 14px;
}

/* ============================================
   CONVERSATIONS VIEW
   ============================================ */

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

.conversations-list {
    padding: 30px;
}

.conversation-item {
    padding: 20px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 12px;
    margin-bottom: 15px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
}

.conversation-item:hover {
    background: var(--primary);
    color: white;
    transform: translateX(5px);
}

.conversation-item:hover .delete-btn {
    color: white;
    opacity: 1;
}

.conversation-item:hover .conversation-date {
    color: white;
}

.delete-btn {
    padding: 8px 12px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    opacity: 1;
    color: #e53e3e;
    transition: all 0.2s;
    border-radius: 6px;
}

.delete-btn:hover {
    opacity: 1;
    background: rgba(244, 67, 54, 0.1);
}

.conversation-title {
    font-weight: 600;
    margin-bottom: 5px;
}

.conversation-date {
    font-size: 13px;
    color: var(--text-light);
}

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 900px) {
    .modal-content {
        max-width: 95%;
    }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -85vw;
        width: min(280px, 85vw);
        height: 100%;
        z-index: 999;
        transition: left 0.3s;
    }

    .sidebar.open {
        left: 0;
    }

    .main-content {
        width: 100%;
    }
}

/* ============================================
   HAMBURGER BUTTON
   ============================================ */
.hamburger-btn {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 12px;
    min-width: 44px;
    min-height: 44px;
    flex-shrink: 0;
}
.hamburger-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--text-dark);
    border-radius: 2px;
    transition: all 0.3s;
}
@media (max-width: 768px) {
    .hamburger-btn { display: flex; }
}

/* ============================================
   SIDEBAR OVERLAY
   ============================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 998;
}
.sidebar-overlay.active {
    display: block;
}

/* ============================================
   UTILITIES
   ============================================ */

.text-center {
    text-align: center;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

/* ============================================
   CASES VIEW
   ============================================ */

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

.cases-list {
    padding: 30px;
}

.case-item-wrapper {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    margin-bottom: 15px;
}

.case-checkbox {
    margin-top: 22px;
    flex-shrink: 0;
}

.case-item-wrapper .case-item {
    flex: 1;
    margin-bottom: 0;
}

.case-item-selected {
    outline: 2px solid var(--primary);
}

.case-item-header-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.case-delete-btn {
    flex-shrink: 0;
}

.case-item {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 15px;
    cursor: pointer;
    transition: all 0.2s;
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary);
    box-shadow: var(--shadow-sm);
}

.case-item:hover {
    background: var(--primary);
    color: white;
    transform: translateX(5px);
}

.case-item:hover .case-item-meta,
.case-item:hover .case-item-status {
    color: white;
}

.case-item-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.case-item-title {
    font-weight: 600;
    font-size: 16px;
}

.case-item-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.case-item-status.active {
    background: var(--success);
    color: white;
}

.case-item-status.resolved {
    background: var(--primary);
    color: white;
}

.case-item-status.archived {
    background: #999;
    color: white;
}

.case-item-meta {
    display: flex;
    gap: 15px;
    font-size: 13px;
    color: var(--text-light);
}

.case-item-description {
    margin-top: 10px;
    font-size: 14px;
}

/* ============================================
   CASE DETAIL VIEW
   ============================================ */

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

.case-detail-actions {
    display: flex;
    gap: 10px;
}

.case-detail-content {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
}

.case-info-box {
    background: var(--bg-white);
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 30px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.case-info-row {
    display: flex;
    gap: 15px;
    margin-bottom: 10px;
}

.case-info-row strong {
    min-width: 100px;
}

.case-section {
    margin-bottom: 40px;
}

.case-section h3 {
    margin-bottom: 15px;
    color: var(--secondary);
    font-size: 18px;
}

.case-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.case-section-header h3 {
    margin-bottom: 0;
}

.btn-add-item {
    padding: 8px 16px;
    background: var(--bg-light);
    border: 1px dashed var(--primary);
    color: var(--primary-text);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-add-item:hover {
    background: var(--primary);
    color: white;
    border-style: solid;
}

/* Add item modal options */
.add-item-option:hover {
    background: var(--bg-highlight) !important;
    border-color: var(--primary) !important;
}

.case-items-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.case-list-item {
    background: var(--bg-white);
    padding: 15px;
    border-radius: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s, box-shadow 0.2s;
    border: 1px solid var(--border);
}

.case-list-item:hover {
    background: var(--bg-hover);
    box-shadow: var(--shadow-sm);
}

.case-list-item-content {
    flex: 1;
}

.case-list-item-title {
    font-weight: 600;
    margin-bottom: 5px;
}

.case-list-item-meta {
    font-size: 13px;
    color: var(--text-light);
}

.case-list-item-actions {
    display: flex;
    gap: 10px;
}

.btn-remove {
    padding: 8px 15px;
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
}

.btn-remove:hover {
    background: var(--danger);
    color: white;
}

.ai-analysis-box {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    margin-top: 20px;
}

.ai-analysis-box h4 {
    margin-bottom: 10px;
    font-size: 16px;
}

.ai-analysis-content {
    line-height: 1.8;
}

/* ============================================
   PROFILE VIEW
   ============================================ */

.profile-header {
    padding: 20px 30px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-content {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.profile-card {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 25px;
    box-shadow: var(--shadow-sm);
}

.profile-card h3 {
    margin: 0 0 20px 0;
    color: var(--secondary);
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* User Info */
.profile-info {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--bg-light);
}

.info-row:last-child {
    border-bottom: none;
}

.info-label {
    font-weight: 600;
    color: var(--text-light);
}

.info-value {
    color: var(--text-dark);
    font-weight: 500;
}

.smartjuss-email {
    color: var(--primary-text); /* A11Y */
    font-weight: 600;
}

/* Customer ID styling */
.customer-id {
    font-family: 'Courier New', monospace;
    background: var(--bg-light);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}

/* Security Info */
.security-info {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 20px;
}

.security-badge {
    display: flex;
    gap: 12px;
    padding: 15px;
    background: var(--bg-white);
    border-radius: 12px;
    align-items: flex-start;
    border: 1px solid var(--border);
}

.badge-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.badge-text {
    flex: 1;
}

.badge-text strong {
    display: block;
    margin-bottom: 3px;
    color: var(--text-dark);
}

.badge-text p {
    margin: 0;
    font-size: 13px;
    color: var(--text-light);
}

/* Email Signature */
.card-description {
    color: var(--text-light);
    font-size: 14px;
    margin-bottom: 15px;
}

#email-signature {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    min-height: 120px;
}

#email-signature:focus {
    outline: none;
    border-color: var(--primary-text); /* A11Y */
    box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.3);
}

#email-signature-form .form-group {
    margin-bottom: 15px;
}

/* Subscription */
.subscription-info {
    text-align: center;
}

.plan-badge {
    display: inline-block;
    padding: 10px 20px;
    background: linear-gradient(135deg, #999 0%, #777 100%);
    color: white;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 15px;
}

.plan-badge.pro {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
}

.plan-badge.basic {
    background: linear-gradient(135deg, #4a90a4 0%, #357a8f 100%);
}

.plan-description {
    color: var(--text-light);
    margin-bottom: 20px;
}

.plan-features {
    list-style: none;
    padding: 0;
    margin: 20px 0;
    text-align: left;
}

.plan-features li {
    padding: 8px 0;
    font-size: 14px;
}

.btn-upgrade-full {
    width: 100%;
    padding: 15px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: transform 0.2s;
}

.btn-upgrade-full:hover {
    transform: translateY(-2px);
}

/* Statistics */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
}

.stat-item {
    text-align: center;
    padding: 20px;
    background: var(--bg-white);
    border-radius: 12px;
    transition: transform 0.2s;
    border: 1px solid var(--border);
}

.stat-item:hover {
    transform: translateY(-3px);
}

.stat-icon {
    font-size: 32px;
    margin-bottom: 10px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary-text); /* A11Y */
    margin-bottom: 5px;
}

.stat-label {
    font-size: 13px;
    color: var(--text-light);
    font-weight: 600;
}

/* Password Change Form */
#change-password-form .form-group {
    margin-bottom: 15px;
}

#change-password-form label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: var(--text-dark);
}

#change-password-form input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
}

#change-password-form input:focus {
    outline: none;
    border-color: var(--primary-text); /* A11Y */
    box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.3);
}

/* Settings */
.settings-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid var(--bg-light);
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-info {
    flex: 1;
}

.setting-info strong {
    display: block;
    margin-bottom: 5px;
    color: var(--text-dark);
}

.setting-info p {
    margin: 0;
    font-size: 13px;
    color: var(--text-light);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 28px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary-text); /* A11Y */
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

/* Danger Zone */
.danger-zone {
    border: 2px solid var(--danger);
    background: var(--danger-light);
}

.danger-zone h3 {
    color: var(--danger);
}

.danger-zone p {
    color: var(--text-light);
    margin-bottom: 15px;
}

.btn-danger {
    padding: 12px 24px;
    background: var(--danger);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s;
}

.btn-danger:hover {
    opacity: 0.8;
}

.btn-sm {
    padding: 6px 12px !important;
    font-size: 13px !important;
}

/* ============================================
   EMAIL ATTACHMENTS
   ============================================ */

.attachment-buttons {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.email-attachments-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 40px;
    padding: 10px;
    background: var(--bg-white);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.email-attachment-chip {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: var(--primary);
    color: white;
    border-radius: 20px;
    font-size: 13px;
}

.email-attachment-chip .attachment-remove {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
    opacity: 0.8;
}

.email-attachment-chip .attachment-remove:hover {
    opacity: 1;
}

.no-attachments {
    color: var(--text-light);
    font-style: italic;
    margin: 0;
}

/* Document Picker Modal */
#document-picker-modal .modal-content {
    max-width: 500px;
}

.document-picker-list {
    max-height: 300px;
    overflow-y: auto;
}

.document-picker-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.2s;
}

.document-picker-item:hover {
    background: var(--bg-light);
}

.document-picker-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
}

.document-picker-item .document-name {
    flex: 1;
}

.document-picker-item .document-size {
    color: var(--text-light);
    font-size: 12px;
}

/* ============================================
   DARK MODE
   ============================================ */

body.dark-mode {
    --bg-light: #2a2a2a;
    --bg-white: #1e1e1e;
    --bg-hover: #333333;
    --bg-highlight: #3a3a3a;
    --text-dark: #e0e0e0;
    --text-light: #a0a0a0;
    --text-muted: #888888;
    --text-placeholder: #666666;
    --border: #3a3a3a;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.4);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.5);
    --gray-100: #2a2a2a;
    --gray-200: #333333;
    --gray-300: #444444;
    --gray-400: #555555;
    --gray-500: #666666;
    --gray-600: #999999;
    --gray-700: #aaaaaa;
    --gray-800: #cccccc;
    --gray-900: #e0e0e0;
}

body.dark-mode .profile-card {
    background: var(--bg-light);
    border-color: var(--border);
}

body.dark-mode .stat-item {
    background: #333;
}

body.dark-mode input,
body.dark-mode textarea,
body.dark-mode select {
    background: #2a2a2a;
    color: var(--text-dark);
    border-color: var(--border);
}

body.dark-mode .modal-content {
    background: var(--bg-white);
    color: var(--text-dark);
    border: 1px solid var(--border);
}

body.dark-mode .modal-header {
    border-bottom-color: var(--border);
}

body.dark-mode .modal-body {
    color: var(--text-dark);
}

body.dark-mode .toast {
    background: #2a2a2a;
    color: var(--text-dark);
    border: 1px solid var(--border);
}

body.dark-mode .notifications-dropdown {
    background: var(--bg-white);
    border-color: var(--border);
}

body.dark-mode .notification-item {
    border-bottom-color: var(--border);
}

body.dark-mode .notification-item.unread {
    background: #2a2a2a;
}

body.dark-mode .sidebar-btn:hover,
body.dark-mode .sidebar-btn.active {
    background: var(--bg-hover);
}

body.dark-mode .conversation-item:hover {
    background: var(--bg-hover);
}

body.dark-mode .case-item:hover {
    background: var(--bg-hover);
}

body.dark-mode .document-item:hover,
body.dark-mode .documents-table tbody tr:hover {
    background: var(--bg-hover);
}

body.dark-mode .chat-messages {
    background: #1a1a1a;
}

body.dark-mode .assistant-message {
    background: var(--bg-light);
}

body.dark-mode .user-message {
    background: var(--primary-dark);
}

body.dark-mode .full-law-header {
    background: linear-gradient(135deg, #0d1f3c 0%, #1a2f52 100%);
}

/* ============================================
   MODAL
   ============================================ */

.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
}

.modal-content {
    background: var(--bg-white);
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-shadow: var(--shadow-lg);
}

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

.modal-header h2 {
    margin: 0;
    font-size: 20px;
}

.btn-close {
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-light);
}

.btn-close:hover {
    color: var(--text-dark);
}

/* ===== Klikkbare kildehenvisninger + fulltekst-popup ===== */
.src-ref {
    color: #9a7b33;
    text-decoration: underline;
    text-decoration-color: rgba(197, 160, 89, 0.5);
    text-underline-offset: 2px;
    cursor: pointer;
}
.src-ref:hover { color: #7c2230; text-decoration-color: currentColor; }
.citation-link { color: #9a7b33; cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.citation-link:hover { color: #7c2230; }

.source-modal-overlay {
    position: fixed; inset: 0;
    background: rgba(20, 16, 8, 0.55);
    display: flex; align-items: center; justify-content: center;
    z-index: 10001; padding: 20px;
}
.source-modal {
    background: #fff; border-radius: 14px;
    width: 100%; max-width: 680px; max-height: 82vh;
    display: flex; flex-direction: column;
    box-shadow: 0 18px 50px rgba(0,0,0,0.3);
    overflow: hidden;
}
.source-modal-head {
    display: flex; align-items: flex-start; gap: 12px;
    padding: 18px 22px 12px; border-bottom: 1px solid #ece5d6;
}
.source-modal-title {
    margin: 0; font-size: 18px; line-height: 1.3; flex: 1;
    font-family: 'Playfair Display', Georgia, serif; color: #3D3321;
}
.source-modal-close {
    background: none; border: none; font-size: 26px; line-height: 1;
    cursor: pointer; color: #9a8f78; padding: 0 4px;
}
.source-modal-close:hover { color: #7c2230; }
.source-modal-sub {
    padding: 10px 22px 0; font-size: 12.5px; color: #8a7d63; font-weight: 600;
}
.source-modal-body {
    padding: 14px 22px 20px; overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    font-size: 14.5px; line-height: 1.7; color: #2c2618;
    white-space: normal;
}
.source-modal-foot {
    padding: 12px 22px; border-top: 1px solid #ece5d6; background: #faf7ef;
}
.src-modal-link { color: #9a7b33; font-weight: 600; text-decoration: none; font-size: 13.5px; }
.src-modal-link:hover { color: #7c2230; text-decoration: underline; }
@media (max-width: 600px) {
    .source-modal { max-height: 90vh; border-radius: 12px; }
    .source-modal-overlay { padding: 0; align-items: flex-end; }
}

.modal form {
    padding: 30px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}


/* ============================================
   NOTIFICATIONS DROPDOWN
   ============================================ */

.notifications-dropdown {
    position: fixed;
    top: 70px;
    right: 20px;
    width: 380px;
    max-height: 500px;
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border);
}

.notifications-dropdown.hidden {
    display: none;
}

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

.notifications-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
}

.notifications-list {
    overflow-y: auto;
    max-height: 400px;
}

.notification-item {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    gap: 12px;
    cursor: pointer;
    transition: background 0.2s;
}

.notification-item:hover {
    background: var(--bg-hover);
}

.notification-item.unread {
    background: var(--bg-highlight);
}

.notification-item.unread:hover {
    background: var(--bg-hover);
}

.notification-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.notification-content {
    flex: 1;
}

.notification-content p {
    margin: 0;
    font-size: 14px;
    color: var(--text-light);
}

.notification-content strong {
    font-weight: 600;
    color: var(--text-dark);
}

.notification-time {
    font-size: 12px !important;
    color: var(--text-muted) !important;
    margin-top: 4px !important;
}

.notifications-footer {
    padding: 12px 20px;
    border-top: 1px solid var(--border);
    text-align: center;
}

.btn-text {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    padding: 0;
}

.btn-text:hover {
    text-decoration: underline;
}

/* ============================================
   VELKOMSTSKJERM MED ANIMASJONER
   ============================================ */

.welcome-screen {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 600px;
    padding: 40px 20px;
    background: var(--bg-light);
    overflow: hidden;
}

/* Flytende §-symboler i bakgrunnen */
.floating-symbols {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 1;
}

.floating-symbols .symbol {
    position: absolute;
    font-size: 80px;
    font-weight: bold;
    color: rgba(197, 160, 89, 0.15);
    font-family: 'Playfair Display', Georgia, serif;
    animation: floatAround 20s infinite ease-in-out;
}

.floating-symbols .s1 {
    top: 10%;
    left: 15%;
    animation-delay: 0s;
    animation-duration: 18s;
}

.floating-symbols .s2 {
    top: 20%;
    right: 20%;
    animation-delay: 2s;
    animation-duration: 22s;
}

.floating-symbols .s3 {
    bottom: 15%;
    left: 10%;
    animation-delay: 4s;
    animation-duration: 20s;
}

.floating-symbols .s4 {
    bottom: 25%;
    right: 15%;
    animation-delay: 6s;
    animation-duration: 24s;
}

.floating-symbols .s5 {
    top: 50%;
    left: 5%;
    animation-delay: 8s;
    animation-duration: 19s;
}

.floating-symbols .s6 {
    top: 40%;
    right: 8%;
    animation-delay: 10s;
    animation-duration: 21s;
}

@keyframes floatAround {
    0%, 100% {
        transform: translate(0, 0) rotate(0deg);
        opacity: 0.1;
    }
    25% {
        transform: translate(30px, -20px) rotate(5deg);
        opacity: 0.15;
    }
    50% {
        transform: translate(-20px, 30px) rotate(-5deg);
        opacity: 0.12;
    }
    75% {
        transform: translate(20px, 20px) rotate(3deg);
        opacity: 0.18;
    }
}

/* Hovedinnhold i midten */
.welcome-content {
    position: relative;
    z-index: 2;
    text-align: center;
    animation: fadeInUp 1s ease-out;
}

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

/* Logo animasjoner */
.welcome-logo-container {
    display: inline-block;
    margin-bottom: 30px;
}

.welcome-logo {
    display: block;
    filter: drop-shadow(0 10px 30px rgba(197, 160, 89, 0.3));
    animation: logoFloat 3s ease-in-out infinite;
}

@keyframes logoFloat {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-15px);
    }
}

.logo-circle-main {
    animation: logoRotate 20s linear infinite;
    transform-origin: center;
}

@keyframes logoRotate {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.logo-circle-pulse {
    animation: logoPulse 2s ease-in-out infinite;
    transform-origin: center;
}

@keyframes logoPulse {
    0%, 100% {
        r: 90;
        opacity: 0.5;
    }
    50% {
        r: 95;
        opacity: 0.2;
    }
}

/* Tekst styling */
.welcome-title {
    font-size: 48px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0 0 10px 0;
    font-family: 'Playfair Display', Georgia, serif;
    letter-spacing: -0.5px;
}

.welcome-subtitle {
    font-size: 24px;
    color: var(--text-light);
    margin: 0 0 20px 0;
    font-weight: 300;
    font-family: 'Inter', sans-serif;
}

.welcome-description {
    font-size: 16px;
    color: var(--text-muted);
    max-width: 500px;
    margin: 0 auto;
    line-height: 1.6;
    font-family: 'Inter', sans-serif;
}

/* Skjul velkomstskjerm når det er meldinger */
.chat-messages:has(.message) .welcome-screen {
    display: none;
}

/* Responsive design */
@media (max-width: 768px) {
    .welcome-screen {
        min-height: 400px;
        padding: 30px 15px;
    }
    
    .welcome-logo {
        width: 120px;
        height: 120px;
    }
    
    .welcome-title {
        font-size: 32px;
    }
    
    .welcome-subtitle {
        font-size: 18px;
    }
    
    .welcome-description {
        font-size: 14px;
    }
    
    .floating-symbols .symbol {
        font-size: 50px;
    }
}

/* ============================================
   DOCUMENT UPLOAD MODAL
   ============================================ */

.upload-area {
    border: 2px dashed var(--border);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    transition: all 0.2s;
    background: var(--bg-white);
}

.upload-area.drag-over {
    border-color: var(--primary); /* A11Y */
    background: var(--bg-highlight);
}

.upload-icon {
    font-size: 48px;
    margin-bottom: 15px;
}

.upload-hint {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 15px;
}

.progress-bar {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin: 20px 0;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    transition: width 0.3s ease;
    width: 0%;
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    pointer-events: auto;
    animation: toastSlideIn 0.3s ease;
    max-width: 400px;
    border-left: 4px solid var(--primary);
}

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

.toast.error {
    border-left-color: var(--danger);
}

.toast.warning {
    border-left-color: var(--warning);
}

.toast.info {
    border-left-color: #2196F3;
}

.toast-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.toast-message {
    flex: 1;
    font-size: 14px;
    color: var(--text-dark);
}

.toast-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-light);
    padding: 0;
    line-height: 1;
}

.toast-close:hover {
    color: var(--text-dark);
}

.toast.hiding {
    animation: toastSlideOut 0.3s ease forwards;
}

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

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

/* ============================================
   LOVDATA SEARCH
   ============================================ */

.lovdata-header {
    padding: 12px 20px;
    background: var(--gray-100);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
}

.lovdata-header h2 {
    font-size: 1.1rem;
    margin: 0;
    color: var(--text-dark);
}

.lovdata-subtitle {
    color: var(--text-muted);
    font-size: 0.85rem;
    margin: 0;
}

.lovdata-tabs {
    display: flex;
    gap: 6px;
    padding: 12px 20px;
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
}

.lovdata-tab {
    padding: 7px 18px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: transparent;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text-muted);
    transition: all 0.15s;
}

.lovdata-tab:hover {
    background: var(--gray-100);
    color: var(--text-dark);
}

.lovdata-tab.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.lovdata-tab-panel.hidden {
    display: none;
}

.lovdata-search-container {
    padding: 16px 20px;
    background: var(--bg-white);
    margin: 0;
    border-bottom: 1px solid var(--border);
}

.lovdata-search-box {
    display: flex;
    gap: 12px;
    margin-bottom: 15px;
}

.lovdata-search-input {
    flex: 1;
    padding: 15px 20px;
    font-size: 16px;
    border: 2px solid var(--border);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.2s;
}

.lovdata-search-input:focus {
    border-color: var(--primary-text); /* A11Y */
    box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.3);
}

.lovdata-search-box .btn-primary {
    padding: 15px 30px;
    font-size: 16px;
    white-space: nowrap;
}

.lovdata-filters {
    display: flex;
    gap: 12px;
}

.lovdata-filters select {
    padding: 10px 15px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    background: var(--bg-white);
    cursor: pointer;
}

#lovdata-view {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.lovdata-results {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.lovdata-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-light);
}

.lovdata-empty-icon {
    font-size: 80px;
    margin-bottom: 20px;
}

.lovdata-empty-state h3 {
    font-size: 24px;
    color: var(--text-dark);
    margin-bottom: 10px;
}

.lovdata-examples {
    margin-top: 30px;
}

.lovdata-examples p {
    margin-bottom: 15px;
}

.example-search {
    display: inline-block;
    margin: 5px;
    padding: 8px 16px;
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.example-search:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary-text); /* A11Y */
}

.lovdata-loading {
    text-align: center;
    padding: 60px;
}

.lovdata-loading .spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border);
    border-top-color: var(--primary-text); /* A11Y */
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 20px;
}

.lovdata-results-header {
    padding: 15px 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.lovdata-result-card {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid var(--primary);
    transition: transform 0.2s, box-shadow 0.2s;
}

.lovdata-result-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.lovdata-result-card.law {
    border-left-color: #2196F3;
}

.lovdata-result-card.regulation {
    border-left-color: #9C27B0;
}

.dommer-result-card {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
    border-left: 4px solid #E67E22;
    transition: transform 0.2s, box-shadow 0.2s;
}

.dommer-result-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.doc-type-badge.dommer {
    background: #FEF3E2;
    color: #B7450C;
}

.lovdata-result-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 15px;
}

.lovdata-result-title h3 {
    font-size: 18px;
    color: var(--text-dark);
    margin: 5px 0;
}

.paragraph-title {
    color: var(--text-light);
    font-size: 14px;
}

.doc-type-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.doc-type-badge.law {
    background: #E3F2FD;
    color: #1565C0;
}

.doc-type-badge.regulation {
    background: #F3E5F5;
    color: #7B1FA2;
}

.score-badge {
    background: var(--primary);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 600;
}

.lovdata-result-content {
    margin-bottom: 15px;
}

.law-text {
    background: #FAFAFA;
    padding: 20px;
    border-radius: 8px;
    font-size: 15px;
    line-height: 1.8;
    color: var(--text-dark);
    white-space: pre-wrap;
    border: 1px solid #EEEEEE;
}

.law-text mark {
    background: #FFF59D;
    padding: 2px 4px;
    border-radius: 3px;
}

.lovdata-result-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    font-size: 13px;
    color: var(--text-light);
    padding-top: 15px;
    border-top: 1px solid var(--border);
}

.meta-item {
    display: flex;
    align-items: center;
    gap: 5px;
}

.lovdata-no-results,
.lovdata-error {
    text-align: center;
    padding: 60px;
    color: var(--text-light);
}

.lovdata-error .error-detail {
    margin-top: 10px;
    font-size: 14px;
    color: var(--danger);
}

/* Responsive */
@media (max-width: 768px) {
    .lovdata-header {
        padding: 10px 16px;
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .lovdata-header h2 {
        font-size: 1rem;
    }

    .lovdata-search-container {
        margin: 0 10px;
        padding: 12px;
    }

    .lovdata-search-box {
        flex-direction: column;
    }

    .lovdata-filters {
        flex-direction: column;
    }

    .lovdata-result-header {
        flex-direction: column;
        gap: 10px;
    }

    .lovdata-result-meta {
        flex-direction: column;
        gap: 8px;
    }
}

/* ============================================
   ADDITIONAL RESPONSIVE FIXES
   ============================================ */

/* Tablet breakpoint */
@media (max-width: 1024px) {
    .sidebar {
        width: 200px;
    }

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

/* Mobile breakpoint - additional fixes */
@media (max-width: 768px) {
    /* Modal responsive */
    .modal-content {
        width: 95%;
        max-width: none;
        margin: 10px;
        max-height: 90vh;
        overflow-y: auto;
    }

    .modal-body {
        padding: 15px;
    }

    /* Email list truncation fix */
    .email-preview {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 100%;
    }

    /* Chat messages */
    .chat-messages {
        padding: 12px 16px;
    }

    .message {
        max-width: 95%;
    }

    #welcome-screen {
        grid-template-columns: 1fr;
        padding: 20px 16px;
    }

    .chat-input-wrapper {
        padding: 12px 16px;
    }

    /* Notifications dropdown */
    .notifications-dropdown {
        right: 10px;
        left: 10px;
        width: auto;
    }

    /* Toast notifications */
    .toast-container {
        left: 10px;
        right: 10px;
        top: 10px;
    }

    .toast {
        max-width: none;
    }

    /* Chat header */
    .chat-header {
        padding: 10px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .chat-header h2 {
        flex: 1;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .chat-header .chat-actions {
        width: 100%;
    }

    .chat-header .chat-actions .search-input {
        max-width: 100%;
    }

    /* View headers - wrap actions to next row on mobile */
    .email-header,
    .cases-header,
    .documents-header,
    .conversations-header {
        flex-wrap: wrap;
        gap: 8px;
        padding: 12px 16px;
    }

    .email-header h2,
    .cases-header h2,
    .documents-header h2,
    .conversations-header h2 {
        flex: 1;
        min-width: 0;
    }

    .email-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .email-actions .search-input,
    .conversations-header .search-input {
        max-width: 100%;
        flex: 1;
    }

    .email-actions .btn-primary,
    .cases-header .btn-primary,
    .documents-header .btn-primary {
        width: 100%;
        justify-content: center;
    }

    .profile-header {
        padding: 14px 16px;
    }

    /* Content padding reductions */
    .cases-list,
    .documents-list {
        padding: 16px;
    }

    /* Documents table - horizontal scroll */
    .documents-list {
        overflow-x: auto;
    }

    .documents-table {
        min-width: 360px;
    }
}

/* Small phone breakpoint */
@media (max-width: 480px) {
    .chat-header h2 {
        font-size: 18px;
    }

    .btn-primary {
        padding: 10px 16px;
        font-size: 14px;
    }

    .sidebar-btn {
        padding: 10px 12px;
        font-size: 14px;
    }

    .welcome-title {
        font-size: 24px;
    }

    .welcome-logo {
        width: 100px;
        height: 100px;
    }
}

/* ============================================
   FULL LAW VIEW (inline, replaces search results)
   ============================================ */

.full-law-view {
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.full-law-header {
    display: flex;
    align-items: center;
    gap: 20px;
    padding: 20px 24px;
    background: linear-gradient(135deg, #1a365d 0%, #2d4a7c 100%);
    border-bottom: 1px solid var(--border);
}

.btn-back-to-results {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-back-to-results:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

.full-law-title {
    margin: 0;
    font-size: 1.4rem;
    color: white;
    font-weight: 600;
}

.full-law-view .full-law-body {
    padding: 24px;
    max-height: calc(100vh - 280px);
    overflow-y: auto;
}

.full-law-view .full-law-info {
    background: #f0f7ff;
    padding: 16px 20px;
    border-radius: 10px;
    margin-bottom: 24px;
    border-left: 4px solid var(--primary);
}

.full-law-view .full-law-info p {
    margin: 0;
    color: var(--text-dark);
}

.full-law-view .law-chapter-header {
    margin: 32px 0 16px 0;
    padding-bottom: 8px;
    border-bottom: 2px solid var(--primary);
}

.full-law-view .law-chapter-header h3 {
    margin: 0;
    color: var(--secondary);
    font-size: 1.1rem;
}

.full-law-view .full-law-paragraph,
.full-law-body .full-law-paragraph {
    background: var(--gray-100);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
    border-left: 4px solid var(--primary);
    position: relative;
    display: block;
    clear: both;
}

/* General paragraph styling (fallback) */
.full-law-paragraph {
    background: var(--gray-100);
    border-radius: 10px;
    padding: 20px;
    margin-bottom: 16px;
    border-left: 4px solid var(--primary);
    position: relative;
    display: block;
}

.full-law-view .paragraph-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    flex-wrap: wrap;
    gap: 8px;
}

.full-law-view .paragraph-id {
    font-weight: 700;
    color: var(--primary-dark);
    font-size: 1.05rem;
}

.full-law-view .paragraph-title {
    color: var(--text-dark);
    font-weight: 500;
}

.full-law-view .paragraph-content {
    color: var(--text-dark);
    line-height: 1.7;
    white-space: pre-wrap;
}

/* Responsive for full law view */
@media (max-width: 768px) {
    .full-law-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        padding: 16px;
    }

    .full-law-title {
        font-size: 1.1rem;
    }

    .full-law-view .full-law-body {
        padding: 16px;
        max-height: calc(100vh - 320px);
    }

    .full-law-view .full-law-paragraph {
        padding: 16px;
    }
}

/* ============================================
   FULL LAW MODAL (deprecated, kept for compatibility)
   ============================================ */

.modal.full-law-modal {
    display: none !important;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    overflow-y: auto;
}

.modal.full-law-modal.active {
    display: flex !important;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
}

.full-law-modal-content {
    background: var(--bg-white);
    border-radius: 16px;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    margin: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.full-law-modal-content .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, #1a365d 0%, #2d4a7c 100%);
    border-radius: 16px 16px 0 0;
}

.full-law-modal-content .modal-header h2 {
    margin: 0;
    font-size: 22px;
    color: white;
}

.full-law-modal-content .close-modal {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 28px;
    cursor: pointer;
    padding: 5px 12px;
    border-radius: 8px;
    transition: background 0.2s;
}

.full-law-modal-content .close-modal:hover {
    background: rgba(255, 255, 255, 0.3);
}

.full-law-body {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
}

.full-law-info {
    background: #f0f7ff;
    padding: 15px 20px;
    border-radius: 10px;
    margin-bottom: 25px;
    border-left: 4px solid var(--primary);
}

.full-law-info p {
    margin: 0;
    color: var(--text-dark);
}

.law-chapter-header {
    background: linear-gradient(135deg, #e8f4fd 0%, #d0e8f9 100%);
    padding: 15px 20px;
    border-radius: 10px;
    margin: 25px 0 15px;
    border-left: 4px solid #2196F3;
}

.law-chapter-header h3 {
    margin: 0;
    font-size: 16px;
    color: #1565C0;
    font-weight: 600;
}

.paragraph-header {
    display: flex;
    align-items: baseline;
    gap: 12px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.paragraph-id {
    font-weight: 700;
    color: var(--primary-text); /* A11Y */
    font-size: 16px;
    background: #e8f4fd;
    padding: 4px 10px;
    border-radius: 6px;
}

.paragraph-title-full {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 15px;
}

.paragraph-content {
    color: var(--text-dark);
    line-height: 1.7;
    font-size: 15px;
    white-space: pre-wrap;
}

/* Button style for "Se hele loven" */
.lovdata-result-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.btn-view-full-law {
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: white;
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-view-full-law:hover {
    background: linear-gradient(135deg, #1d4ed8 0%, #1e40af 100%);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(197, 160, 89, 0.3);
}

/* Responsive for full law modal */
@media (max-width: 768px) {
    .full-law-modal.active {
        padding: 10px;
    }

    .full-law-modal-content {
        max-height: 95vh;
    }

    .full-law-modal-content .modal-header {
        padding: 15px 20px;
    }

    .full-law-modal-content .modal-header h2 {
        font-size: 18px;
    }

    .full-law-body {
        padding: 15px;
    }

    .full-law-paragraph {
        padding: 15px;
    }

    .paragraph-header {
        flex-direction: column;
        gap: 8px;
    }

    .btn-view-full-law {
        padding: 6px 10px;
        font-size: 12px;
    }

    .lovdata-result-actions {
        flex-direction: column;
        align-items: flex-end;
        gap: 8px;
    }
}

/* ============================================
   SKELETON LOADING (UX-004)
   ============================================ */

.skeleton {
    background: linear-gradient(90deg, var(--bg-light) 25%, var(--bg-hover) 50%, var(--bg-light) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

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

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-text.short { width: 40%; }
.skeleton-text.medium { width: 70%; }
.skeleton-text.long { width: 100%; }

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-card {
    padding: 16px;
    margin-bottom: 12px;
    border-radius: 8px;
    background: var(--bg-white);
    border: 1px solid var(--border);
}

.skeleton-list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.skeleton-list-item .skeleton-content {
    flex: 1;
}

/* Email list skeleton */
.email-skeleton {
    padding: 15px;
    border-bottom: 1px solid var(--border);
}

.email-skeleton-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.email-skeleton-body {
    margin-top: 8px;
}

/* Conversation skeleton */
.conversation-skeleton {
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 8px;
}

/* ============================================
   OFFLINE MODE STYLES
   ============================================ */

body.offline::before {
    content: 'Frakoblet';
    position: fixed;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    background: var(--warning);
    color: white;
    padding: 4px 16px;
    font-size: 12px;
    font-weight: bold;
    border-radius: 0 0 8px 8px;
    z-index: 10000;
}

body.offline .sidebar button:not(.logout-btn),
body.offline .chat-input,
body.offline .email-compose-btn {
    opacity: 0.5;
    pointer-events: none;
}

/* ============================================
   BEM COMPONENT STYLES
   Following BEM methodology for new components
   ============================================ */

/* Card Component (BEM) */
.card {
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card__header {
    padding: 16px;
    border-bottom: 1px solid var(--border);
}

.card__title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-dark);
    margin: 0;
}

.card__body {
    padding: 16px;
}

.card__footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    background: var(--gray-100);
}

.card--highlighted {
    border-left: 4px solid var(--primary);
}

.card--compact .card__header,
.card--compact .card__body,
.card--compact .card__footer {
    padding: 12px;
}

/* Button Component (BEM) */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn__icon {
    font-size: 16px;
}

.btn__text {
    white-space: nowrap;
}

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

.btn--primary:hover {
    background: var(--primary-dark);
}

.btn--secondary {
    background: var(--gray-200);
    color: var(--text-dark);
}

.btn--secondary:hover {
    background: var(--gray-300);
}

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

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

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

.btn--ghost:hover {
    background: var(--gray-100);
}

.btn--small {
    padding: 6px 12px;
    font-size: 13px;
}

.btn--large {
    padding: 14px 28px;
    font-size: 16px;
}

.btn--disabled,
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

/* Form Component (BEM) */
.form__group {
    margin-bottom: 16px;
}

.form__label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-dark);
}

.form__input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form__input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.3);
}

.form__input--error {
    border-color: var(--danger);
}

.form__input--error:focus {
    box-shadow: 0 0 0 3px rgba(244, 67, 54, 0.2);
}

.form__error {
    margin-top: 4px;
    font-size: 13px;
    color: var(--danger);
}

.form__hint {
    margin-top: 4px;
    font-size: 13px;
    color: var(--text-muted);
}

/* Alert Component (BEM) */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    font-size: 14px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.alert__icon {
    font-size: 18px;
    flex-shrink: 0;
}

.alert__content {
    flex: 1;
}

.alert__title {
    font-weight: 600;
    margin-bottom: 4px;
}

.alert__message {
    color: inherit;
    opacity: 0.9;
}

.alert--success {
    background: var(--success-bg);
    color: var(--success-text);
    border: 1px solid var(--success);
}

.alert--error {
    background: var(--danger-bg);
    color: var(--danger-text);
    border: 1px solid var(--danger);
}

.alert--warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid var(--warning);
}

.alert--info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid var(--info);
}

/* Badge Component (BEM) */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 12px;
}

.badge--primary {
    background: rgba(201, 165, 90, 0.2);
    color: var(--primary-text);
}

.badge--success {
    background: var(--success-bg);
    color: var(--success-text);
}

.badge--danger {
    background: var(--danger-bg);
    color: var(--danger-text);
}

.badge--warning {
    background: #fff3cd;
    color: #856404;
}

.badge--neutral {
    background: var(--gray-200);
    color: var(--gray-600);
}

/* State Classes */
.is-active {
    color: var(--primary) !important;
    background: var(--bg-highlight) !important;
}

.is-loading {
    opacity: 0.7;
    pointer-events: none;
}

.is-disabled {
    opacity: 0.5;
    pointer-events: none;
}

.has-error {
    border-color: var(--danger) !important;
}

/* Utility Classes */
.u-text-center { text-align: center; }
.u-text-right { text-align: right; }
.u-text-muted { color: var(--text-muted); }
.u-mt-8 { margin-top: 8px; }
.u-mt-16 { margin-top: 16px; }
.u-mb-8 { margin-bottom: 8px; }
.u-mb-16 { margin-bottom: 16px; }
.u-flex { display: flex; }
.u-flex-center { display: flex; align-items: center; justify-content: center; }
.u-gap-8 { gap: 8px; }
.u-gap-16 { gap: 16px; }

/* ============================================
   TIMELINE GENERATOR (BUG-001)
   ============================================ */

.timeline-header {
    margin-bottom: 20px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.timeline-header > div {
    flex: 1;
}

.timeline-header h2 {
    color: var(--secondary);
    font-size: 24px;
    margin-bottom: 8px;
}

.timeline-subtitle {
    color: var(--text-light);
    font-size: 14px;
}

.timeline-controls {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    margin-bottom: 24px;
    padding: 20px;
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

.timeline-controls .form-group {
    flex: 1;
    margin-bottom: 0;
}

.timeline-controls select {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg-white);
}

.timeline-controls select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.3);
}

.timeline-result {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow-sm);
}

.timeline-empty {
    text-align: center;
    padding: 60px 20px;
    background: var(--bg-white);
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
}

.timeline-empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

.timeline-empty h3 {
    color: var(--text-dark);
    margin-bottom: 8px;
}

.timeline-empty p {
    color: var(--text-light);
}

.timeline-no-events {
    text-align: center;
    color: var(--text-muted);
    padding: 40px;
}

/* Timeline visual styles */
.timeline {
    position: relative;
    padding: 20px 0;
}

.timeline::before {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    width: 3px;
    height: 100%;
    background: linear-gradient(to bottom, var(--primary), var(--primary-dark));
    border-radius: 3px;
}

.timeline-event {
    position: relative;
    width: 45%;
    padding: 16px;
    margin-bottom: 24px;
}

.timeline-event.left {
    margin-right: auto;
    text-align: right;
    padding-right: 40px;
}

.timeline-event.right {
    margin-left: auto;
    text-align: left;
    padding-left: 40px;
}

.timeline-event-marker {
    position: absolute;
    top: 20px;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border: 3px solid var(--bg-white);
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(61, 51, 33, 0.2);
}

.timeline-event.left .timeline-event-marker {
    right: -8px;
}

.timeline-event.right .timeline-event-marker {
    left: -8px;
}

.timeline-event-content {
    background: var(--bg-white);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s, transform 0.2s;
}

.timeline-event-content:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.timeline-event-date {
    font-size: 12px;
    color: var(--primary-text);
    font-weight: 600;
    margin-bottom: 8px;
}

.timeline-event-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 4px;
}

.timeline-event-description {
    font-size: 14px;
    color: var(--text-light);
    line-height: 1.5;
}

.timeline-event-type {
    display: inline-block;
    margin-top: 8px;
    padding: 4px 8px;
    background: var(--bg-highlight);
    color: var(--primary-text);
    font-size: 12px;
    border-radius: 4px;
}

/* Timeline responsive */
@media (max-width: 768px) {
    .timeline-controls {
        flex-direction: column;
        align-items: stretch;
    }

    .timeline::before {
        left: 20px;
    }

    .timeline-event {
        width: calc(100% - 40px);
        margin-left: 40px !important;
        margin-right: 0 !important;
        text-align: left !important;
        padding-left: 20px !important;
        padding-right: 0 !important;
    }

    .timeline-event-marker {
        left: -28px !important;
        right: auto !important;
    }
}

/* Timeline text response (when AI returns plain text) */
.timeline-text-response {
    background: var(--bg-white);
    border-radius: 12px;
    padding: 24px;
    line-height: 1.7;
    color: var(--text-dark);
    box-shadow: var(--shadow-sm);
}

.timeline-text-response h2 {
    color: var(--primary-dark);
    margin: 16px 0 8px 0;
    font-size: 1.3rem;
}

.timeline-text-response h3 {
    color: var(--secondary);
    margin: 12px 0 6px 0;
    font-size: 1.1rem;
}

.timeline-text-response p {
    margin-bottom: 12px;
}

.timeline-text-response li {
    margin-left: 20px;
    margin-bottom: 4px;
}

.timeline-text-response strong {
    color: var(--primary-dark);
}

/* Timeline actions bar */
.timeline-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

.timeline-actions .btn-secondary {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Editable timeline */
#timeline-editable {
    min-height: 200px;
    outline: none;
    border: 2px solid transparent;
    border-radius: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#timeline-editable:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(197, 160, 89, 0.3);
}

#timeline-editable:hover:not(:focus) {
    border-color: var(--border);
}

/* Edit hint */
.timeline-edit-hint {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    margin-top: 12px;
    font-style: italic;
}



/* ═══════════════════════════════════════
   SmartJuss A4 Document Renderer
   ═══════════════════════════════════════ */

#sj-print-container {
  position: fixed;
  top: -9999px;
  left: -9999px;
  width: 794px;
  overflow: visible;
  background: white;
}

.sj-doc {
  position: relative;
  width: 794px;
  min-height: 1123px;
  padding: 95px 95px 76px 113px; /* 25mm top, 25mm right, 20mm bottom, 30mm left */
  font-family: 'Times New Roman', Times, serif;
  font-size: 12pt;
  line-height: 1.5;
  color: #000;
  background: white;
  box-sizing: border-box;
}

.sj-doc-watermark {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-45deg);
  font-size: 80pt;
  font-family: 'Times New Roman', serif;
  color: rgba(0, 0, 0, 0.04);
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  z-index: 0;
}

.sj-doc > *:not(.sj-doc-watermark) {
  position: relative;
  z-index: 1;
}

.sj-doc-header {
  display: flex;
  justify-content: flex-end;
  align-items: flex-start;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid #C5A059;
}

.sj-doc-type-badge {
  font-size: 9pt;
  background: #f5f0e8;
  border: 1px solid #C5A059;
  color: #8B7355;
  padding: 4px 10px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.sj-doc-date {
  margin-bottom: 16px;
  font-size: 11pt;
  color: #555;
}

.sj-rule {
  border: none;
  border-top: 0.5px solid #bbb;
  margin: 12px 0;
}

.sj-parties {
  display: flex;
  gap: 40px;
  margin-bottom: 16px;
}

.sj-sender, .sj-recipient {
  flex: 1;
}

.sj-party-label {
  font-size: 9pt;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #888;
  margin-bottom: 4px;
  font-family: Arial, sans-serif;
}

.sj-parties p {
  margin: 0;
  line-height: 1.45;
  font-size: 11pt;
}

.sj-subject {
  margin-bottom: 16px;
  font-size: 11pt;
}

.sj-body {
  margin-top: 8px;
}

.sj-body p {
  margin: 0 0 10px;
  text-align: justify;
  font-size: 12pt;
}

.sj-body h3 {
  font-size: 12pt;
  font-weight: bold;
  margin: 16px 0 6px;
}

.sj-body ul {
  margin: 0 0 10px 1.5em;
  padding: 0;
}

.sj-body li {
  margin-bottom: 4px;
  font-size: 12pt;
}

.sj-signature {
  margin-top: 32px;
}

.sj-sig-line {
  border-bottom: 1px solid #000;
  width: 180px;
  margin-bottom: 6px;
  margin-top: 8px;
}

.sj-sig-name, .sj-sig-org {
  margin: 0;
  font-size: 11pt;
}

.sj-footer {
  margin-top: 40px;
  padding-top: 8px;
  border-top: 0.5px solid #ddd;
  font-size: 7pt;
  text-align: center;
  color: #aaa;
  font-family: Arial, sans-serif;
}

.sj-footer-note {
  margin-top: 4px;
  font-size: 7pt;
  font-style: italic;
  color: #bbb;
}

.sj-footer-link {
  color: #1a6bc1;
  text-decoration: underline;
}

/* ============================================
   MOBIL BUNNNAVIGASJON
   ============================================ */

.mobile-bottom-nav {
    display: none;
}

@media (max-width: 768px) {
    .mobile-bottom-nav {
        display: flex;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 60px;
        background: var(--bg-white);
        border-top: 1px solid var(--border);
        z-index: 997;
        box-shadow: 0 -2px 8px rgba(61,51,33,0.08);
    }

    .mobile-nav-btn {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 3px;
        background: none;
        border: none;
        cursor: pointer;
        padding: 8px 4px;
        color: var(--text-muted);
        transition: color 0.2s;
    }

    .mobile-nav-btn.active {
        color: var(--primary);
    }

    .mobile-nav-icon {
        font-size: 20px;
        line-height: 1;
    }

    .mobile-nav-label {
        font-size: 11px;
        font-weight: 500;
    }

    .app-layout {
        padding-bottom: 60px;
    }

    .chat-input-container {
        padding-bottom: 16px;
    }

    /* Lovdata søk - mobil-polering */
    .lovdata-search-box .btn-primary {
        width: 100%;
        justify-content: center;
    }

    .lovdata-filters select {
        width: 100%;
    }

    .lovdata-examples .example-search {
        display: block;
        width: 100%;
        text-align: left;
        margin: 4px 0;
    }
}

/* ============================================
   ACCESSIBILITY: REDUCED MOTION
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ===== Cookie-samtykkebanner (GDPR) ===== */
.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 11000;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    flex-wrap: wrap;
    padding: 16px 24px;
    background: #2b2419;
    color: #f5efe3;
    box-shadow: 0 -2px 16px rgba(0,0,0,0.25);
}
.cookie-banner.hidden { display: none; }
.cookie-banner-text { flex: 1 1 320px; font-size: 0.9rem; line-height: 1.5; }
.cookie-banner-text strong { display: block; margin-bottom: 4px; }
.cookie-banner-text p { margin: 0; color: #d9cfbd; }
.cookie-banner-text a { color: #e0b667; text-decoration: underline; }
.cookie-banner-actions { display: flex; gap: 10px; flex-shrink: 0; }
.cookie-btn {
    padding: 10px 22px;
    border-radius: 8px;
    border: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    min-height: 44px;
}
.cookie-btn-primary { background: #c9a55a; color: #2b2419; }
.cookie-btn-primary:hover { background: #d9b76a; }
.cookie-btn-secondary { background: transparent; color: #f5efe3; border: 1px solid #6b5f49; }
.cookie-btn-secondary:hover { background: rgba(255,255,255,0.08); }
@media (max-width: 480px) {
    .cookie-banner { flex-direction: column; align-items: stretch; text-align: left; }
    .cookie-banner-actions { justify-content: flex-end; }
}

/* ===== Utskrift: rene A4-dokumenter (skjul UI-chrome) ===== */
@media print {
    .sidebar, .mobile-bottom-nav, .topbar, .chat-input-container, .chat-composer,
    #cookie-banner, .skip-link, .btn-upgrade, .mobile-menu-toggle,
    .message-actions, .typing, .composer, .chat-disclaimer {
        display: none !important;
    }
    body, .app, #app, .main-content, .chat-messages {
        background: #fff !important;
        color: #000 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: visible !important;
        height: auto !important;
    }
    .message { page-break-inside: avoid; box-shadow: none !important; }
    a[href]::after { content: ""; }
}

/* ===== Klikkbar kildevisning i chat ===== */
.citation-marker { font-size: 0.7em; line-height: 0; }
.citation-marker a { color: #a67c2e; text-decoration: none; font-weight: 600; padding: 0 1px; }
.citation-marker a:hover { text-decoration: underline; }
.citation-list {
    margin-top: 14px;
    padding: 12px 14px;
    background: #faf6ee;
    border: 1px solid #e7dcc4;
    border-radius: 10px;
    font-size: 0.85rem;
}
.citation-list-title {
    font-weight: 700;
    color: #5a4e3b;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-size: 0.72rem;
}
.citation-item { margin: 5px 0; line-height: 1.45; }
.citation-ref { color: #a67c2e; font-weight: 600; margin-right: 4px; }
.citation-item a { color: #2b6bc1; text-decoration: none; }
.citation-item a:hover { text-decoration: underline; }
.citation-source { color: #8a7d63; font-size: 0.78rem; }

/* ===== Vedleggschips på meldingsbobler ===== */
.message-attachments {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.message.user .message-attachments .attachment-chip {
    background: rgba(255,255,255,0.18);
    color: inherit;
}
.conversation-attach-icon {
    margin-left: 4px;
    opacity: 0.7;
    font-size: 0.85em;
}

/* ============================================================
   ARBEIDSFLATE — tre-panel (Sak = Notatbok). Prefiks: ws-
   ============================================================ */
.ws-app{
  /* SmartJuss-merkevare: gull / beige / mørk brun — lyst, integrert tema */
  --ws-ink:#3D3321; --ws-ink-soft:#5A4E3B; --ws-paper:#FFFFFF; --ws-panel:#FAF7F0;
  --ws-line:#E6DFD0; --ws-line-soft:#F0EBE0; --accent:#C5A059; --accent-dark:#A88542; --ws-accent-soft:#FFFBF0;
  --blue:#A88542; --ws-blue-soft:#FBF6EA; --ws-ok:#4caf50; --ws-muted:#8A7E6B;
  display:flex;flex-direction:column;height:100%;min-height:0;background:#fff;
  font-family:'Inter',-apple-system,BlinkMacSystemFont,"Segoe UI",system-ui,sans-serif;color:var(--ws-ink);
}
#workspace-view{height:100%;padding:0;overflow:hidden;}
.ws-topbar{height:54px;flex:0 0 54px;display:flex;align-items:center;gap:14px;padding:0 22px;background:#fff;color:var(--ws-ink);border-bottom:1px solid var(--ws-line);}
.ws-topbar::before{content:"Arbeidsflate";font-family:'Playfair Display',Georgia,serif;font-weight:700;font-size:17px;color:var(--ws-ink);letter-spacing:.2px;white-space:nowrap;}
.ws-topbar .ws-case{font-size:12.5px;color:var(--ws-muted);border-left:1px solid var(--ws-line);padding-left:14px;}
.ws-topbar .ws-spacer{flex:1}
.ws-topbar .ws-pill{font-size:11.5px;background:var(--ws-accent-soft);color:var(--accent-dark);padding:5px 12px;border-radius:20px;border:1px solid rgba(197,160,89,0.32);font-weight:600;}
.ws-cols{flex:1;display:flex;min-height:0;}
.ws-panel{display:flex;flex-direction:column;min-height:0;background:var(--ws-paper);}
.ws-col-sources{flex:0 0 280px;background:var(--ws-panel);border-right:1px solid var(--ws-line);}
.ws-col-chat{flex:1;min-width:0;}
.ws-col-studio{flex:0 0 312px;background:var(--ws-panel);border-left:1px solid var(--ws-line);}
.ws-phead{flex:0 0 auto;padding:15px 18px 13px;border-bottom:1px solid var(--ws-line);display:flex;align-items:baseline;justify-content:space-between;background:rgba(255,255,255,0.45);}
.ws-phead h2{font-family:'Playfair Display',Georgia,serif;font-size:15px;letter-spacing:.2px;color:var(--ws-ink);font-weight:700;}
.ws-pbody{flex:1;overflow-y:auto;padding:16px 15px 30px;}
.ws-zone-label{font-size:11px;font-weight:700;letter-spacing:.4px;color:var(--ws-ink-soft);display:flex;align-items:center;gap:7px;margin:6px 2px 10px;}
.ws-zone-label .ws-dot{width:7px;height:7px;border-radius:50%;}
.ws-dot.blue{background:var(--blue)} .ws-dot.burg{background:var(--accent)}
.ws-zone-sub{font-size:11px;color:var(--ws-muted);font-weight:400;margin-left:auto;}
.ws-src{display:flex;gap:11px;align-items:flex-start;padding:10px 11px;border-radius:11px;cursor:pointer;margin-bottom:7px;background:#fff;border:1px solid var(--ws-line);box-shadow:0 1px 3px rgba(61,51,33,0.05);transition:transform .16s ease,box-shadow .16s ease,border-color .16s ease;}
.ws-src:hover{transform:translateY(-1px);box-shadow:0 5px 16px rgba(61,51,33,0.1);border-color:var(--accent);}
.ws-src.on{background:var(--ws-accent-soft);border-color:var(--accent);box-shadow:0 2px 10px rgba(197,160,89,0.2);}
.ws-src .ws-ico{flex:0 0 28px;height:28px;border-radius:8px;display:flex;align-items:center;justify-content:center;font-size:12px;font-weight:700;color:#fff;margin-top:1px;box-shadow:0 2px 6px rgba(61,51,33,0.18);}
.ws-ico.law{background:linear-gradient(135deg,#C5A059,#A88542)} .ws-ico.court{background:linear-gradient(135deg,#8B7355,#5A4E3B)} .ws-ico.tryg{background:linear-gradient(135deg,#B8924E,#8A6D3B)} .ws-ico.file{background:linear-gradient(135deg,#A88542,#7A5E2E)}
.ws-src.unavailable{opacity:.55;cursor:default;}
.ws-src.unavailable:hover{transform:none;box-shadow:0 1px 3px rgba(61,51,33,0.05);border-color:var(--ws-line);}
.ws-src.unavailable .ws-ico{filter:grayscale(0.45);}
.ws-soon{align-self:center;font-size:9.5px;font-weight:700;text-transform:uppercase;letter-spacing:.4px;color:var(--ws-muted);background:var(--ws-panel);border:1px solid var(--ws-line);padding:2px 7px;border-radius:10px;white-space:nowrap;}
.ws-loading-src{color:var(--ws-muted);font-size:12px;padding:10px 4px;}
.ws-new-conv-btn{margin-left:auto;font-size:11px;font-weight:700;color:var(--accent);background:var(--ws-accent-soft);border:1px solid var(--accent);border-radius:9px;padding:2px 9px;cursor:pointer;line-height:1.6;}
.ws-new-conv-btn:hover{background:var(--accent);color:#fff;}
.ws-conv-item{display:flex;flex-direction:column;gap:2px;width:100%;text-align:left;padding:8px 11px;border-radius:11px;cursor:pointer;margin-bottom:7px;background:#fff;border:1px solid var(--ws-line);box-shadow:0 1px 3px rgba(61,51,33,0.05);transition:transform .16s ease,box-shadow .16s ease,border-color .16s ease;}
.ws-conv-item:hover{transform:translateY(-1px);box-shadow:0 5px 16px rgba(61,51,33,0.1);border-color:var(--accent);}
.ws-conv-item.active{background:var(--ws-accent-soft);border-color:var(--accent);}
.ws-conv-title{font-size:12.5px;font-weight:600;color:var(--ws-ink);line-height:1.25;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.ws-conv-meta{font-size:11px;color:var(--ws-muted);}
.ws-src .ws-meta{min-width:0;flex:1}
.ws-src .ws-ttl{font-size:12.5px;font-weight:600;color:var(--ws-ink);line-height:1.25;}
.ws-src .ws-desc{font-size:11px;color:var(--ws-muted);margin-top:2px;}
.ws-src .ws-chk{flex:0 0 16px;height:16px;border-radius:4px;border:1.5px solid var(--ws-line);margin-top:4px;display:flex;align-items:center;justify-content:center;font-size:10px;color:#fff;}
.ws-src.on .ws-chk{background:var(--ws-ok);border-color:var(--ws-ok);}
.ws-scope{font-size:11px;color:var(--ws-ink-soft);background:var(--ws-blue-soft);border:1px solid #d4e0ec;border-radius:8px;padding:9px 11px;margin:4px 2px 16px;line-height:1.45;}
.ws-scope b{color:var(--blue)}
.ws-dropzone{border:1.5px dashed #cfc8ba;border-radius:10px;padding:16px 12px;text-align:center;color:var(--ws-muted);font-size:11.5px;margin-top:8px;cursor:pointer;line-height:1.5;transition:border-color .15s,background .15s;}
.ws-dropzone:hover{border-color:var(--accent);background:var(--ws-accent-soft);color:var(--accent);}
.ws-dropzone .ws-big{font-size:18px;display:block;margin-bottom:4px;}
.ws-dz-over{border-color:var(--accent)!important;background:var(--ws-accent-soft)!important;color:var(--accent)!important;}
.ws-doc-del{margin-left:auto;align-self:center;background:none;border:none;color:var(--ws-muted);font-size:18px;line-height:1;cursor:pointer;padding:0 4px;flex:0 0 auto;}
.ws-doc-del:hover{color:var(--accent-dark);}
.ws-chat-scroll{flex:1;overflow-y:auto;padding:26px 0;}
.ws-turn{max-width:680px;margin:0 auto 26px;padding:0 30px;}
.ws-who{font-size:11px;font-weight:700;letter-spacing:.5px;text-transform:uppercase;color:var(--ws-muted);margin-bottom:7px;}
.ws-who.ai{color:var(--accent)}
.ws-q{font-family:'Playfair Display',Georgia,serif;font-size:18px;line-height:1.46;color:var(--ws-ink);font-weight:600;}
.ws-a{font-size:15px;line-height:1.72;color:var(--ws-ink-soft);}
.ws-a p{margin-bottom:12px;}
.ws-cite{background:var(--ws-accent-soft);color:var(--accent-dark);font-size:11.5px;font-weight:600;padding:1px 7px;border-radius:6px;cursor:pointer;white-space:nowrap;border:1px solid rgba(197,160,89,0.45);transition:background .15s,color .15s;}
.ws-cite:hover{background:var(--accent);color:#fff;}
.ws-sources-used{margin-top:14px;padding-top:13px;border-top:1px solid var(--ws-line-soft);display:flex;flex-wrap:wrap;gap:7px;align-items:center;}
.ws-sources-used .ws-lbl{font-size:10.5px;text-transform:uppercase;letter-spacing:.6px;color:var(--ws-muted);font-weight:600;width:100%;margin-bottom:2px;}
.ws-chip{font-size:11px;background:#fff;border:1px solid var(--ws-line);border-radius:14px;padding:3px 10px;color:var(--ws-ink-soft);display:flex;gap:6px;align-items:center;}
.ws-chip .ws-b{width:6px;height:6px;border-radius:50%}
.ws-placeholder-note{max-width:680px;margin:0 auto;padding:0 30px;color:var(--ws-muted);font-size:12px;font-style:italic;}
.ws-empty{max-width:520px;margin:64px auto;text-align:center;padding:0 30px;}
.ws-empty-title{font-family:'Playfair Display',Georgia,serif;font-size:22px;color:var(--ws-ink);margin-bottom:10px;}
.ws-empty-sub{font-size:14px;color:var(--ws-muted);line-height:1.6;}
.ws-typing{color:var(--ws-muted);letter-spacing:1px;animation:wsblink 1.2s steps(1) infinite;}
@keyframes wsblink{50%{opacity:.35}}
.ws-error{color:#a4424b;font-size:14px;}
.ws-a a.ws-cite{vertical-align:super;font-size:9px;margin:0 1px;padding:0 4px;text-decoration:none;}
.ws-modal{position:fixed;inset:0;background:rgba(42,35,24,0.5);z-index:11000;display:flex;align-items:center;justify-content:center;padding:20px;}
.ws-modal-box{background:#fff;border-radius:14px;width:min(640px,95vw);max-height:90vh;display:flex;flex-direction:column;box-shadow:0 12px 40px rgba(42,35,24,0.3);overflow:hidden;}
.ws-modal-head{display:flex;align-items:center;justify-content:space-between;padding:16px 20px;border-bottom:1px solid var(--ws-line);font-family:'Playfair Display',Georgia,serif;font-weight:700;font-size:16px;color:var(--ws-ink);}
.ws-modal-x{background:none;border:none;font-size:24px;line-height:1;cursor:pointer;color:var(--ws-muted);}
.ws-modal-body{padding:20px;overflow-y:auto;flex:1;min-height:80px;}
.ws-studio-output{white-space:pre-wrap;font-size:14px;line-height:1.62;color:var(--ws-ink-soft);}
.ws-modal-foot{display:flex;gap:10px;justify-content:flex-end;padding:14px 20px;border-top:1px solid var(--ws-line);}
.ws-composer{flex:0 0 auto;border-top:1px solid var(--ws-line);padding:14px 30px 18px;background:var(--ws-paper);}
.ws-box{max-width:680px;margin:0 auto;border:1px solid var(--ws-line);border-radius:14px;background:#fff;padding:14px 16px;display:flex;flex-direction:column;gap:10px;box-shadow:0 2px 12px rgba(61,51,33,0.07);transition:box-shadow .16s,border-color .16s;}
.ws-box:focus-within{border-color:var(--accent);box-shadow:0 4px 18px rgba(197,160,89,0.18);}
.ws-field{font-size:14.5px;color:var(--ws-ink);border:none;outline:none;resize:none;width:100%;font-family:inherit;}
.ws-row{display:flex;align-items:center;gap:8px;}
.ws-attach{font-size:12px;color:var(--ws-ink-soft);border:1px solid var(--ws-line);border-radius:8px;padding:6px 10px;display:flex;gap:6px;align-items:center;cursor:pointer;}
.ws-attach:hover{border-color:var(--accent);color:var(--accent)}
.ws-send{margin-left:auto;background:linear-gradient(135deg,#C5A059,#A88542);color:#3D2817;border:none;border-radius:10px;padding:9px 20px;font-size:13px;font-weight:700;cursor:pointer;box-shadow:0 2px 8px rgba(197,160,89,0.32);transition:filter .15s,transform .1s,box-shadow .15s;}
.ws-send:hover{filter:brightness(1.05);transform:translateY(-1px);box-shadow:0 4px 14px rgba(197,160,89,0.42);}
.ws-studio-intro{font-size:11.5px;color:var(--ws-muted);line-height:1.5;margin:2px 2px 16px;}
.ws-out{background:#fff;border:1px solid var(--ws-line);border-radius:13px;padding:14px;margin-bottom:11px;cursor:pointer;box-shadow:0 1px 3px rgba(61,51,33,0.05);transition:box-shadow .16s,transform .12s,border-color .16s;}
.ws-out:hover{box-shadow:0 7px 20px rgba(61,51,33,0.13);transform:translateY(-2px);border-color:var(--accent);}
.ws-out .ws-top{display:flex;gap:10px;align-items:center;margin-bottom:6px;}
.ws-badge{flex:0 0 30px;height:30px;border-radius:8px;display:flex;align-items:center;justify-content:center;font-size:14px;}
.ws-badge.doc{background:var(--ws-accent-soft)} .ws-badge.pdf{background:#fde9e3} .ws-badge.sum{background:var(--ws-blue-soft)}
.ws-out .ws-name{font-size:13px;font-weight:700;color:var(--ws-ink)}
.ws-out .ws-note{font-size:11px;color:var(--ws-muted);line-height:1.45;}
.ws-feat{display:inline-block;margin-top:8px;font-size:10px;font-weight:700;letter-spacing:.4px;text-transform:uppercase;color:var(--accent);background:var(--ws-accent-soft);padding:3px 8px;border-radius:5px;}
.ws-share{margin-top:6px;border-top:1px solid var(--ws-line);padding-top:14px;}
.ws-lnk{display:flex;align-items:center;gap:8px;background:#fff;border:1px solid var(--ws-line);border-radius:9px;padding:9px 11px;font-size:11.5px;color:var(--ws-ink-soft);cursor:pointer;}
.ws-lnk:hover{border-color:var(--blue);color:var(--blue)}
.ws-url{font-family:ui-monospace,monospace;font-size:10.5px;color:var(--ws-muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap;}
.badge-new{font-size:9px;font-weight:700;text-transform:uppercase;background:var(--primary,#C5A059);color:#fff;padding:1px 5px;border-radius:4px;margin-left:4px;vertical-align:middle;}
/* Lucide-ikon-størrelser i arbeidsflaten */
.ws-ico .lucide{width:15px;height:15px;}
.ws-badge .lucide{width:16px;height:16px;color:var(--accent-dark);}
.ws-chk .lucide{width:11px;height:11px;}
.ws-attach .lucide{width:14px;height:14px;}
.ws-dropzone .ws-big{display:flex;justify-content:center;margin-bottom:6px;}
.ws-dropzone .ws-big .lucide{width:24px;height:24px;}
.ws-lnk-ico{flex:0 0 30px;height:30px;border-radius:8px;background:var(--ws-accent-soft);display:flex;align-items:center;justify-content:center;color:var(--accent-dark);}
.ws-lnk-ico .lucide{width:15px;height:15px;}
.ws-tabbar{display:none}
@media(max-width:900px){
  .ws-cols{position:relative}
  .ws-col-sources,.ws-col-studio{position:absolute;top:0;bottom:0;width:84%;max-width:320px;z-index:20;transform:translateX(0);transition:transform .25s ease;box-shadow:0 0 40px rgba(0,0,0,.25);}
  .ws-col-sources{left:0} .ws-col-studio{right:0}
  .ws-app[data-tab="chat"] .ws-col-sources{transform:translateX(-104%)}
  .ws-app[data-tab="chat"] .ws-col-studio{transform:translateX(104%)}
  .ws-app[data-tab="studio"] .ws-col-sources{transform:translateX(-104%)}
  .ws-app[data-tab="sources"] .ws-col-studio{transform:translateX(104%)}
  .ws-tabbar{display:flex;flex:0 0 56px;background:#fff;border-top:1px solid var(--ws-line);}
  .ws-tabbar button{flex:1;background:none;border:none;color:var(--ws-muted);font-size:11px;font-weight:600;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:3px;cursor:pointer;}
  .ws-tabbar button .i{display:flex}
  .ws-tabbar button.active{color:var(--accent-dark)}
  .ws-topbar .ws-case{display:none}
}
