/* ==================================================
   Ustawienia użytkownika - Wspólnota Mieszkaniowa
   ================================================== */

/* ================== CSS Variables ================== */
:root {
    /* Colors - Light Theme */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #adb5bd;
    --border-color: #dee2e6;
    --link-color: #0d6efd;
    --navbar-bg: #0d6efd;
    --navbar-text: #ffffff;
    --footer-bg: #f8f9fa;
    --card-bg: #ffffff;
    --shadow-color: rgba(0, 0, 0, 0.1);

    /* Font Sizes */
    --font-size-base: 1rem;
    --font-size-small: 0.875rem;
    --font-size-large: 1.125rem;
    --font-size-h1: 2.5rem;
    --font-size-h2: 2rem;
    --font-size-h3: 1.75rem;
    --font-size-h4: 1.5rem;
    --font-size-h5: 1.25rem;
}

/* ================== Dark Mode ================== */
body.dark-mode {
    --bg-primary: #1a1a2e;
    --bg-secondary: #16213e;
    --bg-tertiary: #0f3460;
    --text-primary: #eaeaea;
    --text-secondary: #b8b8b8;
    --text-muted: #888888;
    --border-color: #3a3a5c;
    --link-color: #4dabf7;
    --navbar-bg: #0f3460;
    --navbar-text: #ffffff;
    --footer-bg: #16213e;
    --card-bg: #16213e;
    --shadow-color: rgba(0, 0, 0, 0.4);
}

body.dark-mode {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

body.dark-mode .navbar {
    background-color: var(--navbar-bg) !important;
}

body.dark-mode .card,
body.dark-mode .list-group-item,
body.dark-mode .table,
body.dark-mode .modal-content {
    background-color: var(--card-bg) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

body.dark-mode .bg-light {
    background-color: var(--bg-secondary) !important;
}

body.dark-mode .text-muted {
    color: var(--text-secondary) !important;
}

body.dark-mode .form-control,
body.dark-mode .form-select {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
    border-color: var(--border-color) !important;
}

body.dark-mode .footer {
    background-color: var(--footer-bg) !important;
}

body.dark-mode a:not(.btn):not(.nav-link) {
    color: var(--link-color) !important;
}

body.dark-mode .table-striped>tbody>tr:nth-of-type(odd)>* {
    background-color: var(--bg-tertiary) !important;
    color: var(--text-primary) !important;
}

body.dark-mode .dropdown-menu {
    background-color: var(--bg-secondary) !important;
    border-color: var(--border-color) !important;
}

body.dark-mode .dropdown-item {
    color: var(--text-primary) !important;
}

body.dark-mode .dropdown-item:hover {
    background-color: var(--bg-tertiary) !important;
}

/* ================== High Contrast ================== */
body.high-contrast {
    --bg-primary: #000000;
    --bg-secondary: #1a1a1a;
    --bg-tertiary: #333333;
    --text-primary: #ffffff;
    --text-secondary: #ffff00;
    --text-muted: #ffffff;
    --border-color: #ffffff;
    --link-color: #ffff00;
    --navbar-bg: #000080;
    --navbar-text: #ffffff;
    --footer-bg: #1a1a1a;
    --card-bg: #1a1a1a;
}

body.high-contrast {
    background-color: var(--bg-primary) !important;
    color: var(--text-primary) !important;
}

body.high-contrast .navbar {
    background-color: var(--navbar-bg) !important;
    border-bottom: 3px solid #ffffff !important;
}

body.high-contrast .card,
body.high-contrast .list-group-item {
    background-color: var(--card-bg) !important;
    color: var(--text-primary) !important;
    border: 2px solid var(--border-color) !important;
}

body.high-contrast a {
    color: var(--link-color) !important;
    text-decoration: underline !important;
}

body.high-contrast .btn {
    border: 2px solid #ffffff !important;
}

body.high-contrast .btn-primary {
    background-color: #000080 !important;
    color: #ffffff !important;
}

body.high-contrast .form-control,
body.high-contrast .form-select {
    background-color: #000000 !important;
    color: #ffffff !important;
    border: 2px solid #ffffff !important;
}

body.high-contrast .bg-light {
    background-color: var(--bg-secondary) !important;
}

body.high-contrast .footer {
    background-color: var(--footer-bg) !important;
    border-top: 3px solid #ffffff !important;
}

/* ================== Font Sizes ================== */
body.font-small {
    font-size: 0.85rem !important;
}

body.font-small h1 {
    font-size: 1.8rem !important;
}

body.font-small h2 {
    font-size: 1.5rem !important;
}

body.font-small h3 {
    font-size: 1.3rem !important;
}

body.font-small h4 {
    font-size: 1.15rem !important;
}

body.font-small h5 {
    font-size: 1rem !important;
}

body.font-small .navbar-brand {
    font-size: 1rem !important;
}

body.font-small .btn {
    font-size: 0.8rem !important;
}

body.font-normal {
    font-size: 1rem !important;
}

body.font-large {
    font-size: 1.2rem !important;
}

body.font-large h1 {
    font-size: 3rem !important;
}

body.font-large h2 {
    font-size: 2.5rem !important;
}

body.font-large h3 {
    font-size: 2rem !important;
}

body.font-large h4 {
    font-size: 1.75rem !important;
}

body.font-large h5 {
    font-size: 1.5rem !important;
}

body.font-large .navbar-brand {
    font-size: 1.5rem !important;
}

body.font-large .btn {
    font-size: 1.1rem !important;
}

body.font-large .nav-link {
    font-size: 1.1rem !important;
}

body.font-large .card-title {
    font-size: 1.5rem !important;
}

/* ================== Settings Panel ================== */
.settings-btn {
    background: transparent;
    border: none;
    color: var(--navbar-text);
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    transition: transform 0.3s ease;
}

.settings-btn:hover {
    transform: rotate(45deg);
}

.settings-panel .offcanvas-header {
    background-color: var(--navbar-bg);
    color: white;
}

.settings-panel .offcanvas-body {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

body.dark-mode .settings-panel .offcanvas-body,
body.high-contrast .settings-panel .offcanvas-body {
    background-color: var(--bg-secondary);
}

.settings-group {
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
}

.settings-group:last-child {
    border-bottom: none;
}

.settings-group-title {
    font-weight: 600;
    margin-bottom: 0.75rem;
    color: var(--text-primary);
}

/* Font Size Buttons */
.font-size-controls {
    display: flex;
    gap: 0.5rem;
}

.font-size-btn {
    width: 45px;
    height: 45px;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.font-size-btn:hover {
    background: var(--bg-tertiary);
}

.font-size-btn.active {
    background: var(--navbar-bg);
    color: white;
    border-color: var(--navbar-bg);
}

/* Theme Toggle */
.theme-toggle {
    display: flex;
    gap: 0.5rem;
}

.theme-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    border: 2px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.theme-btn:hover {
    background: var(--bg-tertiary);
}

.theme-btn.active {
    background: var(--navbar-bg);
    color: white;
    border-color: var(--navbar-bg);
}

/* Contrast Toggle Switch */
.contrast-switch {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.switch {
    position: relative;
    display: inline-block;
    width: 60px;
    height: 34px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 26px;
    width: 26px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--navbar-bg);
}

input:checked+.slider:before {
    transform: translateX(26px);
}

/* Language Switcher */
.lang-switcher {
    display: flex;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    padding: 2px;
    margin-left: 1rem;
}

.lang-btn {
    padding: 0.25rem 0.75rem;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.8);
    border-radius: 18px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.2s ease;
}

.lang-btn:hover {
    color: white;
}

.lang-btn.active {
    background: white;
    color: var(--navbar-bg);
}

/* Smooth transitions */
body,
.navbar,
.card,
.footer,
.form-control,
.btn,
a {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

/* ================== AI Chat Widget ================== */
.ai-chat-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1040;
}

.ai-chat-toggle {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    font-size: 1.75rem;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-chat-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(102, 126, 234, 0.6);
}

.ai-chat-window {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 350px;
    height: 450px;
    background: var(--bg-primary);
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: none;
    /* Hidden by default */
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.ai-chat-window.show {
    display: flex !important;
}

.ai-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 600;
}

.ai-chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ai-message {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 16px;
    font-size: 0.9rem;
    line-height: 1.4;
}

.ai-message.bot {
    background: var(--bg-secondary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.ai-message.user {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.ai-chat-input {
    display: flex;
    padding: 0.75rem;
    gap: 0.5rem;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.ai-chat-input input {
    flex: 1;
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.ai-chat-input input:focus {
    outline: none;
    border-color: #667eea;
}

.ai-chat-input button {
    border-radius: 50%;
    width: 38px;
    height: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Mobile responsive */
@media (max-width: 576px) {
    .ai-chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 140px);
        bottom: 75px;
        right: -10px;
    }
}

/* AI Message enhancements */
.ai-message.bot {
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Markdown-like formatting in messages */
.ai-message strong,
.ai-message b {
    font-weight: 600;
    color: var(--text-primary);
}

.ai-message em,
.ai-message i {
    font-style: italic;
}

.ai-message code {
    background: var(--bg-tertiary);
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.85em;
    font-family: 'Courier New', monospace;
}

/* Lists in messages */
.ai-message ul,
.ai-message ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.ai-message li {
    margin: 0.25rem 0;
}

/* Links and buttons in messages */
.ai-message a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

.ai-message a:hover {
    text-decoration: underline;
}

.ai-message .btn {
    margin-top: 0.5rem;
    font-size: 0.85rem;
    padding: 0.4rem 0.8rem;
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
}

/* Loading indicator */
.ai-message.loading {
    opacity: 0.6;
}

.ai-message.loading::after {
    content: '...';
    animation: loading-dots 1.5s infinite;
}

@keyframes loading-dots {

    0%,
    20% {
        content: '.';
    }

    40% {
        content: '..';
    }

    60%,
    100% {
        content: '...';
    }
}

/* Scrollbar for chat messages */
.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* Dark mode adjustments for AI chat */
body.dark-mode .ai-message.bot {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

body.dark-mode .ai-message a {
    color: #8b9cfc;
}

body.dark-mode .ai-chat-input input {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}


/* ================== Mobile Navbar Tweaks ================== */
@media (max-width: 1199.98px) {
    .navbar-nav {
        align-items: flex-start !important;
        width: 100%;
        padding-top: 1rem;
    }

    .nav-item {
        width: 100%;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    }

    .nav-item:last-child {
        border-bottom: none;
    }

    .nav-link {
        width: 100%;
        justify-content: flex-start !important;
        padding: 0.75rem 0 !important;
    }

    /* Ensure dropdowns also align left */
    .dropdown-menu {
        text-align: left;
        border: none;
        background: transparent;
        padding-left: 1.5rem;
    }

    .dropdown-item {
        color: rgba(255, 255, 255, 0.8) !important;
    }

    .dropdown-item:hover {
        background: transparent !important;
        color: white !important;
    }
}