:root {
    --app-accent: #6b8d4a;
    --app-accent-dark: #496632;
    --app-soft: #edf3e7;
    --app-border: #c8d6bb;
    --app-bg: #f3f5f0;
}

html,
body {
    min-height: 100%;
}

body {
    margin: 0;
    background: var(--app-bg);
    color: #25301f;
}

.auth-page {
    min-height: 100vh;
    background:
        radial-gradient(circle at 15% 10%, rgba(198, 215, 183, .85), transparent 35%),
        linear-gradient(145deg, #eef4e8 0%, #f7f8f5 52%, #e7eee1 100%);
}

.auth-shell {
    display: grid;
    min-height: 100vh;
    place-items: center;
    padding: 24px 12px;
}

.auth-card {
    width: min(100%, 470px);
    border: 1px solid var(--app-border);
    border-radius: 12px;
    background: rgba(255, 255, 255, .96);
    box-shadow: 0 18px 50px rgba(44, 63, 32, .14);
}

.auth-card .card-body {
    padding: 28px;
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 54px;
    height: 54px;
    margin-bottom: 16px;
    border: 1px solid var(--app-border);
    border-radius: 14px;
    background: var(--app-soft);
    color: var(--app-accent-dark);
    font-size: 26px;
}

.btn-app {
    border-color: var(--app-accent-dark);
    background: var(--app-accent);
    color: #fff;
}

.btn-app:hover,
.btn-app:focus {
    border-color: #354d25;
    background: var(--app-accent-dark);
    color: #fff;
}

.app-topbar {
    border-bottom: 1px solid var(--app-border);
    background: #fff;
    box-shadow: 0 2px 10px rgba(31, 44, 20, .06);
}

.app-topbar-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    min-height: 60px;
    padding: 8px 18px;
}

.app-brand {
    display: inline-flex;
    align-items: center;
    gap: 9px;
    color: #26351b;
    font-size: 18px;
    font-weight: 700;
    text-decoration: none;
}

.app-brand i {
    color: var(--app-accent);
    font-size: 22px;
}

.app-nav {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.app-nav a,
.app-nav button,
.app-user {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 10px;
    border-radius: 7px;
    color: #536048;
    font-size: 14px;
    text-decoration: none;
}

.app-nav a:hover,
.app-nav a.active,
.app-nav button:hover {
    background: var(--app-soft);
    color: var(--app-accent-dark);
}


.app-nav-form {
    margin: 0;
}

.app-nav button {
    border: 0;
    background: transparent;
}

.app-user {
    color: #26351b;
    font-weight: 700;
}

.admin-content {
    width: min(1180px, calc(100% - 24px));
    margin: 22px auto 40px;
}

.admin-card {
    border-color: var(--app-border);
    border-radius: 10px;
}

.code-output {
    padding: 13px 15px;
    border: 1px dashed var(--app-accent);
    border-radius: 8px;
    background: var(--app-soft);
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 20px;
    font-weight: 700;
    letter-spacing: .04em;
    text-align: center;
    word-break: break-all;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 8px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
}

.status-pill.active {
    background: #e5f3df;
    color: #356326;
}

.status-pill.inactive {
    background: #f4e5e2;
    color: #8a3e29;
}

@media (max-width: 760px) {
    .app-topbar-inner {
        align-items: flex-start;
        flex-direction: column;
    }

    .app-nav {
        width: 100%;
    }

    .app-user {
        margin-left: 0;
    }
}


/* Größere Schrift für die Standalone-Anwendung */
body.chat-page {
    font-size: 16px;
}

body.chat-page .app-brand {
    font-size: 20px;
}

body.chat-page .app-nav a,
body.chat-page .app-nav button,
body.chat-page .app-user {
    font-size: 15px;
}

/* Mobile-Optimierung */
html {
    overflow-x: hidden;
}

body {
    min-height: 100dvh;
    overflow-x: hidden;
}

.auth-page,
.auth-shell {
    min-height: 100dvh;
}

@media (max-width: 767.98px) {
    .app-topbar-inner {
        align-items: stretch;
        gap: 5px;
        min-height: 0;
        padding: 7px 10px 6px;
    }

    .app-brand {
        min-width: 0;
        min-height: 36px;
        font-size: 18px;
    }

    .app-brand span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .app-nav {
        width: 100%;
        flex-wrap: nowrap;
        gap: 3px;
        overflow-x: auto;
        overflow-y: hidden;
        padding: 0 0 2px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }

    .app-nav::-webkit-scrollbar {
        display: none;
    }

    .app-nav a,
    .app-nav button,
    .app-user {
        flex: 0 0 auto;
        min-height: 40px;
        padding: 7px 9px;
        font-size: 14px;
        white-space: nowrap;
    }

    .app-nav-form {
        flex: 0 0 auto;
    }

    .admin-content {
        width: calc(100% - 16px);
        margin: 14px 8px 28px;
    }

    .admin-content h1 {
        font-size: 1.45rem;
    }

    .admin-card {
        overflow: hidden;
        border-radius: 8px;
    }

    .admin-card .card-header {
        padding: 11px 13px;
    }

    .admin-card .card-body {
        padding: 14px 13px;
    }

    .admin-content .form-control,
    .admin-content .form-select,
    .auth-card .form-control,
    .auth-card .form-select {
        min-height: 44px;
        font-size: 16px;
    }

    .admin-content textarea.form-control,
    .auth-card textarea.form-control {
        min-height: 96px;
    }

    .admin-content .card-body .row > [class*="col-"] > .btn {
        width: 100%;
        min-height: 44px;
    }

    .code-output {
        padding: 12px 10px;
        font-size: 17px;
        letter-spacing: .025em;
        overflow-wrap: anywhere;
    }

    .mobile-action-group {
        align-items: stretch;
        flex-direction: column;
    }

    .mobile-action-group > *,
    .mobile-action-group > form,
    .mobile-action-group .btn {
        width: 100%;
    }

    .mobile-action-group .btn {
        min-height: 44px;
    }

    .admin-card > .table-responsive {
        overflow: visible;
    }

    .mobile-card-table,
    .mobile-card-table tbody,
    .mobile-card-table tr,
    .mobile-card-table td {
        display: block;
        width: 100%;
    }

    .mobile-card-table thead {
        display: none;
    }

    .mobile-card-table tbody tr {
        padding: 8px 0;
        border-bottom: 1px solid var(--app-border);
    }

    .mobile-card-table tbody tr:last-child {
        border-bottom: 0;
    }

    .mobile-card-table tbody td {
        display: grid;
        grid-template-columns: minmax(105px, 36%) minmax(0, 1fr);
        gap: 10px;
        align-items: start;
        padding: 7px 12px;
        border: 0;
        background: transparent;
        text-align: left !important;
        white-space: normal !important;
    }

    .mobile-card-table tbody td::before {
        color: #637058;
        content: attr(data-label);
        font-size: 12px;
        font-weight: 700;
        line-height: 1.35;
    }

    .mobile-card-table tbody td[data-label="Chat-Name, Raum und Rolle"] {
        display: block;
    }

    .mobile-card-table tbody td[data-label="Chat-Name, Raum und Rolle"]::before {
        display: block;
        margin-bottom: 7px;
    }

    .mobile-card-table .mobile-table-empty {
        display: block;
        padding: 20px 12px;
    }

    .mobile-card-table .mobile-table-empty::before {
        display: none;
    }

    .mobile-card-table td .d-flex.flex-nowrap {
        align-items: flex-start !important;
        flex-wrap: wrap !important;
    }

    .mobile-card-table td code {
        max-width: 100%;
        overflow-wrap: anywhere;
        white-space: normal !important;
    }

    .mobile-card-table td form {
        min-width: 0;
    }

    .mobile-card-table td[data-label="Aktion"] form,
    .mobile-card-table td[data-label="Zugang"] form,
    .mobile-card-table td[data-label="Aktion"] .btn,
    .mobile-card-table td[data-label="Zugang"] .btn {
        width: 100%;
    }

    .user-edit-form {
        display: grid !important;
        grid-template-columns: 1fr;
        width: 100%;
    }

    .user-edit-form .form-control,
    .user-edit-form .form-select,
    .user-edit-form .btn {
        width: 100%;
        max-width: none !important;
        min-height: 42px;
    }

    .auth-shell {
        padding: 14px 8px;
    }

    .auth-card {
        border-radius: 10px;
    }

    .auth-card .card-body {
        padding: 21px 18px;
    }

    .auth-logo {
        width: 48px;
        height: 48px;
        margin-bottom: 13px;
        font-size: 23px;
    }

    .auth-card .btn {
        min-height: 44px;
    }

    .container.pt-3 {
        max-width: none;
        padding: 8px 8px 0 !important;
    }
}

@media (max-width: 380px) {
    .mobile-card-table tbody td {
        grid-template-columns: 1fr;
        gap: 3px;
    }

    .mobile-card-table tbody td::before {
        margin-bottom: 2px;
    }
}

@media (max-height: 700px) and (max-width: 767.98px) {
    .auth-shell {
        place-items: start center;
    }
}

/* Benutzerprofil */
.app-user {
    font-weight: 700;
}

.app-user-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 27px;
    width: 27px;
    height: 27px;
    overflow: hidden;
    border: 1px solid var(--app-border);
    border-radius: 50%;
    background: var(--app-soft);
    color: var(--app-accent-dark);
    font-size: 10px;
    font-weight: 800;
    letter-spacing: .02em;
}

.app-user-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-content {
    width: min(1040px, calc(100% - 24px));
    margin: 22px auto 40px;
}

.profile-page-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 18px;
    margin-bottom: 16px;
}

.profile-hero-card,
.profile-card {
    border-color: var(--app-border);
    border-radius: 10px;
    box-shadow: 0 7px 24px rgba(44, 63, 32, .07);
}

.profile-hero-card {
    margin-bottom: 18px;
    overflow: hidden;
    background:
        radial-gradient(circle at 92% 10%, rgba(198, 215, 183, .52), transparent 34%),
        #fff;
}

.profile-hero {
    display: flex;
    align-items: center;
    gap: 22px;
    padding: 24px;
}

.profile-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border: 1px solid var(--app-border);
    border-radius: 50%;
    background: linear-gradient(145deg, var(--app-soft), #dbe8d0);
    color: var(--app-accent-dark);
    font-weight: 800;
    letter-spacing: .03em;
    user-select: none;
}

.profile-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-avatar-large {
    flex: 0 0 118px;
    width: 118px;
    height: 118px;
    font-size: 32px;
    box-shadow: 0 8px 24px rgba(44, 63, 32, .14);
}

.profile-avatar-preview {
    flex: 0 0 150px;
    width: 150px;
    height: 150px;
    font-size: 38px;
}

.profile-hero-text {
    min-width: 0;
}

.profile-status {
    margin-top: 5px;
    color: #44513b;
    font-size: 16px;
}

.profile-member-since {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    color: #687460;
    font-size: 13px;
}

.profile-role-badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 8px;
    border: 1px solid var(--app-border);
    border-radius: 999px;
    background: var(--app-soft);
    color: var(--app-accent-dark);
    font-size: 12px;
    font-weight: 700;
}

.profile-grid {
    display: grid;
    grid-template-columns: minmax(300px, .82fr) minmax(0, 1.18fr);
    gap: 18px;
}

.profile-card .card-header {
    padding: 13px 16px;
    border-bottom-color: var(--app-border);
    background: #f8faf6;
}

.profile-card .card-body {
    padding: 18px;
}

.profile-avatar-editor {
    display: flex;
    align-items: flex-start;
    gap: 20px;
}

.profile-avatar-actions {
    min-width: 0;
    flex: 1;
}

.profile-bio {
    color: #303b29;
    font-size: 16px;
    line-height: 1.65;
    overflow-wrap: anywhere;
}

@media (max-width: 767.98px) {
    .app-user-avatar {
        flex-basis: 30px;
        width: 30px;
        height: 30px;
    }

    .profile-content {
        width: calc(100% - 16px);
        margin: 14px 8px 28px;
    }

    .profile-page-head {
        align-items: stretch;
        flex-direction: column;
        gap: 10px;
    }

    .profile-page-head > .btn {
        width: 100%;
        min-height: 44px;
    }

    .profile-hero {
        align-items: center;
        flex-direction: column;
        padding: 20px 16px;
        text-align: center;
    }

    .profile-avatar-large {
        flex-basis: 104px;
        width: 104px;
        height: 104px;
        font-size: 29px;
    }

    .profile-hero-text .d-flex {
        justify-content: center;
    }

    .profile-grid {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .profile-card .card-body {
        padding: 15px 13px;
    }

    .profile-avatar-editor {
        align-items: center;
        flex-direction: column;
    }

    .profile-avatar-preview {
        flex-basis: 132px;
        width: 132px;
        height: 132px;
        font-size: 34px;
    }

    .profile-avatar-actions,
    .profile-avatar-actions form,
    .profile-avatar-actions .btn {
        width: 100%;
    }

    .profile-content .form-control,
    .profile-content .form-select {
        min-height: 44px;
        font-size: 16px;
    }

    .profile-content textarea.form-control {
        min-height: 145px;
    }

    .profile-content .btn {
        min-height: 44px;
    }
}

/* Installierbare Web-App (PWA) */
.pwa-install-nav {
    white-space: nowrap;
}

.pwa-install-nav i,
.pwa-install-fab i {
    font-size: 1rem;
}

.pwa-install-fab {
    position: fixed;
    right: max(14px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    z-index: 1080;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    min-height: 44px;
    padding: 10px 14px;
    border: 1px solid var(--app-accent-dark);
    border-radius: 999px;
    background: var(--app-accent);
    color: #fff;
    font-weight: 700;
    box-shadow: 0 10px 28px rgba(44, 63, 32, .24);
}

.pwa-install-fab:hover,
.pwa-install-fab:focus-visible {
    background: var(--app-accent-dark);
    color: #fff;
}

.pwa-install-fab[hidden],
.pwa-install-nav[hidden] {
    display: none !important;
}

@media (display-mode: standalone), (display-mode: fullscreen) {
    .pwa-install-fab,
    .pwa-install-nav {
        display: none !important;
    }
}

@media (max-width: 767.98px) {
    .pwa-install-nav {
        min-height: 42px;
    }

    .pwa-install-fab {
        right: max(10px, env(safe-area-inset-right));
        bottom: max(10px, env(safe-area-inset-bottom));
        min-height: 46px;
        padding: 10px 13px;
    }
}

/* Push-Benachrichtigungen */
.pwa-notification-nav {
    white-space: nowrap;
}

.pwa-notification-nav.active {
    background: var(--app-soft);
    color: var(--app-accent-dark);
    font-weight: 700;
}

.pwa-notification-nav[hidden] {
    display: none !important;
}

.pwa-notification-nav:disabled {
    cursor: wait;
    opacity: .65;
}

@media (max-width: 767.98px) {
    .pwa-notification-nav {
        min-height: 42px;
    }
}
