/* PXSP UI Fixes - v2 with stronger specificity */

/* 1. Notifications: Fix checkbox alignment going into left border */
body .pxsp-notification-pref-item {
    padding: 12px 20px 12px 20px !important; /* Increase left padding significantly */
    align-items: flex-start !important;
    gap: 12px !important; /* Ensure gap between checkbox and text */
}

body .pxsp-notification-pref-item.form-check {
    display: flex !important;
    align-items: flex-start !important;
    padding-left: 20px !important;
}

body .pxsp-notification-pref-item .form-check-input {
    flex-shrink: 0 !important;
    margin-top: 2px !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    position: relative !important;
    left: 0 !important;
}

body .pxsp-notification-pref-item .form-check-label {
    margin-left: 0 !important;
    padding-left: 0 !important;
}

/* 2. ToDo: Fix header alignment and switch toggle visibility */
body .pxsp-todos-root .form-check-switch {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    margin-top: 0 !important;
}

body .pxsp-todos-root .form-check-switch .form-check-input {
    width: 44px !important;
    height: 24px !important;
    cursor: pointer !important;
    flex-shrink: 0 !important;
    margin: 0 !important;
}

body .pxsp-todos-root .form-check-switch .form-check-input:checked {
    background-color: rgb(59, 130, 246) !important;
    border-color: rgb(59, 130, 246) !important;
}

body .pxsp-todos-root .form-check-switch .form-check-label {
    white-space: nowrap !important;
    font-size: 0.875rem !important;
    margin-bottom: 0 !important;
    cursor: pointer !important;
    user-select: none !important;
}

/* Responsive fix for the toggle */
@media (max-width: 1399px) {
    body .pxsp-todos-root .col-6.col-md-8.col-xl-1 {
        display: flex !important;
        align-items: center !important;
        width: auto !important;
        flex: 0 0 auto !important;
    }

    body .pxsp-todos-root .form-check-switch {
        margin-top: 0 !important;
    }
}

/* Make filter row more spacious */
body .pxsp-todos-root .card .row.g-2 {
    gap: 1rem !important;
}

/* 3. ToDo: Fix dropdown text becoming white when active */
body .pxsp-todos-root .pxsp-todo-project-item.active {
    background: rgba(59, 130, 246, 0.12) !important;
    border-color: rgba(59, 130, 246, 0.35) !important;
}

body .pxsp-todos-root .pxsp-todo-project-item.active,
body .pxsp-todos-root .pxsp-todo-project-item.active * {
    color: inherit !important;
}

body .pxsp-todos-root .pxsp-todo-project-item.active .title {
    color: var(--bs-body-color, #212529) !important;
    font-weight: 600 !important;
}

body .pxsp-todos-root .pxsp-todo-project-item.active .meta {
    color: var(--muted, #6c757d) !important;
    opacity: 0.9 !important;
}

/* Light mode specific */
body:not([data-theme="dark"]) .pxsp-todos-root .pxsp-todo-project-item.active .title {
    color: #212529 !important;
}

body:not([data-theme="dark"]) .pxsp-todos-root .pxsp-todo-project-item.active .meta {
    color: #6c757d !important;
}

/* Dark mode specific */
body[data-theme="dark"] .pxsp-todos-root .pxsp-todo-project-item.active .title,
html[data-theme="dark"] body .pxsp-todos-root .pxsp-todo-project-item.active .title {
    color: #ffffff !important;
}

body[data-theme="dark"] .pxsp-todos-root .pxsp-todo-project-item.active .meta,
html[data-theme="dark"] body .pxsp-todos-root .pxsp-todo-project-item.active .meta {
    color: rgba(255, 255, 255, 0.7) !important;
}

/* 4. Customer Projects: Fix widget text overflow */
body .cp-submodule-card {
    min-height: 96px !important;
    height: auto !important;
    padding: 14px 8px 16px 8px !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 8px !important;
    position: relative !important;
    overflow: visible !important;
}

body .cp-submodule-card .cp-icon {
    font-size: 1.7rem !important;
    line-height: 1 !important;
    margin-bottom: 0 !important;
    flex-shrink: 0 !important;
}

body .cp-submodule-card .cp-label {
    font-size: 0.74rem !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
    margin-top: 4px !important;
    text-align: center !important;
    word-wrap: break-word !important;
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    hyphens: manual !important; /* Changed from auto to manual for better control */
    -webkit-hyphens: manual !important;
    -ms-hyphens: manual !important;
    max-width: 100% !important;
    width: 100% !important;
    padding: 0 4px !important;
    white-space: normal !important;
    display: block !important;
}

/* Handle very long German compound words */
body .cp-submodule-card .cp-label {
    /* Allow breaking at specific points for German compound words */
    word-break: break-all !important; /* Forces break even without spaces */
}

/* Adjust card column widths for better text accommodation */
@media (min-width: 576px) {
    body .row .col-4:has(.cp-submodule-card) {
        flex: 0 0 33.33333% !important;
        max-width: 33.33333% !important;
    }
}

/* Mobile adjustments */
@media (max-width: 575px) {
    body .cp-submodule-card {
        min-height: 100px !important;
        padding: 16px 10px !important;
    }

    body .cp-submodule-card .cp-label {
        font-size: 0.75rem !important;
    }

    body .row .col-4:has(.cp-submodule-card) {
        flex: 0 0 50% !important;
        max-width: 50% !important;
    }
}

/* Tablet adjustments */
@media (min-width: 576px) and (max-width: 991px) {
    body .cp-submodule-card .cp-label {
        font-size: 0.73rem !important;
        padding: 0 3px !important;
    }
}

/* Additional overrides to ensure styles are applied */
body .card .cp-submodule-card,
body .container .cp-submodule-card,
body .row .cp-submodule-card {
    height: auto !important;
    min-height: 96px !important;
}

/* Debug helpers - remove these in production */
body .pxsp-notification-pref-item {
    border-left: 3px solid transparent !important; /* Prevents visual cut-off */
}

body .cp-submodule-card .cp-label {
    /* Visual indicator for debugging - remove later */
    /* outline: 1px dotted red; */
}