/* Basic styles for the DMS interface */
:root{
    --sidebar-w: 250px;
    --sidebar-w-mobile: 220px;
}

body {
    font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: #f6f8fb;
    color: #333;
    font-size: 16px;
    line-height: 1.5;
}

/* Alert styles for messages */
.alert {
    padding: 10px 15px;
    margin-bottom: 15px;
    border-radius: 4px;
    font-size: 0.9em;
}
.alert-error {
    border: 1px solid #c00;
    background-color: #fdd;
    color: #900;
}
.alert-success {
    border: 1px solid #0c0;
    background-color: #dfd;
    color: #060;
}

/* Upload form */
.upload-form {
    max-width: 500px;
    margin-top: 10px;
}

/* OCR overlay styles (schöne Dialogbox statt flacher Textüberlagerung) */
.ocr-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(10, 14, 25, 0.45);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    text-align: center;
    font-size: 1.05em;
    color: #333;
    padding: 18px;
    box-sizing: border-box;
}
.ocr-overlay > *{
    background: #fff;
    border: 1px solid #e1e5eb;
    border-radius: 14px;
    padding: 18px 18px 16px;
    box-shadow: 0 18px 50px rgba(0,0,0,0.25);
    max-width: 520px;
    width: calc(100% - 24px);
    box-sizing: border-box;
}
.ocr-progress {
    margin-top: 8px;
    font-weight: 600;
}

/* =========================================================
   OCR Upload Dialog (polished)
   ========================================================= */
.ocr-box{
    text-align:left;
}
.ocr-title{
    font-weight: 900;
    font-size: 1.1em;
    color:#2a70c0;
    margin: 0 0 6px;
    display:flex;
    align-items:center;
    gap:10px;
}
.ocr-title:before{
    content:"";
    width:10px;
    height:10px;
    border-radius:999px;
    background:#2a70c0;
    box-shadow: 0 0 0 6px rgba(42,112,192,0.14);
    flex:0 0 auto;
}
.ocr-sub{
    font-weight: 800;
    color:#333;
    margin: 0 0 12px;
    line-height: 1.35;
}
.ocr-hint{
    margin-top: 10px;
    font-size: 0.9em;
    color:#6c757d;
}
.ocr-bar{
    height: 12px;
    border-radius: 999px;
    background: #eef2f7;
    border: 1px solid #d9e1ee;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.06);
}
.ocr-bar-fill{
    height: 100%;
    width: 0%;
    border-radius: 999px;
    background: linear-gradient(90deg, #2a70c0, #4a8de0);
    box-shadow: 0 6px 16px rgba(42,112,192,0.22);
    transition: width .22s ease;
    position: relative;
}
.ocr-bar-fill:after{
    content:"";
    position:absolute;
    inset:0;
    background: linear-gradient(90deg, rgba(255,255,255,0), rgba(255,255,255,.35), rgba(255,255,255,0));
    transform: translateX(-55%);
    animation: ocr-shine 1.1s linear infinite;
    opacity: .85;
}
@keyframes ocr-shine{
    to { transform: translateX(55%); }
}

/* Document viewer and meta form layout */
.doc-viewer {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    align-items: flex-start;
}
.doc-viewer .viewer {
    flex: 2 1 400px;
    min-width: 0; /* FIX: verhindert horizontales Überlaufen */
}
.doc-viewer .meta-form {
    flex: 3 1 400px;
    min-width: 0; /* FIX: verhindert horizontales Überlaufen */
    background-color: #fff;
    border: 1px solid #e1e5eb;
    border-radius: 6px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
    max-width: 100%;
}
.pdf-frame {
    width: 100%;
    height: 600px;
    border: 1px solid #e1e5eb;
    border-radius: 4px;
}

@media (max-width: 768px) {
    .doc-viewer {
        flex-direction: column;
    }
    .pdf-frame {
        height: 400px;
    }

    /* Mobile: Meta-Box darf NIE rechts rauslaufen */
    .doc-viewer .meta-form{
        width: 100%;
        max-width: 100%;
        min-width: 0;
        padding: 16px;
        overflow: visible;
        box-sizing: border-box;
    }

    /* Mobile: Meta-Box soll nie "abgewürgt" werden */
    .doc-viewer .meta-form.meta-form-scroll{
        max-height: none;
        overflow: visible;
    }
}

/* Form grid for meta editing */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}
.form-group {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.form-wide {
    grid-column: 1 / -1;
}
.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 4px;
    margin-bottom: 6px;
}
.tag-item {
    font-size: 0.9em;
}
.form-actions {
    margin-top: 20px;
    display: flex;
    gap: 10px;
}
.meta-actions {
    margin-top: 20px;
}
.ocr-status {
    margin-top: 8px;
    font-size: 0.9em;
    color: #555;
}
.ocr-text {
    white-space: pre-wrap;
    background-color: #f9f9f9;
    padding: 10px;
    border: 1px solid #e1e5eb;
    border-radius: 4px;
    max-height: 300px;
    overflow-y: auto;
}
.versions {
    margin-top: 30px;
}
.versions ul {
    list-style: none;
    padding-left: 0;
}
.versions li {
    margin-bottom: 5px;
}

/* Login page */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: #f6f8fb;
    padding: 20px;
    box-sizing: border-box;
}
.login-card {
    background-color: #fff;
    padding: 30px;
    border: 1px solid #e1e5eb;
    border-radius: 8px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    max-width: 400px;
    width: 100%;
    text-align: center;
}
.login-card h1 {
    margin: 0 0 10px;
    font-size: 1.6em;
    color: #2a70c0;
}
.login-card h2 {
    margin: 0 0 20px;
    font-size: 1.2em;
    color: #333;
}

/* Admin page */
.admin-page {
    max-width: 1000px;
    margin: 0 auto;
}
.admin-section {
    margin-bottom: 30px;
    background-color: #fff;
    border: 1px solid #e1e5eb;
    border-radius: 6px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.admin-section h2 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.3em;
    color: #2a70c0;
}
.form-inline {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
}

header {
    background-color: #2a70c0;
    color: #fff;
    padding: 15px;
}

header h1 {
    margin: 0;
    font-size: 1.5em;
}

nav {
    margin-top: 10px;
}

nav a {
    color: #fff;
    margin-right: 15px;
    text-decoration: none;
}

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

/* =========================================================
   Sidebar
   ========================================================= */
.sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: #ffffff;
    border-right: 1px solid #e1e5eb;
    padding: 20px 15px;
    box-sizing: border-box;
    overflow-y: auto;
    position: relative;
    transition: width 0.25s ease, flex-basis 0.25s ease, padding 0.25s ease;
    will-change: width, flex-basis;
}
.sidebar-inner{ transition: opacity 0.2s ease; }
.sidebar-title {
    font-size: 1.1em;
    font-weight: 600;
    color: #2a70c0;
    margin-bottom: 10px;
}
.sidebar-subtitle {
    font-size: 0.9em;
    font-weight: 600;
    color: #6c757d;
    margin-top: 20px;
    margin-bottom: 8px;
}
.sidebar-nav { list-style: none; padding: 0; margin: 0; }
.sidebar-nav li { margin-bottom: 5px; }
.sidebar-nav a {
    display: block;
    color: #333;
    text-decoration: none;
    padding: 6px 10px;
    border-radius: 4px;
    transition: background-color 0.2s, color 0.2s;
}
.sidebar-nav a:hover { background-color: #eaf1fb; color: #2a70c0; }

/* Desktop collapsed */
body.nav-collapsed .sidebar{
    width: 0 !important;
    flex: 0 0 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    border-right: 0 !important;
    overflow: hidden !important;
}
body.nav-collapsed .sidebar .sidebar-inner{
    opacity: 0;
    pointer-events: none;
}

/* Mobile backdrop */
.sidebar-backdrop{
    position: fixed;
    inset: 0;
    background: rgba(10,14,25,.45);
    z-index: 900;
    display: none;
}

/* =========================================================
   Main area
   ========================================================= */
.main-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Top bar */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #ffffff;
    border-bottom: 1px solid #e1e5eb;
    padding: 0 20px;
    height: 60px;
    box-sizing: border-box;
    position: sticky;
    top: 0;
    z-index: 50;
}
.top-bar-left { display: flex; align-items: center; }
.sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.4em;
    color: #2a70c0;
    cursor: pointer;
    margin-right: 15px;
}
.logo { font-size: 1.4em; font-weight: 700; color: #2a70c0; }
.search-form { display: flex; flex: 1; max-width: 400px; margin-left: 20px; }
.search-form input[type="text"] {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-right: none;
    border-radius: 4px 0 0 4px;
    background-color: #f7f9fc;
}
.search-form button {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-left: none;
    background-color: #2a70c0;
    color: #fff;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    transition: background-color 0.2s;
}
.search-form button:hover { background-color: #245fa3; }

.top-nav a {
    color: #2a70c0;
    margin-left: 15px;
    font-size: 1.3em;
    text-decoration: none;
}
.top-nav a:hover { color: #245fa3; }

.content { flex: 1; padding: 20px; box-sizing: border-box; }

.footer {
    text-align: center;
    padding: 15px;
    border-top: 1px solid #e1e5eb;
    background-color: #ffffff;
    font-size: 0.9em;
    color: #666;
}

/* Card and grid styling */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
}
.card {
    background-color: #fff;
    border: 1px solid #e1e5eb;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    transition: box-shadow 0.2s;
}
.card:hover { box-shadow: 0 4px 12px rgba(0,0,0,0.1); }
.card img { width: 100%; height: 140px; object-fit: cover; }
.card .info { padding: 10px; flex: 1; display: flex; flex-direction: column; }
.card .info h3 { margin: 0 0 8px; font-size: 1em; font-weight: 600; }
.card .info .meta { font-size: 0.8em; color: #777; }

.badge {
    display: inline-block;
    padding: 2px 6px;
    margin: 2px 2px;
    font-size: 0.75em;
    color: #fff;
    background-color: #2a70c0;
    border-radius: 3px;
}
.badge-tag{ background-color:#6c757d; }

/* Form elements */
form label { display: block; margin-bottom: 5px; font-weight: 600; }
form input[type="text"],
form input[type="email"],
form input[type="url"],
form input[type="tel"],
form input[type="number"],
form input[type="date"],
form input[type="password"],
form textarea,
form select {
    width: 100%;
    padding: 8px 10px;
    margin-bottom: 12px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
    background-color: #f7f9fc;
    font-size: 1em;
}
form textarea { resize: vertical; min-height: 100px; }

button, input[type="submit"] {
    background-color: #2a70c0;
    color: #fff;
    border: none;
    padding: 10px 18px;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 1em;
}
button:hover, input[type="submit"]:hover { background-color: #245fa3; }

/* Tables */
.table-view { width: 100%; border-collapse: collapse; }
.table-view th, .table-view td { border: 1px solid #ddd; padding: 8px; }
.table-view th { background-color: #f2f2f2; font-weight: bold; }

/* Responsive sidebar */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: var(--sidebar-w-mobile);
        flex: 0 0 auto;
        transform: translateX(-105%);
        transition: transform 0.25s ease;
        z-index: 1000;
        box-shadow: 2px 0 12px rgba(0,0,0,0.12);
    }

    body.nav-collapsed .sidebar{
        width: var(--sidebar-w-mobile) !important;
        padding-left: 20px !important;
        padding-right: 15px !important;
        border-right: 1px solid #e1e5eb !important;
        overflow-y: auto !important;
    }
    body.nav-collapsed .sidebar .sidebar-inner{
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    body.nav-open .sidebar { transform: translateX(0); }
    body.nav-open .sidebar-backdrop{ display: block; }

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

    .search-form {
        flex: 1 0 100%;
        margin-left: 0;
        margin-top: 10px;
        max-width: none;
    }
    .top-bar {
        flex-wrap: wrap;
        padding: 10px;
        height: auto;
        min-height: 60px;
    }
    .top-nav {
        margin-left: auto;
        display: flex;
        align-items: center;
        margin-top: 10px;
    }
    .grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}

/* Misc helpers */
.v-muted{ color:#6c757d; font-size:0.9em; }
.mono{
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
    font-size: 0.92em;
}

/* =========================================================
   Minimal Filter UI (super aufgeräumt)
   ========================================================= */
.filters-simple{
    background:#fff;
    border:1px solid #e1e5eb;
    border-radius:10px;
    padding:10px 10px 8px;
    margin: 12px 0 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.filters-bar{
    display:flex;
    justify-content:flex-start;
    margin-bottom:8px;
}

.view-toggle{
    display:flex;
    gap:10px;
    flex-wrap:wrap;
    align-items:center;
}

.view-btn{
    display:inline-flex;
    align-items:center;
    gap:8px;
    padding:8px 11px;
    border-radius:10px;
    border:1px solid #cfd7e3;
    background:#f7f9fc;
    color:#2a70c0;
    text-decoration:none;
    font-weight:800;
    transition: background-color .2s, border-color .2s, transform .05s;
    cursor:pointer;
}
.view-btn:hover{
    background:#eef3fb;
    border-color:#b9c6da;
}
.view-btn:active{ transform: translateY(1px); }
.view-btn.active{
    background:#2a70c0;
    border-color:#2a70c0;
    color:#fff;
}
.view-btn.reset{ color:#333; }
.view-btn.ghost{
    color:#333;
    background:#fff;
}

.hits-pill{
    display:inline-flex;
    align-items:center;
    gap:8px;
    padding:8px 11px;
    border-radius:999px;
    border:1px solid #e1e5eb;
    background:#ffffff;
    color:#333;
    font-weight:900;
    margin-left:4px;
    white-space:nowrap;
}

.filters-form-simple{ margin:0; }

.filters-checks{
    display:grid;
    grid-template-columns: 1fr 1fr;
    gap:10px;
}
@media (max-width: 860px){
    .filters-checks{ grid-template-columns: 1fr; }
}

.checks-block{
    border:1px solid #e9edf4;
    background:#fbfcfe;
    border-radius:10px;
    padding:10px;
}
.checks-title{
    font-weight:900;
    color:#2a70c0;
    margin-bottom:8px;
    display:flex;
    align-items:center;
    gap:8px;
}

.checks-grid{
    display:block;
    background:#fff;
    border:1px solid #d9e1ee;
    border-radius:10px;
    padding:8px;
    max-height: 220px;
    overflow:auto;
}
.checks-grid.cols-2{ column-count: 2; column-gap: 12px; }
.checks-grid.cols-3{ column-count: 3; column-gap: 12px; }
@media (max-width: 900px){
    .checks-grid.cols-3{ column-count: 2; }
}
@media (max-width: 520px){
    .checks-grid.cols-2,
    .checks-grid.cols-3{ column-count: 1; }
}

.checkline{
    display:flex;
    align-items:center;
    gap:8px;
    padding:6px 6px;
    border-radius:8px;
    cursor:pointer;
    user-select:none;
    break-inside: avoid;
}
.checkline:hover{ background:#f3f6fb; }
.checkline input{ margin:0; }
.checkline span{ font-weight:700; color:#333; }
.checkline em{
    font-style:normal;
    color:#6c757d;
    font-weight:800;
    margin-left:6px;
}

/* Collapse handling */
.filters-body{
    transition: max-height .25s ease, opacity .2s ease;
    max-height: 800px;
    opacity: 1;
}
.filters-simple.is-collapsed .filters-body{
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    margin-top: 0;
}

/* =========================================================
   Table polish + MOBILE horizontal scroll
   ========================================================= */
.table-wrap{
    background:#fff;
    border:1px solid #e1e5eb;
    border-radius:10px;
    overflow:hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.table-scroll{
    overflow-x:auto;
    -webkit-overflow-scrolling: touch;
}

.table-docs{
    width:100%;
    border-collapse:collapse;
    min-width: 980px;
}
.table-docs th, .table-docs td{
    border-bottom:1px solid #eef2f7;
    border-right: 0;
    border-left: 0;
    padding:10px 10px;
    vertical-align:top;
}
.table-docs thead th{
    background:#f3f6fb;
    border-bottom:1px solid #e1e5eb;
    font-weight:900;
    color:#2a70c0;
    white-space:nowrap;
}
.table-docs tbody tr:hover{ background:#f7fbff; }

.th-sort{ color:#2a70c0; text-decoration:none; font-weight:900; }
.th-sort:hover{ text-decoration:underline; }
.sort-ind{ font-size: 0.85em; opacity: .85; }

.row-link{ cursor:pointer; }
.row-mainlink{ color:#333; text-decoration:none; font-weight:900; }
.row-mainlink:hover{ text-decoration:underline; }

.col-size, .col-date { white-space:nowrap; }
.cell-title{ min-width: 220px; }

/* =========================================================
   FIXED SIDEBAR (Desktop) – Sidebar bleibt stehen
   ========================================================= */

/* Desktop: Sidebar fixed, eigener Scroll */
@media (min-width: 769px) {
  .sidebar{
    position: fixed;            /* <- statt relative */
    left: 0;
    top: 0;
    bottom: 0;
    height: 100vh;
    overflow-y: auto;           /* Sidebar scrollt intern */
    z-index: 60;                /* über content, unter overlays */
  }

  /* Main rückt nach rechts, damit nichts unter die Sidebar läuft */
  .main-area{
    margin-left: var(--sidebar-w);
  }

  /* Wenn Desktop nav-collapsed: Main wieder full width */
  body.nav-collapsed .main-area{
    margin-left: 0 !important;
  }
}

/* Optional: wenn du willst, dass der Content NICHT unter der sticky Top-Bar "klebt"
   (nur wenn du Sprünge/Anker hast) */
/*
.content{
  scroll-margin-top: 70px;
}
*/
