/* style.css */

:root {
    --navbar-height: 52px;
    --filter-input-height: 48px;
    --table-header-height: 44px;
}

/* Reset default margins/padding */
body, html {
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
}

/* Navbar container */
#navbar {
    display: flex;               /* horizontal layout */
    align-items: center;         /* vertical centering */
    padding: 10px 20px;
    background-color: #f2f2f2;   /* light gray background */
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    width: 100%;                 /* stretch full width */
    box-sizing: border-box;
    position: fixed;             /* fixed to top */
    top: 0;
    z-index: 1000;               /* keep above other content */
}

/* Links and buttons in navbar */
#navbar a,
#navbar button {
    margin-right: 15px;
    padding: 10px 16px;
    border: 1px solid #ccc;
    background-color: #f2f2f2;  /* same as navbar */
    color: #333;
    text-decoration: none;
    cursor: pointer;
    font-size: 15px;
    transition: background-color 0.2s, color 0.2s, border-color 0.2s;
    border-radius: 4px;
}

/* Hover effect */
#navbar a:hover,
#navbar button:hover {
    background-color: #e0e0e0; /* slightly darker */
    color: #000;
    border-color: #bbb;
}

/* Active page highlight */
#navbar a.active {
    background-color: #d0d0d0;
    font-weight: bold;
    border-color: #bbb;
}

/* Remove outline on focus */
#navbar button:focus {
    outline: none;
}

/* Navbar user info */
#user-info-link {
    display: flex;
    align-items: center;
    gap: 8px;
}

.navbar-role-badge {
    background: #007bff;
    color: white !important;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

#user-info-link:hover .navbar-role-badge {
    background: #0056b3;
}

/* Push content below fixed navbar */
body {
    padding-top: var(--navbar-height);
}

img {
    max-width: 100%;
    /* never exceed the width of the container */
    height: auto;
    /* keep aspect ratio */
    display: block;
    /* remove tiny gaps under image */
}

/* Dropdown container */
.dropdown {
    position: relative;
}

/* Dropdown button (same look as links) */
.dropdown-toggle {
    background: inherit;
}

/* Dropdown menu */
.dropdown-menu {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background-color: #f2f2f2;
    min-width: 160px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    border-radius: 4px;
    padding: 5px 0;
    z-index: 1001;
}

/* Dropdown items */
.dropdown-menu a {
    display: block;
    padding: 8px 12px;
    margin: 0;
    white-space: nowrap;
}

/* Hover shows dropdown */
.dropdown:hover .dropdown-menu {
    display: block;
}

/* Hover effect on dropdown items */
.dropdown-menu a:hover {
    background-color: #e0e0e0;
}

/*------------------------CHAT--------------------------------*/
#chat-sidebar {
    position: fixed;
    top: 0;
    right: -400px;
    width: 400px;
    height: 100vh;
    background: #ffffff;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    z-index: 9999;
    display: flex;
    flex-direction: column;
}

#chat-sidebar.open {
    right: 0;
}

/* Header section with search - 30% height */
.chat-header {
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
    background: #f8f9fa;
    position: relative;
}

#chat-user-search {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

#chat-user-search:focus {
    outline: none;
    border-color: #007bff;
}

/* Custom dropdown styling */
.custom-select-wrapper {
    position: relative;
}

#chat-user-search-dropdown {
    display: none;
    border: 1px solid #ccc;
    max-height: 200px;
    overflow-y: auto;
    width: calc(100% - 30px);
    background: white;
    position: absolute;
    z-index: 10000;
    left: 15px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
}

#chat-user-search-dropdown div {
    padding: 8px 10px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    font-size: 14px;
}

#chat-user-search-dropdown div:hover {
    background-color: #f0f0f0;
}

/* Conversations list - fills remaining space */
#chat-conversations {
    flex: 1;
    overflow-y: auto;
    background: #ffffff;
}

/* Chat window container - fills remaining space */
#chat-window {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    background: #fafafa;
}

#chat-window.hidden {
    display: none;
}

/* Messages area - scrollable, takes up available space */
#chat-messages {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

/* Message bubbles */
.message-me,
.message-them {
    max-width: 70%;
    padding: 10px 14px;
    border-radius: 18px;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.4;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message-me {
    align-self: flex-end;
    background: #007bff;
    color: white;
    border-bottom-right-radius: 4px;
}

.message-them {
    align-self: flex-start;
    background: #e9ecef;
    color: #333;
    border-bottom-left-radius: 4px;
}

/* Chat input area - fixed at bottom */
.chat-input {
    display: flex;
    gap: 10px;
    padding: 15px;
    background: #ffffff;
    border-top: 1px solid #e0e0e0;
    box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.05);
}

#chat-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
    outline: none;
}

#chat-input:focus {
    border-color: #007bff;
}

#send-chat {
    padding: 10px 20px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: background-color 0.2s;
}

#send-chat:hover {
    background: #0056b3;
}

#send-chat:active {
    background: #004494;
}

/* Scrollbar styling */
#chat-conversations::-webkit-scrollbar,
#chat-messages::-webkit-scrollbar,
#chat-user-search-dropdown::-webkit-scrollbar {
    width: 8px;
}

#chat-conversations::-webkit-scrollbar-track,
#chat-messages::-webkit-scrollbar-track,
#chat-user-search-dropdown::-webkit-scrollbar-track {
    background: #f1f1f1;
}

#chat-conversations::-webkit-scrollbar-thumb,
#chat-messages::-webkit-scrollbar-thumb,
#chat-user-search-dropdown::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

#chat-conversations::-webkit-scrollbar-thumb:hover,
#chat-messages::-webkit-scrollbar-thumb:hover,
#chat-user-search-dropdown::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Unread badge on navbar chat button */
.unread-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #dc3545;
    color: white;
    font-size: 11px;
    font-weight: bold;
    min-width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    border-radius: 9px;
    padding: 0 4px;
    box-sizing: border-box;
}

/* Per-conversation unread dot */
.conversation-unread-badge {
    width: 10px;
    height: 10px;
    background: #dc3545;
    border-radius: 50%;
    flex-shrink: 0;
}

/* Conversation item layout */
.conversation-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s;
    font-size: 14px;
    color: #333;
}

.conversation-item:hover {
    background-color: #f5f5f5;
}

.conversation-item:active {
    background-color: #e8e8e8;
}

/* Chat window header with back button */
.chat-window-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 15px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
    font-size: 15px;
    font-weight: 600;
    color: #333;
}

.chat-window-header button {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    padding: 0 4px;
    color: #333;
}

.chat-window-header button:hover {
    color: #007bff;
}

/* Message wrappers for bubble + timestamp */
.message-wrapper-me,
.message-wrapper-them {
    display: flex;
    flex-direction: column;
    max-width: 70%;
}

.message-wrapper-me {
    align-self: flex-end;
    align-items: flex-end;
}

.message-wrapper-them {
    align-self: flex-start;
    align-items: flex-start;
}

/* Message timestamp */
.message-timestamp {
    font-size: 11px;
    color: #999;
    margin-top: 2px;
    padding: 0 4px;
}

/* Responsive design for smaller screens */
@media (max-width: 768px) {
    #chat-sidebar {
        right: -100%;
        width: 100%;
    }
    
    #chat-sidebar.open {
        right: 0;
    }
}
/*------------------------------------------------------------*/

/*------------------------DARK MODE---------------------------*/
html.dark-mode {
    color-scheme: dark;
    --dark-bg: #111827;
    --dark-surface: #1f2937;
    --dark-surface-2: #273449;
    --dark-surface-3: #172033;
    --dark-text: #e5e7eb;
    --dark-muted: #b7c0cc;
    --dark-border: #3d4a5f;
    --dark-border-strong: #64748b;
    --dark-hover: #334155;
    --dark-accent: #8b7cf6;
    --dark-warning: #f4c95d;
}

html.dark-mode body {
    background: var(--dark-bg) !important;
    color: var(--dark-text) !important;
}

html.dark-mode #navbar,
html.dark-mode #navbar a,
html.dark-mode #navbar button,
html.dark-mode .dropdown-menu {
    background-color: var(--dark-surface) !important;
    border-color: var(--dark-border) !important;
    color: var(--dark-text) !important;
}

html.dark-mode #navbar a:hover,
html.dark-mode #navbar button:hover,
html.dark-mode #navbar a.active,
html.dark-mode #dark-mode-toggle[aria-pressed="true"],
html.dark-mode .dropdown-menu a:hover {
    background-color: var(--dark-hover) !important;
    color: #ffffff !important;
}

html.dark-mode :is(
    .container,
    .main-container,
    .profile-container,
    .form-container,
    .section,
    .menu-card,
    .menu-button,
    .assignment-section,
    .alvallalkozok-section,
    .checkbox-group,
    .dropdown-list,
    .szakag-dropdown,
    .modal-content,
    .print-modal-dialog,
    .controls,
    .admin-data-tools,
    .report-panel,
    .report-controls,
    .reports-header,
    .tabs,
    .option-section,
    .option-list,
    .level,
    .home,
    .component,
    #settings-div,
    .match-group,
    .match-group-header,
    .match-source-item,
    .beszallito-selector,
    .summary-section,
    .step-tab,
    .file-input-wrapper,
    .signature-container,
    .unexpected-receipt-panel,
    .unexpected-receipt-pending-row,
    .unexpected-receipt-action-spacer,
    .chat-header,
    .chat-input,
    .chat-window-header,
    .group-card-header
) {
    background: var(--dark-surface) !important;
    border-color: var(--dark-border) !important;
    color: var(--dark-text) !important;
}

html.dark-mode :is(#chat-sidebar, #chat-conversations, #chat-window) {
    background: var(--dark-surface) !important;
    border-color: var(--dark-border) !important;
    color: var(--dark-text) !important;
}

html.dark-mode :is(
    h1,
    h2,
    h3,
    h4,
    h5,
    h6,
    label,
    .loading,
    .no-data,
    .empty-message,
    .hint,
    .password-hint,
    .description,
    .user-info,
    .info-text,
    .item-id-display,
    .projekt-id-display,
    .data-tool-title,
    .row-count,
    .bulk-status,
    .status-line,
    .empty-table,
    .level-header,
    .home-header,
    .group-card-meta,
    .group-card-id,
    .group-card-date,
    .group-card-supplier,
    .group-item-amount,
    .group-item-location,
    .group-item-supplier,
    .group-item-name,
    .card-info,
    .card-info strong,
    .card-info span,
    .permission-name,
    .user-name,
    .user-email,
    .match-group-header .anyag-name,
    .match-group-header .needed-qty,
    .no-match-msg,
    .row-status,
    .message-timestamp
) {
    color: var(--dark-text) !important;
}

html.dark-mode :is(input:not([type="button"]):not([type="submit"]):not([type="reset"]), select, textarea, .table-filter-input, .column-filter-input) {
    background: #111827 !important;
    border-color: var(--dark-border) !important;
    color: var(--dark-text) !important;
}

html.dark-mode :is(input[readonly], input:disabled, select:disabled, textarea:disabled) {
    background: #182233 !important;
    color: var(--dark-muted) !important;
}

html.dark-mode :is(table, .preview-table, .summary-table, .pricing-table) {
    background-color: var(--dark-surface) !important;
    color: var(--dark-text) !important;
    box-shadow: none !important;
}

html.dark-mode :is(.filterable-table th, .tab-button.active, .tab-button:hover) {
    background-color: #2f4f7f !important;
    border-color: #456899 !important;
    color: #ffffff !important;
}

html.dark-mode :is(.filterable-table td, .config-table td, .config-table th) {
    border-color: var(--dark-border) !important;
    color: var(--dark-text) !important;
}

html.dark-mode :is(.filterable-table td:hover, .filterable-table td.pk-cell:hover) {
    background: var(--dark-hover) !important;
}

html.dark-mode :is(.filterable-table td.pk-cell, .filterable-table td.protected-cell) {
    background: var(--dark-surface-2) !important;
}

html.dark-mode :is(td, th) {
    border-color: var(--dark-border) !important;
}

html.dark-mode :is(
    .menu-card,
    .form-section,
    .section,
    .user-section,
    .permission-category,
    .permission-item,
    .filter-section,
    .controls,
    .admin-data-tools,
    .report-panel,
    .report-controls,
    .option-section,
    .option-list,
    .level,
    .home,
    .component,
    #settings-div,
    .price-load-row,
    .tab-content,
    .summary-section,
    .match-group,
    .match-source-item,
    .incoming-group-card,
    .beszerzes-card,
    .unpriced-order-card,
    .modal-content,
    .print-modal-dialog
) {
    background: var(--dark-surface) !important;
    border: 1px solid var(--dark-border-strong) !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35) !important;
    color: var(--dark-text) !important;
}

html.dark-mode :is(.menu-card:hover, .beszerzes-card:hover, .unpriced-order-card:hover) {
    border-color: var(--dark-accent) !important;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.45) !important;
}

html.dark-mode .component.added {
    background-color: #173a2a !important;
    border-color: #1f8f5f !important;
}

html.dark-mode :is(.beszerzes-card, .unpriced-order-card) {
    border-left: 4px solid var(--dark-warning) !important;
}

html.dark-mode :is(.user-section, .permission-item, .filter-section, .price-load-row, .tab-btn, .tab-button, .step-tab, .summary-section h4, .total-row, #bevasarlo-td-ul > li) {
    background: var(--dark-surface-2) !important;
    border-color: var(--dark-border) !important;
    color: var(--dark-text) !important;
}

html.dark-mode :is(.permission-category, .tab-content, .match-source-item, .match-group-header, .group-card-header, .unpriced-order-header, .reports-header, .tabs) {
    background: var(--dark-surface-3) !important;
    border-color: var(--dark-border) !important;
    color: var(--dark-text) !important;
}

html.dark-mode :is(.tab-btn.active, .tab-button.active, .step-tab.active) {
    background: var(--dark-surface) !important;
    border-color: var(--dark-border-strong) !important;
    border-bottom-color: var(--dark-surface) !important;
    color: var(--dark-accent) !important;
}

html.dark-mode .step-tab.completed {
    background: #123524 !important;
    border-bottom-color: #1f8f5f !important;
    color: #b8f5d3 !important;
}

html.dark-mode :is(.modal-footer, .modal-overlay .modal-footer, .modal-overlay .modal-header, .step-indicator, .group-item-row, .unpriced-item-row) {
    border-color: var(--dark-border) !important;
}

html.dark-mode :is(tr:hover, .clickable-row:hover, .conversation-item:hover, .dropdown-list div:hover) {
    background-color: var(--dark-hover) !important;
}

html.dark-mode :is(.column-filter-row th, .batch-selection-table th, .preview-table th, .summary-table th, .pricing-table th) {
    background-color: var(--dark-surface-2) !important;
    color: var(--dark-text) !important;
}

html.dark-mode :is(.message-them, .unexpected-receipt-unit, .unexpected-receipt-package-unit, .group-item-location, .group-item-supplier, .group-item-tarolasi-raktar) {
    background: var(--dark-surface-2) !important;
    color: var(--dark-text) !important;
    border-color: var(--dark-border) !important;
}

html.dark-mode :is(.price-missing, .group-item-row.status-row-RENDELT, .group-item-row.status-row-SZALLITASBAN, .group-item-row.status-row-LEFOGLALVA, .group-item-row.status-row-HIANY, .group-item-row.hiany-row) {
    background-color: var(--dark-surface-2) !important;
    border: 1px solid var(--dark-border) !important;
    color: var(--dark-text) !important;
}

html.dark-mode :is(.success-message, .message.success, .status-msg.success, .unexpected-receipt-message.success, .info-box) {
    background: #123524 !important;
    border-color: #1f8f5f !important;
    color: #b8f5d3 !important;
}

html.dark-mode :is(.error-message, .message.error, .status-msg.error, .unexpected-receipt-message.error, .warning-box) {
    background: #3d1f1f !important;
    border-color: #a43b3b !important;
    color: #ffd0d0 !important;
}

html.dark-mode :is(.row-selected, .preview-table tr.saved-row) {
    background-color: #173a2a !important;
}

html.dark-mode :is(.batch-mode-active, .preview-table tr.duplicate-row) {
    background-color: #3a3016 !important;
    color: var(--dark-text) !important;
}

html.dark-mode :is(.preview-table tr.invalid-row, .preview-table tr.error-row) {
    background-color: #3b1e28 !important;
}

html.dark-mode [style*="background: white"],
html.dark-mode [style*="background:white"],
html.dark-mode [style*="background-color: white"],
html.dark-mode [style*="background-color:white"],
html.dark-mode [style*="background: #f8f9fa"],
html.dark-mode [style*="background:#f8f9fa"],
html.dark-mode [style*="background: #f9f9f9"],
html.dark-mode [style*="background:#f9f9f9"],
html.dark-mode [style*="background:#f0f4ff"],
html.dark-mode [style*="background: #f0f4ff"] {
    background: var(--dark-surface) !important;
}

html.dark-mode [style*="color:#333"],
html.dark-mode [style*="color: #333"],
html.dark-mode [style*="color:#555"],
html.dark-mode [style*="color: #555"],
html.dark-mode [style*="color:#666"],
html.dark-mode [style*="color: #666"],
html.dark-mode [style*="color:#636e72"],
html.dark-mode [style*="color: #636e72"],
html.dark-mode [style*="color:#888"],
html.dark-mode [style*="color: #888"],
html.dark-mode [style*="color:#999"],
html.dark-mode [style*="color: #999"] {
    color: var(--dark-muted) !important;
}

html.dark-mode [style*="border:1px solid #ddd"],
html.dark-mode [style*="border: 1px solid #ddd"],
html.dark-mode [style*="border:1px solid #ccc"],
html.dark-mode [style*="border: 1px solid #ccc"],
html.dark-mode [style*="border:1px solid #d0d8ff"],
html.dark-mode [style*="border: 1px solid #d0d8ff"] {
    border-color: var(--dark-border) !important;
}
/*------------------------------------------------------------*/
