/* ===== QuickTest - CSS Variables & Theming ===== */
:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --primary-light: #EEF2FF;
    --secondary: #10B981;
    --secondary-hover: #059669;
    --bg: #F9FAFB;
    --card-bg: #FFFFFF;
    --text: #1F2937;
    --text-light: #6B7280;
    --text-muted: #9CA3AF;
    --danger: #EF4444;
    --danger-hover: #DC2626;
    --warning: #F59E0B;
    --warning-hover: #D97706;
    --success: #10B981;
    --success-hover: #059669;
    --border: #E5E7EB;
    --border-light: #F3F4F6;
    --sidebar-bg: #1E1B4B;
    --sidebar-hover: #312E81;
    --sidebar-text: #C7D2FE;
    --sidebar-active: #4F46E5;
    --radius: 8px;
    --radius-lg: 12px;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    --transition: all 0.2s ease;
}

/* ===== Reset & Base ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden;
}

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

a {
    color: var(--primary);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

img {
    max-width: 100%;
}

/* ===== Layout ===== */
.layout {
    display: flex;
    min-height: 100vh;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 32px;
    max-width: 1200px;
}

.page-header {
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text);
}

.page-header p {
    color: var(--text-light);
    margin-top: 4px;
}

/* ===== Sidebar ===== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 260px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 900;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-logo i {
    font-size: 1.5rem;
    color: #A5B4FC;
}

.sidebar-logo h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #FFFFFF;
}

.sidebar-logo span {
    font-size: 0.75rem;
    color: var(--sidebar-text);
    display: block;
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

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

.nav-section-title {
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: rgba(199, 210, 254, 0.5);
    padding: 8px 12px 4px;
    font-weight: 600;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--sidebar-text);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.875rem;
    font-weight: 500;
}

.nav-item:hover {
    background: var(--sidebar-hover);
    color: #FFFFFF;
    text-decoration: none;
}

.nav-item.active {
    background: var(--sidebar-active);
    color: #FFFFFF;
}

.nav-item i {
    width: 20px;
    text-align: center;
    font-size: 1rem;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    margin-bottom: 8px;
}

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

.sidebar-user .user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user .user-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #FFFFFF;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.btn-logout {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius);
    color: var(--sidebar-text);
    cursor: pointer;
    transition: var(--transition);
    font-size: 0.875rem;
    width: 100%;
    border: none;
    background: none;
    font-family: inherit;
    font-weight: 500;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.2);
    color: #FCA5A5;
}

/* Mobile hamburger */
.hamburger {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 901;
    background: var(--sidebar-bg);
    color: #FFFFFF;
    border: none;
    border-radius: var(--radius);
    padding: 10px 12px;
    font-size: 1.25rem;
    cursor: pointer;
}

/* ===== Cards ===== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px;
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
}

.card-header h3 {
    font-size: 1rem;
    font-weight: 600;
}

.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

/* Stat Cards */
.stat-card {
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-icon.primary {
    background: var(--primary-light);
    color: var(--primary);
}

.stat-icon.success {
    background: #D1FAE5;
    color: var(--success);
}

.stat-icon.warning {
    background: #FEF3C7;
    color: var(--warning);
}

.stat-icon.danger {
    background: #FEE2E2;
    color: var(--danger);
}

.stat-info h4 {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}

.stat-info p {
    font-size: 0.8125rem;
    color: var(--text-light);
    margin-top: 4px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border: 1px solid transparent;
    transition: var(--transition);
    line-height: 1;
}

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

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

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

.btn-secondary {
    background: #FFFFFF;
    color: var(--text);
    border-color: var(--border);
}

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

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

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

.btn-success {
    background: var(--success);
    color: #FFFFFF;
}

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

.btn-warning {
    background: var(--warning);
    color: #FFFFFF;
}

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

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

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

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-group {
    display: flex;
    gap: 8px;
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    font-family: inherit;
    color: var(--text);
    background: #FFFFFF;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.form-control::placeholder {
    color: var(--text-muted);
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='%236B7280' viewBox='0 0 16 16'%3E%3Cpath d='M8 11L3 6h10l-5 5z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 4px;
}

.form-error {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 4px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
}

.form-check input[type="checkbox"],
.form-check input[type="radio"] {
    width: 16px;
    height: 16px;
    accent-color: var(--primary);
}

/* ===== Tables ===== */
.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: var(--card-bg);
}

thead th {
    background: var(--bg);
    padding: 12px 16px;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-light);
    border-bottom: 1px solid var(--border);
}

tbody td {
    padding: 12px 16px;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--border-light);
}

tbody tr:nth-child(even) {
    background: var(--border-light);
}

tbody tr:hover {
    background: var(--primary-light);
}

tbody tr:last-child td {
    border-bottom: none;
}

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.4;
}

.badge-primary {
    background: var(--primary-light);
    color: var(--primary);
}

.badge-success, .badge-published {
    background: #D1FAE5;
    color: #065F46;
}

.badge-warning, .badge-draft {
    background: #FEF3C7;
    color: #92400E;
}

.badge-danger, .badge-closed {
    background: #FEE2E2;
    color: #991B1B;
}

.badge-secondary, .badge-archived {
    background: #F3F4F6;
    color: #4B5563;
}

.badge-info, .badge-active {
    background: #DBEAFE;
    color: #1E40AF;
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-overlay.hidden {
    display: none;
}

.modal {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 90%;
    max-width: 560px;
    max-height: 85vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-light);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: var(--transition);
}

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

.modal-body {
    padding: 24px;
}

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

/* ===== Login Page ===== */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1E1B4B 0%, #312E81 50%, #4F46E5 100%);
    padding: 20px;
}

.login-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 40px;
    width: 100%;
    max-width: 420px;
}

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

.login-header i {
    font-size: 2.5rem;
    color: var(--primary);
    margin-bottom: 16px;
    display: block;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

.login-header p {
    color: var(--text-light);
    font-size: 0.875rem;
    margin-top: 8px;
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 0.875rem;
    color: var(--text-light);
}

.login-footer a {
    color: var(--primary);
    font-weight: 500;
}

/* ===== Notifications / Toast ===== */
#notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.notification {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    font-size: 0.875rem;
    font-weight: 500;
    animation: slideIn 0.3s ease;
    min-width: min(300px, calc(100vw - 40px));
    max-width: 450px;
}

.notification.success {
    background: #065F46;
    color: #FFFFFF;
}

.notification.error {
    background: #991B1B;
    color: #FFFFFF;
}

.notification.warning {
    background: #92400E;
    color: #FFFFFF;
}

.notification.info {
    background: #1E40AF;
    color: #FFFFFF;
}

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

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

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-light);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    color: var(--text-muted);
}

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

.empty-state p {
    font-size: 0.875rem;
    margin-bottom: 20px;
}

/* ===== Tabs ===== */
.tabs {
    display: flex;
    border-bottom: 1px solid var(--border);
    margin-bottom: 24px;
    gap: 4px;
}

.tab {
    padding: 10px 20px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-light);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: var(--transition);
    background: none;
    border-top: none;
    border-left: none;
    border-right: none;
    font-family: inherit;
}

.tab:hover {
    color: var(--text);
}

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

/* ===== Progress Bar ===== */
.progress-bar {
    height: 8px;
    background: var(--border-light);
    border-radius: 9999px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 9999px;
    transition: width 0.5s ease;
}

.progress-fill.success {
    background: var(--success);
}

.progress-fill.warning {
    background: var(--warning);
}

/* ===== Question Card (for test taking) ===== */
.question-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 16px;
}

.question-card .question-number {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.question-card .question-text {
    font-size: 1rem;
    font-weight: 500;
    margin-bottom: 16px;
}

.question-card .option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition);
}

.question-card .option:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.question-card .option.selected {
    border-color: var(--primary);
    background: var(--primary-light);
}

.filter-bar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: end;
    margin-bottom: 12px;
}

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

    .sidebar.open {
        transform: translateX(0);
    }

    .hamburger {
        display: block;
    }

    .main-content {
        margin-left: 0;
        padding: 16px 12px;
        padding-top: 64px;
        overflow-x: hidden;
        width: 100%;
        max-width: 100vw;
        box-sizing: border-box;
    }

    .page-header h1 {
        font-size: 1.25rem;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .login-card {
        padding: 24px;
    }

    .modal {
        width: 95%;
        margin: 16px;
    }

    table {
        font-size: 0.75rem;
        min-width: unset;
    }

    .progress-bar { max-width: 50px !important; }

    .table-container table thead { display: none; }

    .table-container table tbody tr {
        display: block;
        background: var(--card-bg);
        border-radius: var(--radius);
        padding: 12px 16px;
        margin-bottom: 10px;
        box-shadow: 0 1px 3px rgba(0,0,0,0.15);
        border: 1px solid var(--border-light, rgba(255,255,255,0.08));
    }

    .table-container table tbody td {
        display: block;
        padding: 3px 0;
        border: none;
        text-align: left;
    }

    .table-container table tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.7rem;
        color: var(--text-light);
        text-transform: uppercase;
        letter-spacing: 0.5px;
        display: block;
        margin-bottom: 2px;
    }

    .table-container table tbody td.card-title {
        font-weight: 600;
        font-size: 0.95rem;
        padding-bottom: 8px;
        margin-bottom: 6px;
        border-bottom: 1px solid var(--border-light, rgba(255,255,255,0.08));
    }

    .table-container table tbody td.card-title::before {
        display: none;
    }

    .table-container table tbody td.expand-cell {
        display: none;
    }

    .table-container table tbody td.mobile-hide { display: none !important; }

    .table-container table tbody td .btn-group {
        display: flex;
        gap: 6px;
        margin-top: 8px;
    }

    .table-container table tbody td .btn-group .btn {
        flex: 1;
        text-align: center;
        font-size: 0.75rem;
        padding: 6px 8px;
    }

    .table-container table tbody td .progress-bar {
        max-width: none !important;
        flex: 1;
    }

    .result-expand-icon { font-size: 0.7rem; color: var(--text-light); }

    .table-container table tbody tr.result-detail-row { display: none; }

    .table-container table tbody tr.result-detail-row[style*="block"] {
        border-radius: 0;
        margin-top: -10px;
        padding: 8px 16px;
        background: var(--bg-secondary, rgba(255,255,255,0.03));
    }

    th, td {
        padding: 6px 8px;
    }

    td {
        max-width: none !important;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .page-actions {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .page-actions .btn {
        flex: 1;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        justify-content: center;
    }

    .card {
        overflow: hidden;
        max-width: 100%;
    }

    .filter-bar {
        flex-direction: column;
        gap: 8px;
    }

    .filter-bar > div {
        min-width: 0 !important;
        width: 100% !important;
    }

    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }

    .nav-item {
        min-height: 44px;
    }

    .btn, button {
        min-height: 44px;
    }

    .chat-session-item {
        min-height: 44px;
    }

    .chat-session-delete {
        min-width: 44px;
        min-height: 44px;
    }

    .btn-group {
        flex-wrap: wrap;
    }

    .mobile-hide {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .btn-group {
        flex-direction: column;
    }

    .page-header h1 {
        font-size: 1.375rem;
    }

    .stat-grid {
        grid-template-columns: 1fr;
    }

    .mobile-hide-sm {
        display: none !important;
    }
}

/* ===== Utility Classes ===== */
.text-center {
    text-align: center;
}

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

.text-muted {
    color: var(--text-light);
}

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

.flex {
    display: flex;
}

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }

.hidden {
    display: none !important;
}

/* --- KI-Chat --- */
.chat-layout {
    display: flex;
    height: calc(100vh - 100px);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    background: #fff;
}

.chat-sidebar {
    width: 260px;
    min-width: 260px;
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.chat-sidebar-header {
    padding: 12px;
    border-bottom: 1px solid var(--border);
}

.chat-session-list {
    flex: 1;
    overflow-y: auto;
}

.chat-session-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.15s;
}

.chat-session-item:hover {
    background: var(--border-light);
}

.chat-session-item.active {
    background: var(--primary-light);
    border-left: 3px solid var(--primary);
}

.chat-session-info {
    flex: 1;
    min-width: 0;
}

.chat-session-title {
    font-size: 0.8125rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text);
}

.chat-session-date {
    font-size: 0.6875rem;
    color: var(--text-lighter);
    margin-top: 2px;
}

.chat-session-delete {
    background: none;
    border: none;
    color: var(--text-lighter);
    cursor: pointer;
    padding: 4px 6px;
    border-radius: var(--radius);
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.chat-session-item:hover .chat-session-delete {
    opacity: 1;
}

.chat-session-delete:hover {
    color: var(--danger);
    background: rgba(239, 68, 68, 0.1);
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 32px;
    text-align: center;
}

.chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: #fff;
}

.chat-header-title {
    font-weight: 600;
    font-size: 0.9375rem;
    color: var(--text);
}

.chat-quick-actions {
    display: flex;
    gap: 8px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg);
    flex-wrap: wrap;
}

.chat-quick-btn {
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.8125rem;
    color: var(--text-light);
    cursor: pointer;
    transition: all 0.15s;
    white-space: nowrap;
}

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

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chat-msg {
    display: flex;
    flex-direction: column;
    max-width: 75%;
}

.chat-msg-user {
    align-self: flex-end;
    align-items: flex-end;
}

.chat-msg-ai {
    align-self: flex-start;
    align-items: flex-start;
}

.chat-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 0.875rem;
    line-height: 1.5;
    word-break: break-word;
}

.chat-bubble-user {
    background: var(--primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.chat-bubble-ai {
    background: var(--bg);
    color: var(--text);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

.chat-msg-time {
    font-size: 0.6875rem;
    color: var(--text-lighter);
    margin-top: 4px;
    padding: 0 4px;
}

.chat-code-block {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 0.8125rem;
    overflow-x: auto;
    margin: 6px 0;
    white-space: pre-wrap;
    word-break: break-all;
}

.chat-inline-code {
    background: rgba(0,0,0,0.08);
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 0.8125rem;
}

.chat-bubble-user .chat-inline-code {
    background: rgba(255,255,255,0.2);
}

.chat-typing {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.chat-typing span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-lighter);
    animation: chatTyping 1.4s ease-in-out infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

.chat-input-area {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    background: #fff;
}

.chat-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 6px 6px 6px 14px;
    transition: border-color 0.15s;
}

.chat-input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.chat-textarea {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-size: 0.875rem;
    line-height: 1.5;
    padding: 6px 0;
    max-height: 120px;
    font-family: inherit;
    color: var(--text);
}

.chat-textarea:focus {
    outline: none;
}

.chat-textarea::placeholder {
    color: var(--text-lighter);
}

.chat-attach-btn {
    background: none;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    font-size: 1rem;
    transition: color 0.15s, background 0.15s;
    flex-shrink: 0;
}

.chat-attach-btn:hover {
    color: var(--primary);
    background: var(--primary-light);
}

.chat-file-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-light);
    background: var(--bg);
}

.chat-file-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #fff;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.75rem;
    color: var(--text);
    max-width: 200px;
}

.chat-file-chip i:first-child {
    color: var(--primary);
    font-size: 0.8125rem;
}

.chat-file-chip-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}

.chat-file-chip-size {
    color: var(--text-muted);
    white-space: nowrap;
}

.chat-file-chip-remove {
    background: none;
    border: none;
    color: var(--text-lighter);
    cursor: pointer;
    padding: 0 2px;
    font-size: 0.6875rem;
    transition: color 0.15s;
    flex-shrink: 0;
}

.chat-file-chip-remove:hover {
    color: var(--danger);
}

body.dark-mode .chat-file-chip {
    background: #162035;
    border-color: var(--border);
}

.chat-send-btn {
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s;
    flex-shrink: 0;
}

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

.chat-mobile-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 100;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    align-items: center;
    justify-content: center;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .chat-layout {
        height: calc(100dvh - 60px);
    }

    .chat-mobile-toggle {
        top: 8px;
        left: 8px;
        z-index: 48;
    }

    .chat-sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        bottom: 0;
        z-index: 50;
        width: 280px;
        transition: left 0.3s ease;
        box-shadow: none;
    }

    .chat-sidebar.chat-sidebar-open {
        left: 0;
        box-shadow: var(--shadow-lg);
    }

    .chat-mobile-toggle {
        display: flex;
    }

    .chat-msg {
        max-width: 90%;
    }
}

/* --- Berechtigungen --- */
.perm-subject-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    font-size: 0.9375rem;
}

.perm-topic-list {
    display: flex;
    flex-direction: column;
}

.perm-topic-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.15s;
}

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

.perm-topic-row:hover {
    background: var(--bg);
}

.perm-topic-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}

.perm-topic-name {
    font-size: 0.875rem;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.perm-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
}

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

.perm-toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--border);
    border-radius: 24px;
    transition: background 0.25s;
}

.perm-toggle-slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.15);
}

.perm-toggle-input:checked + .perm-toggle-slider {
    background: var(--success);
}

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

.perm-toggle-input:disabled + .perm-toggle-slider {
    opacity: 0.5;
    cursor: wait;
}

/* --- Dark Mode --- */
body.dark-mode {
    --bg: #1a1a2e;
    --sidebar-bg: #16213e;
    --sidebar-hover: #1e3050;
    --sidebar-text: #a0b4cc;
    --sidebar-active: #4F46E5;
    --card-bg: #1e2746;
    --text: #e0e0e0;
    --text-light: #a0aec0;
    --text-muted: #8899aa;
    --text-lighter: #667788;
    --border: #2a3a5c;
    --border-light: #233050;
    --hover-bg: #253350;
    --primary-light: #2a2560;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
    --bg-secondary: #162035;
    --info-bg: #1a2744;
}

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

body.dark-mode .main-content {
    background: var(--bg);
}

body.dark-mode .sidebar {
    background: var(--sidebar-bg);
}

body.dark-mode .form-control,
body.dark-mode select.form-control,
body.dark-mode textarea.form-control,
body.dark-mode input[type="text"],
body.dark-mode input[type="email"],
body.dark-mode input[type="password"],
body.dark-mode input[type="number"],
body.dark-mode input[type="search"],
body.dark-mode input[type="url"] {
    background: #162035;
    color: var(--text);
    border-color: var(--border);
}

body.dark-mode .form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

body.dark-mode .form-control::placeholder {
    color: var(--text-muted);
}

body.dark-mode table th {
    background: #162035;
    color: var(--text-light);
    border-color: var(--border);
}

body.dark-mode table td {
    border-color: var(--border);
    color: var(--text);
}

body.dark-mode table tr:hover td {
    background: var(--hover-bg);
}

body.dark-mode .badge {
    opacity: 0.9;
}

body.dark-mode .badge-success { background: #064e3b; color: #6ee7b7; }
body.dark-mode .badge-warning { background: #78350f; color: #fcd34d; }
body.dark-mode .badge-danger { background: #7f1d1d; color: #fca5a5; }

body.dark-mode .result-detail-content table { background: transparent; }

body.dark-mode .page-header h1 {
    color: var(--text);
}

body.dark-mode .empty-state {
    color: var(--text-muted);
}

body.dark-mode .btn-secondary {
    background: #253350;
    color: var(--text-light);
    border-color: var(--border);
}

body.dark-mode .btn-secondary:hover {
    background: #2d3f60;
}

body.dark-mode .modal-overlay {
    background: rgba(0, 0, 0, 0.6);
}

body.dark-mode .nav-section-title {
    color: var(--text-muted);
}

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

body.dark-mode .chat-bubble-ai {
    background: #162035;
    border-color: var(--border);
    color: var(--text);
}

body.dark-mode .chat-input-wrapper {
    background: #162035;
    border-color: var(--border);
}

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

body.dark-mode .chat-quick-btn {
    background: #162035;
    border-color: var(--border);
    color: var(--text-light);
}

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

body.dark-mode .chat-input-area {
    background: var(--card-bg);
    border-color: var(--border);
}

body.dark-mode .chat-sidebar {
    background: #162035;
    border-color: var(--border);
}

body.dark-mode .chat-session-item {
    border-color: var(--border);
}

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

body.dark-mode .perm-subject-header {
    background: #162035;
}

body.dark-mode .perm-topic-row:hover {
    background: var(--hover-bg);
}

/* --- Backdrops --- */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 899;
}

.sidebar-backdrop.active {
    display: block;
}

.chat-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.3);
    z-index: 49;
}

.chat-sidebar-backdrop.active {
    display: block;
}
