:root {
    --font-family: 'Poppins', sans-serif;
    --hue: 250;
    --primary-color-h: 250;
    --primary-color-s: 86%;
    --primary-color-l: 62%;
    --secondary-color-h: 288;
    --secondary-color-s: 95%;
    --secondary-color-l: 71%;

    --c-primary: hsl(var(--primary-color-h), var(--primary-color-s), var(--primary-color-l));
    --c-secondary: hsl(var(--secondary-color-h), var(--secondary-color-s), var(--secondary-color-l));

    --c-text: #333;
    --c-text-light: #888;
    --c-bg: #f0f2f5;
    --c-white: #fff;
    --c-black: #000;
    --c-border: #e0e0e0;
    --c-error: #e74c3c;
    --c-success: #2ecc71;

    --shadow-light: rgba(255, 255, 255, 0.7);
    --shadow-dark: rgba(0, 0, 0, 0.1);

    --glass-bg: rgba(255, 255, 255, 0.3);
    --glass-border: rgba(255, 255, 255, 0.5);
    --glass-shadow: rgba(0, 0, 0, 0.1);

    --neumorph-shadow-outset:
            -6px -6px 12px var(--shadow-light),
            6px 6px 12px var(--shadow-dark);
    --neumorph-shadow-inset:
            inset -4px -4px 8px var(--shadow-light),
            inset 4px 4px 8px var(--shadow-dark);
}

body.dark-mode {
    --c-text: #eee;
    --c-text-light: #aaa;
    --c-bg: #1a1a2e;
    --c-white: #2e2e48;
    --c-black: #ffffff;
    --c-border: #3a3a5a;

    --shadow-light: rgba(255, 255, 255, 0.05);
    --shadow-dark: rgba(0, 0, 0, 0.3);

    --glass-bg: rgba(46, 46, 72, 0.4);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: rgba(0, 0, 0, 0.2);
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--c-bg);
    color: var(--c-text);
    transition: background-color 0.3s, color 0.3s;
    overflow-x: hidden;
}

.main-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    padding: 2rem 1.5rem;
    background: var(--glass-bg);
    backdrop-filter: blur(10px);
    border-right: 1px solid var(--glass-border);
    box-shadow: 5px 0 15px var(--glass-shadow);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease-in-out;
    z-index: 100;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-header {
    margin-bottom: 2rem;
    text-align: center;
}

.sidebar-footer {
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border);
    margin-top: auto;
}

.theme-switch-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.logout-wrapper {
    margin-top: 1rem;
}

.logout-link {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    color: var(--c-text-light);
    background-color: transparent;
    border: 2px solid var(--c-border);
    transition: all 0.3s ease;
}

.logout-link i {
    margin-right: 0.8rem;
}

.logout-link:hover {
    color: #fff;
    background-color: var(--c-error);
    border-color: var(--c-error);
    box-shadow: 0 4px 10px -2px hsla(0, 80%, 60%, 0.5);
    transform: translateY(-2px);
}

.logo {
    max-width: 150px;
    height: auto;
    margin-bottom: 0.5rem;
}

.company-name {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--c-text);
}

.nav-menu {
    list-style: none;
    flex-grow: 1;
}

.nav-item a {
    display: flex;
    align-items: center;
    padding: 0.9rem 1rem;
    margin-bottom: 0.5rem;
    border-radius: 10px;
    color: var(--c-text-light);
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s ease;
}

.nav-item a:hover, .nav-item.active a {
    background: linear-gradient(90deg, var(--c-primary), var(--c-secondary));
    color: #fff;
    box-shadow: 0 4px 10px -2px hsla(var(--primary-color-h), 50%, 50%, 0.4);
}

.nav-item a i {
    margin-right: 1rem;
    font-size: 1.2rem;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding-top: 1rem;
    border-top: 1px solid var(--glass-border);
}

.theme-switch-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
}

.theme-switch {
    display: inline-block;
    height: 34px;
    position: relative;
    width: 60px;
}

.theme-switch input {
    display:none;
}

.slider {
    background-color: var(--c-border);
    bottom: 0;
    cursor: pointer;
    left: 0;
    position: absolute;
    right: 0;
    top: 0;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    background-color: var(--c-white);
    bottom: 4px;
    content: "";
    height: 26px;
    left: 4px;
    position: absolute;
    transition: .4s;
    width: 26px;
    border-radius: 50%;
    box-shadow: 0 0 5px rgba(0,0,0,0.2);
}

input:checked + .slider {
    background: linear-gradient(90deg, var(--c-primary), var(--c-secondary));
}

input:checked + .slider:before {
    transform: translateX(26px);
}

.main-content {
    flex-grow: 1;
    padding: 2.5rem;
    margin-left: 260px;
    width: calc(100% - 260px);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.page-header h1 {
    font-size: 2.2rem;
    font-weight: 700;
}

.card {
    background: var(--glass-bg);
    backdrop-filter: blur(5px);
    border: 1px solid var(--glass-border);
    padding: 1.5rem;
    border-radius: 20px;
    box-shadow: var(--neumorph-shadow-outset);
    transition: all 0.3s ease;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    display: flex;
    align-items: center;
    padding: 1.5rem;
}

.stat-card-icon {
    font-size: 2.5rem;
    padding: 1rem;
    width: 85px;
    text-align: center;
    border-radius: 50%;
    margin-right: 1.5rem;
    color: var(--c-white);
}

.stat-card-icon.docs { background: #3498db; }
.stat-card-icon.users { background: #2ecc71; }
.stat-card-icon.deadlines { background: #e74c3c; }

.stat-card-info h3 {
    font-size: 2.5rem;
    font-weight: 700;
}
.stat-card-info p {
    color: var(--c-text-light);
}

.grid-container {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    align-items: start;
}

.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--c-border);
}
.list-item:last-child {
    border-bottom: none;
}
.list-item-content strong {
    display: block;
    margin-bottom: 0.2rem;
}
.list-item-content span {
    font-size: 0.9rem;
    color: var(--c-text-light);
}
.list-item-date {
    font-weight: 600;
    color: var(--c-primary);
}

h2.section-title {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
}

/* Form Styles */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.form-control {
    width: 100%;
    padding: 0.9rem 1.2rem;
    background-color: var(--c-bg);
    border: none;
    border-radius: 12px;
    box-shadow: var(--neumorph-shadow-inset);
    color: var(--c-text);
    font-family: var(--font-family);
    font-size: 1rem;
    transition: all 0.2s ease;
}

.form-control:focus {
    outline: none;
    box-shadow: var(--neumorph-shadow-inset), 0 0 0 2px var(--c-primary);
}

.form-group-checkbox {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
}
.form-group-checkbox input[type="checkbox"] {
    margin-right: 10px;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}
.form-group-checkbox label {
    margin-bottom: 0;
    font-weight: 600;
}

.btn {
    padding: 0.9rem 1.8rem;
    border: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.btn-primary {
    background: linear-gradient(90deg, var(--c-primary), var(--c-secondary));
    color: #fff;
    box-shadow: 0 4px 15px -3px hsla(var(--primary-color-h), 50%, 50%, 0.5);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 7px 20px -5px hsla(var(--primary-color-h), 50%, 50%, 0.7);
}

.btn-secondary {
    background-color: var(--c-white);
    color: var(--c-text);
    box-shadow: var(--neumorph-shadow-outset);
}
.btn-secondary:hover {
    box-shadow: none;
}

.btn-danger {
    background-color: var(--c-error);
    color: #fff;
}
.btn-danger:hover {
    background-color: #c0392b;
}

/* Login Page */
.login-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: var(--c-bg);
    background-image: linear-gradient(135deg, hsla(var(--primary-color-h), 80%, 70%, 0.3) 0%, hsla(var(--secondary-color-h), 80%, 70%, 0.3) 100%);
}

.login-box {
    max-width: 400px;
    width: 90%;
    padding: 3rem;
    text-align: center;
}

.login-box h1 {
    margin-bottom: 0.5rem;
    font-size: 2rem;
}

.login-box p {
    margin-bottom: 2rem;
    color: var(--c-text-light);
}

/* Documents Page */
.main-content.full-height-content {
    padding: 1.5rem;
    height: 100vh;
}

.docs-layout {
    display: grid;
    grid-template-columns: 2.5fr 2fr;
    gap: 1.5rem;
    height: calc(100vh - 3rem); /* Adjusted for padding */
}

/* Ausklappen Feature Style */
.docs-layout.preview-popped-out {
    grid-template-columns: 1fr;
}
.docs-layout.preview-popped-out .docs-preview {
    display: none;
}


.main-content.full-height-content .docs-layout {
    height: 100%;
}

.docs-left-column {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    min-height: 0; /* Important for flex child overflow */
}

.docs-main {
    max-height: 49vh;
    display: flex;
    min-height: 317px;
    flex-direction: column;
    flex-grow: 1;
}

.docs-bottom-widgets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    align-items: stretch;
    min-height: 390px
}

#details-widget {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.docs-preview {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 0.5rem; /* Give some space for the iframe */
}

.docs-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1rem;
}
.search-bar {
    flex-grow: 1;
}

.docs-list-container {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 10px;
}

.doc-item {
    display: grid;
    grid-template-columns: 40px 1fr 100px 120px 150px 100px;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1rem;
    border-radius: 10px;
    margin-bottom: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

.doc-item:hover, .doc-item.selected {
    background-color: var(--glass-bg);
}

.doc-item .doc-icon { font-size: 1.5rem; color: var(--c-primary); }
.doc-item .doc-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-item .doc-meta { font-size: 0.9rem; color: var(--c-text-light); }
.doc-actions { text-align: right; }
.doc-actions a { color: var(--c-text-light); margin: 0 5px; font-size: 1.1rem; }
.doc-actions a:hover { color: var(--c-primary); }

.upload-widget {
    display: flex;
    flex-direction: column;
}
.upload-widget #drop-zone {
    flex-grow: 1;
}
.upload-widget > .form-group {
    flex-shrink: 0;
    margin-top: auto;
    margin-bottom: 0;
}

#drop-zone {
    border: none;
    background-color: var(--c-bg);
    box-shadow: var(--neumorph-shadow-inset);
    border-radius: 20px;
    padding: 2rem;
    text-align: center;
    color: var(--c-text-light);
    cursor: pointer;
    transition: all 0.3s ease-in-out;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 150px;
}
#drop-zone i {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--c-text-light);
    transition: all 0.3s;
}
#drop-zone.drag-over {
    background: linear-gradient(135deg, var(--c-primary), var(--c-secondary));
    box-shadow: 0 8px 25px -5px hsla(var(--primary-color-h), 50%, 50%, 0.5);
    transform: scale(1.02);
    color: white;
}
#drop-zone.drag-over i {
    color: white;
    transform: scale(1.1);
}

#file-preview-iframe {
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 15px;
    background-color: var(--c-white);
    box-shadow: var(--neumorph-shadow-inset);
}
#file-details-panel {
    flex-grow: 1;
    overflow-y: auto;
    padding-right: 10px;
}
#file-details-panel h3 {
    margin-bottom: 0.8rem;
    font-size: 1.1rem;
}
#file-details-panel .form-group {
    margin-bottom: 0.5rem;
}
#file-details-panel .form-group label {
    margin-bottom: 0.25rem;
    font-size: 0.85rem;
}
#file-details-panel .form-control {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
}
#file-details-panel .form-group-checkbox {
    margin-bottom: 0.4rem;
}
#file-details-panel .form-group-checkbox input {
    width: 16px;
    height: 16px;
}
#file-details-panel .form-group-checkbox label {
    font-weight: normal;
    font-size: 0.85rem;
}

/* Table Styles */
.table {
    width: 100%;
    border-collapse: collapse;
    white-space: nowrap;
}
.table th, .table td {
    padding: 0.8rem;
    text-align: left;
    max-width: 402px;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
    border-bottom: 1px solid var(--c-border);
}
.table th {
    font-weight: 600;
}
.docs-list-container .table tbody tr {
    cursor: pointer;
    transition: background-color 0.2s;
}
.docs-list-container .table tbody tr:hover,
.docs-list-container .table tbody tr.selected {
    background-color: var(--glass-bg);
}
.table .table-clickable-cell:hover {
    text-decoration: underline;
    color: var(--c-primary);
}
.doc-icon {
    font-size: 1.5rem;
    color: var(--c-primary);
    text-align: center;
}
.doc-name {
    font-weight: 600;
}

.table th.sortable-header {
    cursor: pointer;
    user-select: none;
    position: relative;
}

.table th.sortable-header .fa-sort,
.table th.sortable-header .fa-sort-up,
.table th.sortable-header .fa-sort-down {
    color: var(--c-text-light);
    margin-left: 8px;
    opacity: 0.4;
    transition: opacity 0.2s;
}

.table th.sortable-header:hover .fa-sort,
.table th.sortable-header:hover .fa-sort-up,
.table th.sortable-header:hover .fa-sort-down {
    opacity: 0.8;
}

.table th.sortable-header.sorted .fa-sort-up,
.table th.sortable-header.sorted .fa-sort-down {
    opacity: 1;
    color: var(--c-primary);
}


/* Table responsiveness */
.table-responsive {
    max-width: 50vw;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

.preview-popped-out .table-responsive {
    max-width: 100% !important;
}


/* Filter Bubbles */
.filter-bubble {
    background: var(--c-primary);
    color: white;
    padding: 5px 10px;
    border-radius: 15px;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
}

.filter-bubble-remove {
    background: rgba(255,255,255,0.2);
    border: none;
    color: white;
    border-radius: 50%;
    width: 18px;
    height: 18px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    line-height: 1;
}

/* Responsive */
.hamburger {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 101;
    background: var(--c-white);
    color: var(--c-text);
    border: none;
    padding: 0;
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
    border-radius: 50%;
    box-shadow: var(--neumorph-shadow-outset);
    cursor: pointer;
    transition: all 0.2s ease;
}
.hamburger:hover {
    box-shadow: none;
}
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}
.sidebar-overlay.active {
    display: block;
}

@media (max-width: 1200px) {
    .docs-layout {
        grid-template-columns: 1fr;
        height: auto; /* FIX: Allow layout to grow vertically */
    }
    .main-content.full-height-content {
        height: auto; /* FIX: Allow layout to grow vertically */
        min-height: 100vh;
    }
    .docs-preview {
        height: 60vh; /* Adjust height for stacked view */
    }
}

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 5px 0 15px var(--glass-shadow);
    }
    .main-content {
        margin-left: 0;
        width: 100%;
        padding: 1.5rem 1rem;
        padding-top: 70px;
    }
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .page-header .header-actions {
        width: 100%;
        text-align: left;
    }
    .grid-container, .docs-bottom-widgets {
        grid-template-columns: 1fr;
    }
    .hamburger {
        display: block;
    }
    .sidebar.open {
        background: rgba(255, 255, 255, 0.66);
        transform: translateX(0);
    }
    .docs-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .login-box {
        padding: 2rem;
    }
    .docs-bottom-widgets {
        min-height: unset; /* Remove min-height on mobile */
    }
}
@media (max-width: 576px) {
    .card {
        padding: 1rem;
    }
    .stat-grid {
        grid-template-columns: 1fr;
    }
    .doc-item {
        grid-template-columns: 40px 1fr auto;
        grid-template-rows: auto auto;
        grid-template-areas:
            "icon name actions"
            "icon meta actions";
        row-gap: 0.25rem;
        padding: 0.8rem;
    }
    .doc-item .doc-icon { grid-area: icon; align-self: center; }
    .doc-item .doc-name { grid-area: name; align-self: end; }
    .doc-item .doc-meta { display: none; }
    .doc-item .doc-meta:nth-of-type(3) {
        display: block;
        grid-area: meta;
        align-self: start;
    }
    .doc-item .doc-actions {
        grid-area: actions;
        align-self: center;
    }
    .page-header h1 {
        font-size: 1.8rem;
    }
    .modal-content {
        margin: 2rem auto; /* Better mobile margin */
        width: 95%;
        padding: 1.5rem;
    }
    /* FIX: Stack Calendar Toolbar */
    .fc .fc-toolbar {
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;
    }
    .fc .fc-toolbar-title {
        font-size: 1.25em;
    }
    .fc-event-title {
        font-size: 0.85em !important;
    }
}

/* Calendar */
#calendar {
    width: 100%;
}
.fc-event {
    cursor: pointer;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.5);
    backdrop-filter: blur(5px);
}
.modal-content {
    background-color: var(--c-bg); /* Use theme background color */
    border: 1px solid var(--c-border);
    position: relative;
    margin: 10% auto;
    padding: 2rem;
    width: 90%;
    max-width: 500px;
}
.close-modal {
    color: var(--c-text-light);
    position: absolute;
    top: 1rem;
    right: 1.5rem;
    font-size: 2rem;
    font-weight: bold;
    cursor: pointer;
}
.close-modal:hover,
.close-modal:focus {
    color: var(--c-text);
}

.hidden {
    display: none;
}