/**
 * Custom CSS - Admin Platform
 *
 * Branding and custom styles for the multi-tenant admin platform.
 * Uses CSS Custom Properties for dynamic theming.
 *
 * Implements PFLICHTENHEFT 3.5 and 4.1.5 white-label branding requirements.
 */

/* CSS Custom Properties for Branding
 *
 * These variables are overridden dynamically via inline <style> tag in the base template
 * based on configuration values from config.php['branding']
 *
 * Default values (AdminLTE blue):
 * - primary_color: #3c8dbc (navigation, buttons)
 * - accent_color: #3c8dbc (links, hover states)
 */
:root {
    --primary-color: #3c8dbc;
    --accent-color: #3c8dbc;
}

/* Primary color overrides */
.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

.navbar-light .navbar-nav .nav-link:hover,
.navbar-light .navbar-nav .nav-link:focus {
    color: var(--primary-color);
}

.sidebar-dark-primary .nav-sidebar > .nav-item > .nav-link.active {
    background-color: var(--primary-color);
}

.card-primary:not(.card-outline) > .card-header {
    background-color: var(--primary-color);
}

.card.card-outline.card-primary {
    border-top: 3px solid var(--primary-color);
}

.page-item.active .page-link {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

a {
    color: var(--accent-color);
}

a:hover {
    color: var(--primary-color);
}

/* Brand Logo Styling */
.brand-link .brand-image {
    max-height: 33px;
    width: auto;
}

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

/* ── Sidebar scroll containment ──
 * Prevents scroll events from leaking to main content when
 * the user scrolls inside the sidebar (overscroll-behavior).
 * Also ensures the sidebar is independently scrollable when
 * its contents exceed the viewport height.
 */
.main-sidebar {
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;   /* trap scroll inside sidebar */
}

.main-sidebar .sidebar {
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;   /* trap scroll inside sidebar */
}

/* Sidebar brand: two-row layout (logo + role below) */
.main-sidebar .brand-link {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
}

.main-sidebar .brand-link .brand-image {
    float: none;
}

.brand-role-label {
    width: 100%;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.7;
    padding: 0.15rem 0 0 0.3rem;
}

/* Login Page Branding */
.login-box .card-header img {
    max-height: 60px;
    max-width: 100%;
    object-fit: contain;
}

/* Flash Messages */
.alert {
    border-radius: 4px;
}

.alert i[data-lucide] {
    width: 18px;
    height: 18px;
    vertical-align: middle;
    margin-right: 8px;
}

/* Important alerts with links (password reset, invitations) */
.alert-important {
    border-width: 2px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.alert-important.alert-info {
    background-color: #d1ecf1;
    border-color: #0c5460;
}

.alert-important.alert-warning {
    background-color: #fff3cd;
    border-color: #856404;
}

.alert-important .alert-link {
    font-weight: 600;
    word-break: break-all;
}

.alert-important hr {
    border-top-color: rgba(0, 0, 0, 0.1);
}

/* Lucide Icons */
i[data-lucide] {
    width: 20px;
    height: 20px;
    vertical-align: middle;
}

.nav-icon[data-lucide] {
    width: 20px;
    height: 20px;
}

.small-box .icon i[data-lucide] {
    width: 70px;
    height: 70px;
}

/* Table Icons */
.table i[data-lucide] {
    width: 16px;
    height: 16px;
}

/* Button Icons */
.btn i[data-lucide] {
    width: 16px;
    height: 16px;
    margin-right: 4px;
}

.btn-sm i[data-lucide] {
    width: 14px;
    height: 14px;
    margin-right: 0;
}

/* Card Header Icons */
.card-title i[data-lucide] {
    width: 20px;
    height: 20px;
    margin-right: 8px;
}

/* Badge Styling */
.badge {
    font-size: 85%;
    font-weight: 500;
}

/* DataTable Enhancements */
.table-hover tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.03);
}

/* Form Validation */
.is-invalid {
    border-color: #dc3545;
}

.invalid-feedback {
    display: block;
    color: #dc3545;
    font-size: 0.875rem;
    margin-top: 0.25rem;
}

/* Responsive Improvements */
@media (max-width: 768px) {
    .brand-text {
        font-size: 1rem;
    }

    .content-header h1 {
        font-size: 1.5rem;
    }

    .small-box .inner h3 {
        font-size: 2rem;
    }
}

/* Modal Enhancements */
.modal-header {
    background-color: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.modal-title i[data-lucide] {
    width: 24px;
    height: 24px;
    margin-right: 8px;
}

/* GDPR Consent Styling */
#gdprConsentModal .form-check-label {
    font-size: 0.95rem;
    line-height: 1.5;
}

/* Audit Log Details */
#detailsContent {
    background-color: #f8f9fa;
    padding: 1rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-family: 'Courier New', monospace;
}

/* Status Badges */
.badge-primary {
    background-color: var(--primary-color);
}

/* Loading State */
.btn[disabled] {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Footer Styling */
.main-footer {
    background-color: #fff;
    border-top: 1px solid #dee2e6;
}

/* Print Styles */
@media print {
    .main-header,
    .main-sidebar,
    .main-footer,
    .content-header,
    .btn,
    .card-tools {
        display: none !important;
    }

    .content-wrapper {
        margin-left: 0 !important;
        padding-top: 0 !important;
    }

    .card {
        border: 1px solid #000;
    }
}

/* Utility Classes */
.text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.cursor-pointer {
    cursor: pointer;
}

/* ── Sidebar treeview chevron (Lucide icons) ──
 * AdminLTE expects Font Awesome for the rotate animation on
 * .nav-treeview toggle.  We replicate the same effect for the
 * Lucide SVG icon used as the chevron indicator.
 */
.nav-sidebar .nav-item.has-treeview > .nav-link > p > .right {
    display: inline-block;
    transition: transform 0.3s ease;
}

.nav-sidebar .nav-item.has-treeview.menu-open > .nav-link > p > .right {
    transform: rotate(-90deg);
}

/* Treeview child indent: give sub-items a bit more left padding */
.nav-sidebar .nav-treeview > .nav-item > .nav-link {
    padding-left: 2rem;
}

/* Animation for Alpine.js */
[x-cloak] {
    display: none !important;
}

/* Custom Scrollbar for Webkit browsers */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #555;
}
