/* sidebar.css - sidebar, chat-history, resize-handle */

.sidebar {
    width: 20vw;
    min-width: 350px;
    max-width: 450px;
    padding: 10px 0;
    background: #0d0d0d;
    border-right: 1px solid #333;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    transition: width 0.2s ease;
    resize: horizontal;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
}

.sidebar.closed {
    width: 0 !important;
    min-width: 0 !important;
    max-width: 0 !important;
    margin-left: 0;
    border-right: none;
    overflow: hidden;
}

.sidebar-resize-handle {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 8px;
    cursor: ew-resize;
    background: transparent;
    z-index: 1000;
    transition: background 0.2s;
}

.sidebar-resize-handle:hover {
    background: linear-gradient(to right, transparent, #4CAF50);
}

.sidebar-resize-handle::after {
    content: '';
    position: absolute;
    right: 2px;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 40px;
    background: #4CAF50;
    border-radius: 2px;
    opacity: 0;
    transition: opacity 0.2s;
}

.sidebar-resize-handle:hover::after {
    opacity: 0.5;
}

body.resizing-sidebar {
    cursor: ew-resize !important;
    user-select: none;
}

body.resizing-sidebar * {
    cursor: ew-resize !important;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #333;
    background: linear-gradient(135deg, #1a1a1a 0%, #252525 100%);
    flex-wrap: nowrap;
}

.sidebar-header h2 {
    color: #4CAF50;
    font-size: 18px;
    margin-bottom: 5px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.freeze-badge {
    display: inline-block;
    background: #f44336;
    color: white;
    padding: 3px 8px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
}

/* User Info */
.user-info {
    margin-top: 10px;
    padding: 10px;
    background: #252525;
    border-radius: 4px;
    border-left: 3px solid #4CAF50;
}

.user-info.guest {
    border-left-color: #FF9800;
}

.user-name {
    font-size: 13px;
    font-weight: 600;
    color: #e0e0e0;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.user-role {
    font-size: 11px;
    color: #888;
    text-transform: uppercase;
}

.user-role-badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
}

.user-role-badge.operator {
    background: #4CAF50;
    color: white;
}

.user-role-badge.observer {
    background: #2196F3;
    color: white;
}

.user-role-badge.auditor {
    background: #FF9800;
    color: white;
}

.user-role-badge.guest {
    background: #666;
    color: white;
}

.login-btn {
    margin-top: 8px;
    width: 100%;
    padding: 8px;
    background: #4CAF50;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s;
}

.login-btn:hover {
    background: #45a049;
    transform: translateY(-1px);
}

.logout-btn {
    margin-top: 8px;
    width: 100%;
    padding: 6px;
    background: #555;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.logout-btn:hover {
    background: #666;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    flex-wrap: nowrap;
}

.memory-section {
    margin-bottom: 20px;
}

.memory-section h3 {
    color: #888;
    font-size: 12px;
    text-transform: uppercase;
    margin-bottom: 10px;
    padding-bottom: 5px;
    border-bottom: 1px solid #333;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Chat History (in sidebar) - využíva celý voľný výškový priestor */
.chat-history-section {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    flex-wrap: nowrap;
    background: #0d0d0d;
    position: relative;
}

.chat-history-section > .chat-history-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 8px 12px;
    padding-bottom: 10px;
    -webkit-overflow-scrolling: touch;
}

.chat-history-section > .chat-history-content::-webkit-scrollbar {
    width: 8px;
}

.chat-history-section > .chat-history-content::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

.chat-history-section > .chat-history-content::-webkit-scrollbar-thumb:hover {
    background: #555;
}

#chatHistoryList {
    margin-top: 6px;
}

.chat-history-resize-handle {
    height: 20px;
    background: linear-gradient(to bottom, #0d0d0d 0%, #1a1a1a 50%, #0d0d0d 100%);
    cursor: ns-resize !important;
    position: relative;
    border-top: 2px solid #333;
    border-bottom: 2px solid #333;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin: 0;
}

.chat-history-resize-handle:hover {
    background: linear-gradient(to bottom, #1a1a1a 0%, #252525 50%, #1a1a1a 100%);
    border-top-color: #4CAF50;
    border-bottom-color: #4CAF50;
}

.chat-history-resize-handle::before {
    content: '';
    width: 50px;
    height: 4px;
    background: #4CAF50;
    border-radius: 2px;
    opacity: 0.3;
    box-shadow: 0 0 8px rgba(76, 175, 80, 0.3);
}

.chat-history-resize-handle:hover::before {
    opacity: 0.8;
    box-shadow: 0 0 12px rgba(76, 175, 80, 0.6);
}

.chat-history-resize-handle:active::before {
    opacity: 1;
    background: #66BB6A;
}

.chat-history-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    gap: 10px;
    min-width: 0;
}

.chat-history-header h3 {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-history-header h3:hover {
    color: #45a049 !important;
    text-decoration: underline;
}

.chat-history-item {
    padding: 10px 4px 10px 8px;
    margin: 4px 0;
    background: #1a1a1a;
    border-radius: 4px;
    border-left: 3px solid #333;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    overflow: hidden;
    position: relative;
    min-width: 0;
    cursor: pointer;
}

.chat-history-item:hover {
    background: #252525;
    border-left-color: #4CAF50;
}

.chat-history-item.active {
    background: #252525;
    border-left-color: #4CAF50;
}

.chat-history-content,
.chat-history-item > div:first-of-type {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    margin-right: 2px;
}

.chat-history-title {
    color: #e0e0e0;
    font-size: 13px;
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    display: block;
}

.chat-history-time {
    color: #666;
    font-size: 10px;
    opacity: 0.7;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    display: block;
}

.chat-history-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    gap: 8px;
    min-width: 0;
}

.chat-history-date {
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    min-width: 0;
}

.chat-history-count {
    background: #333;
    padding: 2px 6px;
    border-radius: 3px;
    color: #888;
    flex-shrink: 0;
}

.chat-history-actions {
    display: flex;
    flex-shrink: 0;
    gap: 2px;
}

.chat-history-item-menu-wrap {
    display: none;
    width: 100%;
    box-sizing: border-box;
}

.phase-link {
    display: block;
    padding: 8px 10px;
    margin-bottom: 5px;
    background: #252525;
    border-radius: 4px;
    border-left: 3px solid #4CAF50;
    color: #e0e0e0;
    text-decoration: none;
    font-size: 12px;
    transition: all 0.2s;
}

.phase-link:hover {
    background: #333;
    border-left-color: #45a049;
    transform: translateX(5px);
}

.phase-link .phase-num {
    color: #4CAF50;
    font-weight: bold;
    margin-right: 5px;
}

.phase-link .phase-name {
    color: #e0e0e0;
}

/* Projects – rozbalovacie menu */
.projects-section {
    padding: 8px 12px 0 12px;
    border-bottom: 1px solid #222;
    margin-bottom: 4px;
}

.projects-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 2px 0 6px 0;
    cursor: pointer;
    color: #fff;
    font-size: 14px;
  /*   text-transform: uppercase;
    letter-spacing: 1px;*/
    user-select: none;
    outline: none;
}

.projects-toggle:hover,
.projects-section:not(.collapsed) .projects-toggle {
    color: #4CAF50;
}

.projects-toggle:focus-visible {
    outline: 1px solid #4CAF50;
    outline-offset: 2px;
}

.projects-toggle-chevron {
    flex-shrink: 0;
    font-size: 8px;
    color: #888;
    transition: transform 0.2s;
}

.projects-section.collapsed .projects-toggle-chevron {
    transform: rotate(-90deg);
}

.projects-toggle-label {
    flex: 1;
    min-width: 0;
}

.projects-toggle-new {
    background: none;
    border: none;
    color: #4CAF50;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    padding: 0 2px;
    flex-shrink: 0;
}

.projects-toggle-new:hover {
    color: #66BB6A;
}

.projects-list-wrap {
    max-height: 160px;
    overflow-y: auto;
    transition: max-height 0.2s ease-out, opacity 0.2s;
}

.projects-section.collapsed .projects-list-wrap {
    max-height: 0;
    overflow: hidden;
    opacity: 0;
}

.projects-list {
    min-height: 0;
}

.sidebar-menu {
    padding: 10px 0;
    border-bottom: 1px solid #333;
    overflow-y: auto;
    flex-shrink: 0;
    max-height: 40vh;
    flex-wrap: nowrap;
}

.menu-item {
    display: grid;
    grid-template-columns: 30px minmax(0, 1fr);
    align-items: center;
    width: 100%;
    height: 40px;
    padding: 0;
    margin: 5px 0;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
    overflow: hidden;
}

.menu-item>span:first-child {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    width: 30px !important;
    height: 100%;
    flex-shrink: 0;
    font-size: 1.1rem;
    padding-left: 10px;
}

.menu-item>span:first-child img,
.menu-item>span:first-child svg {
    width: 20px;
    height: 20px;
    object-fit: contain;
}

.menu-item>span:nth-child(2) {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin: 0;
    padding: 0 0 0 5px;
    font-size: 0.9rem;
    min-width: 0;
}

.menu-item:hover {
    background-color: #333;
}

.menu-item.active {
    background-color: #4CAF50;
    color: #1a1a1a;
    margin: 8px 10px 8px;
}

/* Chat – pri aktívnom stave len farba textu na zelenú, pozadie bez zmeny */
.menu-item[data-view="chat"].active {
    background-color: transparent;
    color: #4CAF50;
}
.menu-item[data-view="chat"].active > span:nth-child(2) {
    color: #4CAF50;
}

#dynamic-modules-nav {
    display: block;
}

#dynamic-modules-nav .menu-item:hover {
    background-color: #333;
}

#dynamic-modules-nav .menu-item.active {
    background-color: #4CAF50;
    color: #1a1a1a;
}

.sidebar-bottom-block .menu-item {
    margin-top: 0;
    margin-bottom: 0;
    overflow: visible;
    grid-template-columns: 30px minmax(4em, 1fr);
    color: #e0e0e0;
}

.sidebar-bottom-block .menu-item > span:nth-child(2) {
    overflow: visible;
    min-width: 4em;
    display: block;
    visibility: visible;
    color: inherit;
}

/* Nastavenia/Settings – názov vždy viditeľný (ikona + text) */
#sidebarSettingsBtn,
#sidebarSettingsBtn > span:nth-child(2) {
    overflow: visible !important;
}
#sidebarSettingsBtn {
    grid-template-columns: 30px 1fr;
}
#sidebarSettingsBtn > span:nth-child(2) {
    min-width: 0;
    white-space: nowrap;
    text-overflow: clip;
    color: #e0e0e0;
}
#sidebarSettingsBtn.active > span:nth-child(2) {
    color: #4CAF50;
}

.sidebar-bottom-block .menu-item + .menu-item {
    margin-top: 0;
}

.models-menu-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    min-height: 40px;
    position: relative;
}

.models-menu-wrap .models-menu-trigger {
    margin-left: auto;
}

.models-mini-menu {
    display: none;
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    min-width: 0;
    transform: translateY(-100%);
    margin-top: -4px;
    padding: 4px 0;
    background: #1a1a1a;
    border: 1px solid #333;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
    z-index: 10001;
}

#models-menu-items {
    width: 100%;
    box-sizing: border-box;
}

.models-mini-menu.is-open {
    display: block;
}

.models-mini-menu-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 6px 12px;
    background: none;
    border: none;
    color: #e0e0e0;
    font-size: 12px;
    text-align: left;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.models-mini-menu-btn:hover {
    background: #252525;
    color: #4CAF50;
}

.auth-required-hidden {
    display: none !important;
}

.module-view-placeholder {
    background: rgba(26, 26, 26, 0.4);
    border-radius: 8px;
    margin: 20px;
}

.menu-expandable {
    position: relative;
    grid-template-columns: 30px 1fr 40px;
}

.menu-expandable .expand-icon {
    justify-self: end;
    font-size: 10px;
    transition: transform 0.3s;
}

.expand-icon.expanded {
    transform: rotate(-180deg);
}

.submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    background: #0a0a0a;
    flex-wrap: nowrap;
}

.submenu.expanded {
    max-height: 600px;
    overflow: visible;
}

.submenu-item {
    display: grid;
    grid-template-columns: 30px 1fr;
    padding-left: 20px;
    font-size: 0.85rem;
    border-left: 3px solid transparent;
    flex-wrap: nowrap;
}

.submenu-item:hover {
    background: #1a1a1a;
    border-left-color: #4CAF50;
}

.phase-tracker-toggle-btn {
    width: 100%;
    box-sizing: border-box;
}

.memory-item {
    background: #252525;
    padding: 10px;
    border-radius: 4px;
    margin-bottom: 8px;
    font-size: 12px;
    border-left: 3px solid #4CAF50;
}

.memory-item .label {
    color: #888;
    font-size: 10px;
}

.memory-item .value {
    color: #e0e0e0;
    font-weight: 600;
}
