/* IBE Corporate Design - Dashboard Portal */
/* Hausfarben: Dunkelblau #00324B, Blaugrau #9AAEB7 */
/* Produktfarben: Blau #5985C2, Orange #E0822D, Gruen #9DC042 */

:root {
    --ibe-dark: #00324B;
    --ibe-gray: #9AAEB7;
    --ibe-blue: #5985C2;
    --ibe-orange: #E0822D;
    --ibe-green: #9DC042;
    --ibe-dark-hover: #004a6e;
    --ibe-light-bg: #f4f7f9;
    --ibe-card-shadow: 0 2px 8px rgba(0, 50, 75, 0.08);
    --ibe-border: #e0e7eb;
}

* { box-sizing: border-box; }

body {
    font-family: 'Roboto', sans-serif;
    font-weight: 300;
    background: var(--ibe-light-bg);
    color: #333;
    margin: 0;
    min-height: 100vh;
}

/* ============ SIDEBAR ============ */
.sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 250px;
    height: 100vh;
    background: var(--ibe-dark);
    color: #fff;
    display: flex;
    flex-direction: column;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-logo {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}
.sidebar-logo img { height: 36px; width: auto; }
.sidebar-logo .app-title {
    font-size: 13px; font-weight: 500;
    color: var(--ibe-gray); line-height: 1.3;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
}
.sidebar-nav a {
    display: flex; align-items: center; gap: 12px;
    padding: 12px 24px;
    color: rgba(255,255,255,0.75);
    text-decoration: none; font-size: 14px; font-weight: 400;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}
.sidebar-nav a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.sidebar-nav a.active {
    background: rgba(255,255,255,0.1); color: #fff;
    border-left-color: var(--ibe-orange); font-weight: 500;
}
.sidebar-nav a .nav-icon { width: 20px; text-align: center; font-size: 16px; flex-shrink: 0; }
.sidebar-nav .nav-section {
    padding: 20px 24px 8px;
    font-size: 11px; text-transform: uppercase;
    letter-spacing: 1px; color: rgba(255,255,255,0.4); font-weight: 500;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 12px; color: rgba(255,255,255,0.5);
}
.sidebar-footer .user-info {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 8px; color: rgba(255,255,255,0.8); font-size: 13px;
}
.sidebar-footer .user-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--ibe-blue);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; color: #fff;
}

/* ============ MAIN LAYOUT ============ */
.main-content { margin-left: 250px; min-height: 100vh; }

.topbar {
    background: #fff;
    border-bottom: 1px solid var(--ibe-border);
    padding: 16px 32px;
    display: flex; align-items: center; justify-content: space-between;
    position: sticky; top: 0; z-index: 50;
}
.topbar h1 { font-size: 20px; font-weight: 500; color: var(--ibe-dark); margin: 0; }
.topbar-actions { display: flex; gap: 12px; align-items: center; }

.page-content { padding: 28px 32px; }

.mobile-toggle {
    display: none; background: none; border: none;
    font-size: 24px; color: var(--ibe-dark); cursor: pointer;
}

/* ============ DASHBOARD WELCOME ============ */
.dashboard-welcome {
    text-align: center;
    padding: 40px 20px 36px;
}
.dashboard-welcome h1 {
    font-size: 26px; font-weight: 700;
    color: var(--ibe-dark); margin: 0 0 6px;
}
.dashboard-welcome p {
    font-size: 14px; color: #888; margin: 0;
}

/* ============ MODULE GRID ============ */
.module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    padding: 0 32px 40px;
    max-width: 1100px;
    margin: 0 auto;
}

.module-card {
    background: #fff;
    border-radius: 8px;
    border: 1px solid var(--ibe-border);
    box-shadow: var(--ibe-card-shadow);
    padding: 24px;
    display: flex; align-items: center; gap: 18px;
    text-decoration: none; color: inherit;
    transition: all 0.2s;
    position: relative;
}
.module-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 50, 75, 0.12);
    border-color: var(--ibe-blue);
}
.module-card:active { transform: translateY(0); }

.module-icon {
    width: 52px; height: 52px; border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 24px; flex-shrink: 0;
}
.module-blue   { background: rgba(89,133,194,0.12);  color: var(--ibe-blue); }
.module-dark   { background: rgba(0,50,75,0.1);      color: var(--ibe-dark); }
.module-green  { background: rgba(157,192,66,0.12);  color: #5a8a10; }
.module-orange { background: rgba(224,130,45,0.12);  color: var(--ibe-orange); }
.module-gray   { background: rgba(154,174,183,0.15); color: #5a6b73; }

.module-info { flex: 1; min-width: 0; }
.module-info h3 {
    margin: 0 0 4px; font-size: 15px; font-weight: 600; color: var(--ibe-dark);
}
.module-info p {
    margin: 0; font-size: 12px; color: #888; line-height: 1.4;
    overflow: hidden; text-overflow: ellipsis;
}

.module-arrow {
    font-size: 18px; color: #ccc; transition: all 0.2s; flex-shrink: 0;
}
.module-card:hover .module-arrow { color: var(--ibe-blue); transform: translateX(3px); }

.module-badge {
    position: absolute; top: 8px; right: 10px;
    font-size: 10px; background: rgba(154,174,183,0.2); color: #5a6b73;
    padding: 2px 8px; border-radius: 10px;
    text-transform: uppercase; letter-spacing: 0.5px;
}

.no-modules {
    grid-column: 1 / -1; text-align: center; padding: 60px 20px; color: #888;
}
.no-modules h3 { color: var(--ibe-dark); margin: 0 0 8px; font-size: 16px; }
.no-modules p { margin: 0; font-size: 13px; }

/* ============ STARTSEITE (Dashboard nach Login, 14.10.2026) ============ */
/* Gleiches Hintergrundbild wie die Anmeldeseite; Karten und Kacheln bleiben weiss,
   frei stehende Ueberschriften werden weiss. body.startseite setzt dashboard.html. */
body.startseite {
    background: #163B4B url('../img/hintergrund-startseite.png') center top / cover no-repeat fixed;
}
body.startseite .topbar { background: rgba(255,255,255,0.94); }
body.startseite .page-content > section > div > h2,
body.startseite .page-content > section > div > h2 span { color: #fff !important; }
body.startseite .page-content > section > div > span { color: rgba(255,255,255,0.8) !important; }
body.startseite .module-card { box-shadow: 0 4px 18px rgba(0,0,0,0.25); }
@media (max-width: 900px) { body.startseite { background-attachment: scroll; } }

/* ============ LOGIN PAGE ============ */
/* Startseite (14.10.2026): neues Hintergrundbild mit Biber-Muster und iBE-Wortmarke
   (static/img/hintergrund-startseite.png, 2560x1440). Die Wortmarke liegt im oberen
   Drittel, deshalb sitzt die Anmeldekarte darunter; auf schmalen Bildschirmen wird
   das Bild beschnitten (cover) und die Karte rueckt nach oben. */
.login-body {
    background: #163B4B url('../img/hintergrund-startseite.png') center top / cover no-repeat fixed;
    display: flex; align-items: flex-start; justify-content: center;
    min-height: 100vh; padding-top: 34vh;
}
.login-container { width: 100%; max-width: 400px; padding: 20px; }
@media (max-width: 700px), (max-height: 640px) {
    .login-body { padding-top: 22vh; background-attachment: scroll; }
}

.login-card {
    background: #fff; border-radius: 12px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.2); overflow: hidden;
}
.login-header {
    background: var(--ibe-dark);
    padding: 32px 24px; text-align: center; color: #fff;
}
.login-logo { height: 48px; margin-bottom: 12px; }
.login-header h1 { margin: 0; font-size: 22px; font-weight: 700; }
.login-header p { margin: 6px 0 0; font-size: 13px; color: rgba(255,255,255,0.6); }

.login-body-inner { padding: 28px 24px; }

.btn-keycloak {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; padding: 14px;
    background: var(--ibe-blue); color: #fff; border: none; border-radius: 6px;
    font-size: 15px; font-weight: 600; font-family: 'Roboto', sans-serif;
    text-decoration: none; cursor: pointer; transition: all 0.15s;
}
.btn-keycloak:hover { background: #4a73b0; }
.kc-icon { font-size: 18px; }

.login-divider {
    display: flex; align-items: center; margin: 20px 0; color: #bbb; font-size: 12px;
}
.login-divider::before, .login-divider::after {
    content: ''; flex: 1; border-top: 1px solid var(--ibe-border);
}
.login-divider span { padding: 0 12px; }

.login-footer {
    text-align: center; margin-top: 16px;
    font-size: 11px; color: rgba(255,255,255,0.75); text-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

/* ============ FORMS ============ */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block; font-size: 13px; font-weight: 500;
    color: var(--ibe-dark); margin-bottom: 6px;
}
.form-control, .form-input {
    width: 100%; padding: 10px 14px;
    border: 1px solid var(--ibe-border); border-radius: 6px;
    font-size: 14px; font-family: 'Roboto', sans-serif;
    background: #fff; color: #333; transition: border-color 0.2s;
}
.form-control:focus, .form-input:focus {
    outline: none; border-color: var(--ibe-blue);
    box-shadow: 0 0 0 3px rgba(89,133,194,0.15);
}
select.form-control { appearance: auto; }

.btn-login {
    width: 100%; padding: 12px;
    background: var(--ibe-dark); color: #fff; border: none; border-radius: 6px;
    font-size: 14px; font-weight: 600; cursor: pointer;
    font-family: 'Roboto', sans-serif; transition: all 0.15s;
}
.btn-login:hover { background: var(--ibe-dark-hover); }

/* ============ CARDS ============ */
.card {
    background: #fff; border-radius: 8px;
    box-shadow: var(--ibe-card-shadow);
    border: 1px solid var(--ibe-border);
    margin-bottom: 20px; overflow: hidden;
}
.card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--ibe-border);
    display: flex; align-items: center; justify-content: space-between;
}
.card-header h2 { font-size: 16px; font-weight: 500; color: var(--ibe-dark); margin: 0; }

/* ============ ADMIN PAGES ============ */
.admin-content {
    max-width: 1100px; margin: 0 auto; padding: 28px 32px;
}
.page-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 24px;
}
.page-header h1 { margin: 0; font-size: 20px; font-weight: 500; color: var(--ibe-dark); }

/* Tables */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th {
    padding: 10px 14px; text-align: left;
    font-weight: 500; font-size: 12px; color: var(--ibe-dark);
    text-transform: uppercase; letter-spacing: 0.5px;
    border-bottom: 2px solid var(--ibe-border);
    background: var(--ibe-light-bg); white-space: nowrap;
}
.data-table td {
    padding: 10px 14px; border-bottom: 1px solid var(--ibe-border); vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: rgba(89,133,194,0.04); }
.data-table .row-selected { background: rgba(89,133,194,0.06); }

.module-icon-sm {
    width: 30px; height: 30px; border-radius: 6px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 14px;
}

/* User Cards */
.user-card { margin-bottom: 12px; }
.user-card-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 20px; border-bottom: 1px solid var(--ibe-border);
}
.user-card-info { display: flex; align-items: center; gap: 12px; }
.user-avatar-lg {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--ibe-blue); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.user-card-modules {
    padding: 12px 20px; display: flex; flex-wrap: wrap; gap: 8px;
}
.module-checkbox {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 14px; border: 1px solid var(--ibe-border); border-radius: 20px;
    font-size: 13px; cursor: pointer; transition: all 0.15s; user-select: none;
}
.module-checkbox:hover { background: var(--ibe-light-bg); }
.module-checkbox.checked {
    background: rgba(89,133,194,0.08); border-color: var(--ibe-blue);
    color: var(--ibe-dark); font-weight: 500;
}
.module-checkbox input { display: none; }
.module-icon-xs {
    width: 20px; height: 20px; border-radius: 4px;
    display: inline-flex; align-items: center; justify-content: center; font-size: 10px;
}

/* ============ BUTTONS ============ */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 8px 18px; border-radius: 6px;
    font-size: 14px; font-weight: 500;
    font-family: 'Roboto', sans-serif; cursor: pointer;
    border: none; text-decoration: none;
    transition: all 0.2s; white-space: nowrap;
}
.btn-primary { background: var(--ibe-dark); color: #fff; }
.btn-primary:hover { background: var(--ibe-dark-hover); }
.btn-secondary { background: #fff; color: var(--ibe-dark); border: 1px solid var(--ibe-border); }
.btn-secondary:hover { background: var(--ibe-light-bg); }
.btn-sm { padding: 5px 12px; font-size: 13px; }

/* ============ BADGES ============ */
.badge {
    display: inline-block; padding: 3px 10px;
    border-radius: 12px; font-size: 12px; font-weight: 500;
}
.badge-active { background: rgba(157,192,66,0.15); color: #5a7a1f; }
.badge-inactive { background: rgba(200,50,50,0.1); color: #E0822D; }

/* ============ ALERTS ============ */
.flash-container { max-width: 1100px; margin: 0 auto; padding: 16px 32px 0; }
.alert {
    padding: 12px 18px; border-radius: 6px; font-size: 14px;
    margin-bottom: 12px; display: flex; align-items: center; gap: 8px;
}
.alert-success { background: rgba(157,192,66,0.12); color: #4a6a1a; border: 1px solid rgba(157,192,66,0.3); }
.alert-danger  { background: rgba(220,53,69,0.08); color: #E0822D; border: 1px solid rgba(220,53,69,0.2); }
.alert-warning { background: rgba(224,130,45,0.1); color: #8a5a1e; border: 1px solid rgba(224,130,45,0.25); }
.alert-info    { background: rgba(89,133,194,0.1); color: #5985C2; border: 1px solid rgba(89,133,194,0.25); }

/* Sidebar-Backdrop fuer Mobile (per JS aktiviert) */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.45);
    z-index: 99;
}
body.sidebar-open .sidebar-backdrop { display: block; }
body.sidebar-open { overflow: hidden; }

/* ============ RESPONSIVE: Tablet + Phone (<900px) ============ */
@media (max-width: 900px) {
    .sidebar { transform: translateX(-100%); width: 280px; box-shadow: 4px 0 20px rgba(0,0,0,0.25); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .mobile-toggle { display: block; padding: 4px 8px; }

    .topbar {
        padding: 10px 14px;
        flex-wrap: wrap;
        gap: 8px;
    }
    .topbar h1 { font-size: 17px; }
    .topbar-actions {
        flex-wrap: wrap;
        gap: 6px;
        width: 100%;
        justify-content: flex-start;
    }
    .topbar-actions > * { font-size: 12.5px; }

    .page-content, .admin-content { padding: 14px 12px; }

    /* Card / Module-Grid */
    .card { margin-bottom: 12px; }
    .card-header { padding: 10px 12px; flex-wrap: wrap; gap: 6px; }
    .card-header h2 { font-size: 15px; }
    .card-body { padding: 12px; }
    .module-grid { grid-template-columns: 1fr; padding: 0 12px 20px; gap: 12px; }
    .dashboard-welcome { padding: 20px 14px 16px; }
    .dashboard-welcome h1 { font-size: 20px; }

    /* Tabellen scrollbar */
    .table-container, [class*="tablewrap"] {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        max-width: 100%;
    }
    .table { font-size: 12.5px; }
    .table th, .table td { padding: 7px 8px; }

    /* Filter-Bars */
    .filter-bar {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    .filter-bar > * { width: 100%; }
    .filter-bar input, .filter-bar select { font-size: 14px; width: 100%; }

    /* Stats / KPI */
    .stats-grid { grid-template-columns: repeat(2, 1fr) !important; gap: 10px; }
    .stat-card { padding: 12px 14px !important; }
    .stat-info .stat-value { font-size: 22px !important; }

    /* Inline-Grids zwingen */
    [style*="grid-template-columns"] {
        grid-template-columns: 1fr !important;
    }
    .stats-grid[style*="grid-template-columns"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* Form-Layouts entstapeln */
    .form-row, .form-grid { display: block !important; }
    .form-row > *, .form-grid > * { width: 100% !important; margin-bottom: 8px; }
    .form-control { font-size: 14px; }

    .btn { white-space: nowrap; }
}

/* ============ RESPONSIVE: Phone (<560px) ============ */
@media (max-width: 560px) {
    .topbar h1 { font-size: 15px; }
    .page-content, .admin-content { padding: 10px 8px; }
    .card-body { padding: 10px; }
    .stats-grid { grid-template-columns: 1fr !important; }
    .stats-grid[style*="grid-template-columns"] { grid-template-columns: 1fr !important; }
    .table { font-size: 12px; }
}

/* ============ UTILITIES ============ */
.text-muted { color: #999; }
.d-flex { display: flex; }
.gap-2 { gap: 8px; }
.align-center { align-items: center; }

/* ===========================================
   GERAETE-SPEZIFISCHE TWEAKS (data-Attribute aus shared/device.py)
   =========================================== */
body[data-os="ios"] input,
body[data-os="ios"] select,
body[data-os="ios"] textarea { font-size: 16px; }

body[data-device="mobile"] .btn,
body[data-device="tablet"] .btn { min-height: 38px; padding-top: 8px; padding-bottom: 8px; }
body[data-device="mobile"] .btn-sm,
body[data-device="tablet"] .btn-sm { min-height: 34px; }

body[data-device="mobile"] .ibe-pbx-call { display: none; }

body[data-device="mobile"] #audit-widget {
    bottom: 8px !important; right: 8px !important;
}
body[data-device="mobile"] #audit-widget-btn {
    width: 38px !important; height: 38px !important; font-size: 17px !important;
}
body[data-device="mobile"] .bugtool-widget {
    bottom: 56px !important; right: 8px !important;
    transform: scale(0.85); transform-origin: bottom right;
}
@media print {
    .ibe-pbx-call, .mobile-toggle, .sidebar-backdrop,
    #audit-widget, .bugtool-widget { display: none !important; }
}

/* Seitenleiste (14.10.2026): die neue Wortmarke ist breiter als das alte Logo -> Logo ueber dem
   Modultitel statt daneben, sonst ueberlappen beide in der 250-px-Leiste. */
.sidebar-logo { flex-direction: column; align-items: flex-start; gap: 8px; }
.sidebar-logo img { height: 30px; width: auto; }
