/* Service Portal – Dark Theme (Epitome-Stil) */

:root {
    --sidebar-width: 250px;
    --topbar-height: 56px;
    --bg-dark: #0f172a;
    --bg-card: #1e293b;
    --bg-sidebar: #141b2d;
    --border-color: #334155;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
}

/* Login Card */
.login-card {
    width: 100%;
    max-width: 440px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 1rem;
    padding: 2.5rem;
    box-shadow: 0 25px 50px rgba(0,0,0,.5);
}

/* Form controls */
.form-control, .form-select {
    background: var(--bg-dark);
    border-color: var(--border-color);
    color: var(--text-primary);
}
.form-control:focus, .form-select:focus {
    background: var(--bg-dark);
    border-color: var(--accent);
    color: var(--text-primary);
    box-shadow: 0 0 0 .25rem rgba(99,102,241,.25);
}

/* Buttons */
.btn-primary { background: var(--accent); border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    overflow-y: auto;
    z-index: 1040;
    transition: transform .2s ease;
}

.sidebar-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .5rem;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.1rem;
}

.sidebar-brand-icon { font-size: 1.3rem; color: var(--accent); }

.sidebar-nav {
    list-style: none;
    padding: .5rem 0;
    margin: 0;
}

.sidebar-heading {
    padding: .75rem 1.25rem .25rem;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-secondary);
}

.sidebar-divider {
    border-top: 1px solid var(--border-color);
    margin: .5rem 1rem;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .5rem 1.25rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: .875rem;
    transition: all .15s;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    color: var(--text-primary);
    background: rgba(99,102,241,.08);
}

.sidebar-link.active {
    color: var(--accent);
    background: rgba(99,102,241,.12);
    border-left-color: var(--accent);
}

.sidebar-link i {
    font-size: 1rem;
    width: 1.25rem;
    text-align: center;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-width: 0;
}

/* Topbar */
.topbar {
    height: var(--topbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1030;
}

.topbar-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    color: var(--text-primary);
    white-space: nowrap;
}

.topbar-right {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: .5rem;
}

.sidebar-toggle { display: none; }

/* Content */
.content-area {
    padding: 1.5rem;
}

/* Stat Cards */
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: .75rem;
    padding: 1.25rem;
    transition: border-color .2s;
}
.stat-card:hover { border-color: var(--accent); }
.stat-card .stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}
.stat-card .stat-label {
    font-size: .8rem;
    color: var(--text-secondary);
    margin-top: .25rem;
}
.stat-card .stat-icon {
    font-size: 2rem;
    opacity: .3;
}

/* Service Cards */
.service-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: .75rem;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all .2s;
    height: 100%;
}
.service-card:hover {
    border-color: var(--accent);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0,0,0,.3);
}
.service-card-icon {
    width: 48px;
    height: 48px;
    border-radius: .75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}
.service-card-body {
    flex: 1;
    min-width: 0;
}
.service-card-title {
    font-size: .9rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.service-card-desc {
    font-size: .78rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: .15rem;
}
.service-card-arrow {
    color: var(--text-secondary);
    opacity: 0;
    transition: opacity .2s;
    font-size: .85rem;
}
.service-card:hover .service-card-arrow {
    opacity: 1;
}

/* Table */
.table-dark-custom {
    --bs-table-bg: var(--bg-card);
    --bs-table-border-color: var(--border-color);
    --bs-table-hover-bg: rgba(99,102,241,.08);
}

/* Modal */
.modal-dark .modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}
.modal-dark .modal-header {
    border-bottom-color: var(--border-color);
}
.modal-dark .modal-footer {
    border-top-color: var(--border-color);
}

/* Responsive */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.show {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
    }
    .sidebar-toggle { display: block; }
}

@media (max-width: 575.98px) {
    .content-area { padding: 1rem; }
    .topbar { padding: 0 1rem; }
}

/* Icon Picker */
.icon-picker-wrap { position: relative; }
.icon-picker-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 1060;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    border-radius: .5rem;
    padding: .75rem;
    max-height: 280px;
    overflow-y: auto;
    display: none;
    box-shadow: 0 8px 25px rgba(0,0,0,.4);
}
.icon-picker-dropdown.show { display: block; }
.icon-picker-search {
    width: 100%;
    padding: .35rem .6rem;
    margin-bottom: .5rem;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: .35rem;
    color: var(--text-primary);
    font-size: .8rem;
}
.icon-picker-search::placeholder { color: var(--text-secondary); }
.icon-picker-search:focus {
    outline: none;
    border-color: var(--accent);
}
.icon-picker-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 2px;
}
.icon-picker-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: .45rem;
    border-radius: .35rem;
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 1.1rem;
    transition: all .15s;
}
.icon-picker-item:hover {
    background: rgba(99,102,241,.15);
    color: var(--accent);
}
.icon-picker-item.active {
    background: rgba(99,102,241,.2);
    color: var(--accent);
}
.icon-picker-dropdown::-webkit-scrollbar { width: 4px; }
.icon-picker-dropdown::-webkit-scrollbar-track { background: transparent; }
.icon-picker-dropdown::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

/* Icon Preview in Input Group */
.icon-preview-box {
    background: var(--bg-dark);
    border-color: var(--border-color);
    color: var(--accent);
    min-width: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
}

/* Category Tree */
.tree-indent {
    display: inline-block;
    width: 1.25rem;
}
.tree-branch {
    color: var(--text-secondary);
    margin-right: .35rem;
    font-size: .85rem;
}

/* Sidebar Nested */
.sidebar-sub .sidebar-link {
    padding-left: 2.25rem;
    font-size: .8rem;
    padding-top: .35rem;
    padding-bottom: .35rem;
}
.sidebar-sub-deep .sidebar-link {
    padding-left: 3.25rem;
    font-size: .75rem;
    padding-top: .3rem;
    padding-bottom: .3rem;
}

/* Scrollbar */
.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-track { background: transparent; }
.sidebar::-webkit-scrollbar-thumb { background: var(--border-color); border-radius: 2px; }

/* === Dashboard Cards === */
.dash-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: .75rem;
    overflow: hidden;
}
.dash-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .875rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-primary);
}
.dash-card-header h6 {
    font-size: .85rem;
    font-weight: 600;
}
.dash-card-body {
    padding: 1.25rem;
}
.dash-card-footer {
    padding: .75rem 1.25rem;
    border-top: 1px solid var(--border-color);
}

/* Progress bars */
.progress {
    background: rgba(255,255,255,.06);
    border-radius: 2px;
}

/* Container Card */
.container-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: .75rem;
    padding: 1rem 1.25rem;
    transition: border-color .2s;
}
.container-card:hover {
    border-color: var(--accent);
}
.container-card .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: .5rem;
    flex-shrink: 0;
}
.status-dot.running { background: #22c55e; box-shadow: 0 0 6px rgba(34,197,94,.4); }
.status-dot.stopped { background: #ef4444; }
.status-dot.paused  { background: #f59e0b; }
.status-dot.unknown { background: #6b7280; }

/* Health Badge */
.health-badge {
    display: inline-flex;
    align-items: center;
    gap: .35rem;
    font-size: .75rem;
    font-weight: 500;
    padding: .2rem .6rem;
    border-radius: .35rem;
}
/* Health status: Python writes "up", "slow", "down", "timeout", "unknown" */
.health-badge.up      { background: rgba(34,197,94,.15); color: #4ade80; }
.health-badge.healthy { background: rgba(34,197,94,.15); color: #4ade80; }
.health-badge.slow    { background: rgba(245,158,11,.15); color: #fbbf24; }
.health-badge.warning { background: rgba(245,158,11,.15); color: #fbbf24; }
.health-badge.down    { background: rgba(239,68,68,.15); color: #f87171; }
.health-badge.timeout { background: rgba(239,68,68,.15); color: #f87171; }
.health-badge.unknown { background: rgba(107,114,128,.15); color: #9ca3af; }

/* Alert Item */
.alert-item {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .75rem 1rem;
    border-bottom: 1px solid var(--border-color);
}
.alert-item:last-child { border-bottom: none; }
.alert-item .alert-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: .35rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .8rem;
}
.alert-item .alert-icon.critical { background: rgba(239,68,68,.15); color: #f87171; }
.alert-item .alert-icon.warning  { background: rgba(245,158,11,.15); color: #fbbf24; }
.alert-item .alert-icon.info     { background: rgba(59,130,246,.15); color: #60a5fa; }

/* Activity Item */
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: .75rem;
    padding: .75rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    font-size: .8rem;
}
.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: rgba(99,102,241,.04); }
.activity-item .activity-time {
    flex-shrink: 0;
    color: var(--text-secondary);
    font-size: .75rem;
    width: 70px;
    text-align: right;
}
.activity-item .activity-type {
    flex-shrink: 0;
    width: 20px;
    text-align: center;
    color: var(--accent);
}
.activity-item .activity-msg {
    flex: 1;
    color: var(--text-primary);
    min-width: 0;
    word-break: break-word;
}

/* Compact List Item */
.compact-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .5rem 1.25rem;
    border-bottom: 1px solid var(--border-color);
    font-size: .8rem;
}
.compact-item:last-child { border-bottom: none; }
.compact-item:hover { background: rgba(99,102,241,.04); }

/* Quick Action Buttons */
.btn-action {
    padding: .15rem .4rem;
    font-size: .7rem;
    border-radius: .25rem;
}

/* Sidebar Heading */
.sidebar-heading {
    padding: .75rem 1.25rem .25rem;
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-secondary);
}

/* Queue status colors */
.queue-pending  { color: #fbbf24; }
.queue-running  { color: #60a5fa; }
.queue-done     { color: #4ade80; }
.queue-failed   { color: #f87171; }

/* Update Terminal */
.update-terminal {
    background: #0c0c14;
    color: #c8d6e5;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: .78rem;
    line-height: 1.5;
    padding: 1rem;
    max-height: 400px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}
.update-terminal::-webkit-scrollbar { width: 6px; }
.update-terminal::-webkit-scrollbar-track { background: #0c0c14; }
.update-terminal::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }

.terminal-line { padding: 1px 0; }
.terminal-error { color: #f87171; }
.terminal-success { color: #4ade80; }
.terminal-warn { color: #fbbf24; }

/* Button xs */
.btn-xs {
    padding: .2rem .5rem;
    font-size: .72rem;
    line-height: 1.4;
}

/* Docker update row highlight */
.table-row-update {
    border-left: 3px solid #fbbf24;
}

/* === Enhanced Responsive === */

/* Sidebar overlay auf Mobile */
@media (max-width: 991.98px) {
    .sidebar.show {
        box-shadow: 0 0 50px rgba(0,0,0,.5);
    }
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,.4);
        z-index: 1039;
        display: none;
    }
    .sidebar.show ~ .sidebar-overlay { display: block; }
}

/* Stat-Cards auf Mobile */
@media (max-width: 575.98px) {
    .stat-card {
        padding: .875rem 1rem;
    }
    .stat-card .stat-value {
        font-size: 1.3rem;
    }
    .stat-card .stat-icon {
        font-size: 1.5rem;
    }

    /* Tabellen horizontal scrollbar */
    .table-responsive { -webkit-overflow-scrolling: touch; }

    /* Container-Cards einzeln */
    .container-card {
        padding: .75rem 1rem;
    }

    /* Kompaktere Dash-Cards */
    .dash-card-header {
        padding: .625rem 1rem;
        flex-wrap: wrap;
        gap: .5rem;
    }
    .dash-card-body {
        padding: .875rem 1rem;
    }

    /* Activity items kompakter */
    .activity-item {
        padding: .5rem .75rem;
        gap: .5rem;
    }
    .activity-item .activity-time {
        width: 55px;
        font-size: .7rem;
    }

    /* Buttons wrapping */
    .d-flex.gap-2.flex-wrap > .btn {
        flex: 1 1 auto;
        min-width: 0;
    }

    /* Topbar kompakter */
    .topbar {
        padding: 0 .75rem;
    }
    .topbar-title {
        font-size: .95rem;
    }

    /* Chart kleiner */
    .chart-container {
        min-height: 200px !important;
    }

    /* Login-Card auf Mobile */
    .login-card {
        padding: 1.5rem;
        margin: 1rem;
        border-radius: .75rem;
    }

    /* Update-Terminal */
    .update-terminal {
        max-height: 250px;
        font-size: .7rem;
        padding: .75rem;
    }
}

/* Mittlere Screens */
@media (min-width: 576px) and (max-width: 991.98px) {
    .content-area { padding: 1.25rem; }
}

/* Touch-freundliche Interaktionen */
@media (hover: none) {
    .service-card:hover {
        transform: none;
    }
    .btn-action {
        padding: .3rem .6rem;
        font-size: .75rem;
    }
}

/* === Widget Drag & Drop === */
.widget-block {
    transition: transform .15s ease, box-shadow .15s ease;
}
.widget-block[draggable="true"] {
    cursor: grab;
}
.widget-block[draggable="true"]:active {
    cursor: grabbing;
}
.widget-block.drag-over {
    border-top: 2px solid var(--accent);
    margin-top: -2px;
}
.widget-drag-handle {
    padding: .4rem .75rem;
    font-size: .75rem;
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(99,102,241,.06);
    border-radius: .5rem .5rem 0 0;
    margin-bottom: -1px;
    cursor: grab;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.widget-drag-handle i {
    color: var(--accent);
    opacity: .6;
}

/* === Log Viewer === */
.log-container-item {
    cursor: pointer;
    transition: background .15s;
}
.log-container-item:hover {
    background: rgba(99,102,241,.08);
}
.log-container-item.active {
    background: rgba(99,102,241,.15);
    border-left: 3px solid var(--accent);
}
.log-output {
    background: #0c0c14;
    color: #c8d6e5;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: .78rem;
    line-height: 1.6;
    padding: 1rem;
    max-height: 600px;
    overflow-y: auto;
    border-radius: .5rem;
}
.log-output::-webkit-scrollbar { width: 6px; }
.log-output::-webkit-scrollbar-track { background: #0c0c14; }
.log-output::-webkit-scrollbar-thumb { background: #334155; border-radius: 3px; }
.log-line {
    padding: 1px .5rem;
    border-radius: 2px;
}
.log-line.log-error {
    background: rgba(239,68,68,.08);
    color: #f87171;
}
.log-line.log-warn {
    background: rgba(245,158,11,.08);
    color: #fbbf24;
}
.log-line.log-info {
    color: #60a5fa;
}

/* Audit */
.audit-check-card[data-severity="critical"] {
    border-left: 3px solid #ef4444;
}
.audit-check-card[data-severity="warning"] {
    border-left: 3px solid #f59e0b;
}
.audit-check-card[data-severity="ok"] {
    border-left: 3px solid #22c55e;
}
.audit-check-card[data-severity="info"] {
    border-left: 3px solid #3b82f6;
}
.audit-finding {
    padding: 3px 0;
    font-size: .875rem;
    line-height: 1.4;
}
.audit-detail-json {
    background: #0c0c14;
    color: #94a3b8;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: .8rem;
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}
