/* ========================================
   Login Overlay Styles
   ======================================== */

/* Login overlay animation */
#login-overlay {
    animation: fadeIn 0.3s ease-out;
}

/* Shake animation for login errors */
@keyframes shake {
    0%, 100% {
        transform: translateX(0);
    }
    10%, 30%, 50%, 70%, 90% {
        transform: translateX(-10px);
    }
    20%, 40%, 60%, 80% {
        transform: translateX(10px);
    }
}

/* Login form input focus effects */
#login-form input:focus {
    box-shadow: 0 0 0 3px rgba(162, 24, 255, 0.1);
}

/* Login button loading state */
#login-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
}

/* ========================================
   Custom Styles for Sidebar Component
   ======================================== */

/* Sidebar transition for collapse/expand */
.sidebar {
    transition: width 0.3s ease-in-out;
    overflow: hidden;
}

/* Hide text labels when sidebar is collapsed */
.sidebar.collapsed .nav-label {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
}

/* Show text labels when sidebar is expanded */
.sidebar:not(.collapsed) .nav-label {
    opacity: 1;
    transition: opacity 0.2s ease-in-out 0.1s;
}

/* Tooltip styles for collapsed state */
.nav-item {
    position: relative;
}

.nav-item .tooltip {
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 12px;
    padding: 6px 12px;
    background-color: #ffffff;
    color: #1f2937;
    font-size: 14px;
    font-weight: 500;
    border-radius: 6px;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out;
    z-index: 100;
    box-shadow: 0 4px 12px -1px rgba(0, 0, 0, 0.15);
    border: 1px solid #e5e7eb;
}

.nav-item .tooltip::before {
    content: '';
    position: absolute;
    left: -6px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: transparent #ffffff transparent transparent;
}

/* Show tooltip only when sidebar is collapsed */
.sidebar.collapsed .nav-item:hover .tooltip {
    opacity: 1;
    visibility: visible;
}

/* Toggle button rotation */
.toggle-btn svg {
    transition: transform 0.3s ease-in-out;
}

.sidebar.collapsed .toggle-btn svg {
    transform: rotate(180deg);
}

/* Mobile overlay backdrop */
.sidebar-overlay {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* Mobile sidebar slide-in */
@media (max-width: 1023px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }
}

/* Active nav item indicator */
.nav-item.active {
    position: relative;
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 24px;
    background-color: #a218ff;
    border-radius: 0 3px 3px 0;
}

/* Smooth icon transition */
.nav-item i {
    transition: transform 0.2s ease-in-out;
}

.nav-item:hover i {
    transform: scale(1.1);
}

/* Main content transition for sidebar collapse */
.main-content {
    transition: margin-left 0.3s ease-in-out;
}

/* Hide scrollbar completely */
.sidebar::-webkit-scrollbar {
    display: none;
}

.sidebar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* Hide logo completely when sidebar is collapsed */
.sidebar.collapsed .logo-image {
    display: none;
}

.sidebar.collapsed .logo-text {
    display: none;
}

/* Hide entire logo container when collapsed */
.sidebar.collapsed .logo-container {
    display: none;
}

/* Center the header when collapsed (toggle button only) */
.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 0;
}

/* Ensure no overflow causes scrollbars */
.sidebar,
.sidebar * {
    overflow-x: hidden;
}

/* Remove any potential horizontal scroll */
body {
    overflow-x: hidden;
}

/* Hide any scrollbar that might appear in nav */
nav::-webkit-scrollbar {
    display: none;
}

nav {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

/* ========================================
   Modules Dropdown Styles
   ======================================== */

/* Dropdown arrow transition */
.dropdown-arrow {
    transition: transform 0.2s ease-in-out;
}

/* Hide submenu when sidebar is collapsed */
.sidebar.collapsed .modules-submenu,
.sidebar.collapsed .threads-submenu {
    display: none;
}

/* Submenu animation */
.modules-submenu,
.threads-submenu {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.25s ease-out, opacity 0.2s ease-out;
}

.modules-submenu.open,
.threads-submenu.open {
    max-height: 500px;
    opacity: 1;
    transition: max-height 0.3s ease-in, opacity 0.2s ease-in;
}

/* ========================================
   Page Content Styles
   ======================================== */

/* Page transitions */
.page-content {
    animation: fadeIn 0.2s ease-out;
}

.page-content.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* ========================================
   Threads Page Styles
   ======================================== */

/* Threads page full height with fixed height for flex layout */
#page-threads {
    height: calc(100vh - 64px);
    overflow: hidden;
}

@media (min-width: 1024px) {
    #page-threads {
        height: 100vh;
    }
}

#page-threads > div {
    height: 100%;
    overflow: hidden;
}

/* Ensure new thread section takes full height */
#new-thread-section {
    height: 100%;
    max-height: 100%;
    overflow: hidden;
}

/* Ensure conversation area can scroll */
#conversation-area {
    overflow-y: auto;
    height: 100%;
}

/* Custom gray-750 color for hover */
.hover\:bg-gray-750:hover {
    background-color: rgb(55, 55, 60);
}

/* Chat card hover effect */
.chat-card {
    transform: translateY(0);
    transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

.chat-card:hover {
    transform: translateY(-2px);
}

/* Delete button transition */
.delete-thread-btn {
    transition: opacity 0.15s ease, color 0.15s ease, background-color 0.15s ease;
}

/* Thread input textarea auto-resize support */
#thread-input {
    min-height: 24px;
    max-height: 200px;
}

/* Model dropdown animation */
#model-dropdown {
    transform-origin: bottom left;
    animation: dropdownFadeIn 0.15s ease-out;
}

#model-dropdown.hidden {
    display: none;
}

@keyframes dropdownFadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Attachment preview styles */
.attachment-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background-color: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 14px;
    color: #374151;
}

.attachment-item .remove-attachment {
    cursor: pointer;
    color: #9ca3af;
    transition: color 0.2s;
}

.attachment-item .remove-attachment:hover {
    color: #ef4444;
}

/* Custom scrollbar for threads chat history */
#page-threads .overflow-y-auto::-webkit-scrollbar {
    width: 6px;
}

#page-threads .overflow-y-auto::-webkit-scrollbar-track {
    background: transparent;
}

#page-threads .overflow-y-auto::-webkit-scrollbar-thumb {
    background-color: #d1d5db;
    border-radius: 3px;
}

#page-threads .overflow-y-auto::-webkit-scrollbar-thumb:hover {
    background-color: #9ca3af;
}

/* Send button pulse animation when input has content */
#send-btn.has-content {
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(162, 24, 255, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(162, 24, 255, 0);
    }
}

/* ========================================
   Command Center Page Styles
   ======================================== */

/* Metric card hover effect */
.metric-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
    transform: translateY(-2px);
}

/* Horizon item hover effect */
.horizon-item {
    transition: background-color 0.2s ease;
}

/* Alert card hover effect */
.alert-card {
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.alert-card:hover {
    transform: translateY(-1px);
}

/* Alert filter buttons */
.alert-filter-btn {
    background-color: #f3f4f6;
    color: #6b7280;
}

.alert-filter-btn:hover {
    background-color: #e5e7eb;
    color: #374151;
}

.alert-filter-btn.active {
    background-color: #6366f1;
    color: #ffffff;
}

.alert-filter-btn.active:hover {
    background-color: #4f46e5;
}

/* ========================================
   Data Sources Page Styles
   ======================================== */

/* Data source card hover effect */
.datasource-card {
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.datasource-card:hover {
    transform: translateY(-2px);
}

/* Connect button transition */
.connect-btn {
    transition: all 0.2s ease;
}

/* Filter buttons */
.datasource-filter-btn {
    background-color: #f3f4f6;
    color: #6b7280;
}

.datasource-filter-btn:hover {
    background-color: #e5e7eb;
    color: #374151;
}

.datasource-filter-btn.active {
    background-color: #a218ff;
    color: #ffffff;
}

.datasource-filter-btn.active:hover {
    background-color: #8b15d6;
}

/* ========================================
   Suggestion Cards Styles
   ======================================== */

/* Suggestion card hover effect */
.suggestion-card {
    transition: transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

.suggestion-card:hover {
    transform: translateY(-2px);
}

/* Line clamp utility */
.line-clamp-4 {
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ========================================
   Thread Section Styles
   ======================================== */

/* Section transitions */
#new-thread-section,
#previous-threads-section {
    animation: sectionFadeIn 0.2s ease-out;
}

#new-thread-section.hidden,
#previous-threads-section.hidden {
    display: none;
}

@keyframes sectionFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Message fade-in animation */
.message-fade-in {
    animation: messageFadeIn 0.5s ease-out;
}

@keyframes messageFadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* AI Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background-color: #9ca3af;
    border-radius: 50%;
    animation: typingDot 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* ========================================
   World Model Page Styles
   ======================================== */

/* Tab transitions */
.world-model-tab {
    transition: color 0.2s ease;
}

/* Section transitions */
#company-structure-section,
#data-sources-section,
#knowledge-section {
    animation: fadeIn 0.2s ease-out;
}

/* Organization chart styles */
#wm-org-chart {
    min-height: 200px;
}

/* Progress bar transitions */
#wm-goals-container .bg-yellow-400 {
    transition: width 0.3s ease-in-out;
}

/* Knowledge category tab styles */
.knowledge-category-tab {
    transition: color 0.2s ease, border-color 0.2s ease;
}

.knowledge-category-tab:hover {
    color: #374151;
}

/* Table hover effects */
#wm-knowledge-table-body tr {
    transition: background-color 0.15s ease;
}

/* Card hover effects for World Model */
#wm-uploaded-files .bg-white,
#wm-connected-sources .bg-white {
    transition: box-shadow 0.2s ease, transform 0.2s ease;
}

#wm-uploaded-files .bg-white:hover,
#wm-connected-sources .bg-white:hover {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* Strategic priorities and goals card hover */
#wm-priorities-container .bg-white,
#wm-goals-container .bg-white {
    transition: box-shadow 0.2s ease;
}

/* Toast Notification Styles */
#toast-container {
    pointer-events: none;
}

#toast-container > div {
    pointer-events: auto;
    animation: slideInRight 0.3s ease-out;
}

@keyframes slideInRight {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* ========================================
   Module Detail Page Styles
   ======================================== */

/* Custom select dropdown styling */
select {
    background-image: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

select::-ms-expand {
    display: none;
}

/* Ensure select dropdowns are clickable */
select option {
    padding: 8px 12px;
    background-color: #ffffff;
    color: #111827;
}

select option:hover {
    background-color: #f3f4f6;
}

/* Module config section transitions */
#module-config {
    transition: opacity 0.2s ease, max-height 0.3s ease;
}

/* Checkbox styling for multiselect */
input[type="checkbox"]:checked {
    background-color: #a218ff;
    border-color: #a218ff;
}

input[type="checkbox"]:focus {
    ring-color: #a218ff;
    border-color: #a218ff;
}

/* ========================================
   THREADS 3-COLUMN LAYOUT
   ======================================== */

.threads-layout-container {
    display: flex;
    height: 100%;
    width: 100%;
    overflow: hidden;
}

/* Left Column: Outline Panel */
.outline-panel-column {
    width: 0;
    min-width: 0;
    background: #fafafa;
    border-right: 1px solid #e5e7eb;
    overflow: hidden;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.outline-panel-column.open {
    width: 320px;
    min-width: 320px;
}

.outline-panel-content {
    width: 320px;
    padding: 20px;
    height: 100%;
    overflow-y: auto;
}

/* Center Column: Main Content */
.threads-main-column {
    flex: 1;
    min-width: 0;
    height: 100%;
    overflow-y: auto;
    background: #f9fafb;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Right Column: Dive Deeper Panel */
.dive-deeper-panel-column {
    width: 0;
    min-width: 0;
    background: #fafafa;
    border-left: 1px solid #e5e7eb;
    overflow: hidden;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    flex-shrink: 0;
}

.dive-deeper-panel-column.open {
    width: 400px;
    min-width: 400px;
}

.dive-deeper-panel-content {
    width: 400px;
    padding: 24px;
    height: 100%;
    overflow-y: auto;
}

/* Close buttons for both panels */
#outline-close,
#dive-deeper-close {
    padding: 4px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #9ca3af;
    cursor: pointer;
    transition: all 0.2s ease;
}

#outline-close:hover,
#dive-deeper-close:hover {
    background: #f3f4f6;
    color: #111827;
}

/* ========================================
   INLINE ANALYSIS CARD STYLES
   ======================================== */

/* Main analysis card container */
.inline-analysis {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 24px;
    margin-top: 16px;
    box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
}

/* Analysis header with title and buttons */
.analysis-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid #f3f4f6;
}

.analysis-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #111827;
}

.analysis-header-buttons {
    display: flex;
    gap: 8px;
}

.analysis-header-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: white;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.875rem;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
}

.analysis-header-btn:hover {
    background: #f9fafb;
    border-color: #f97316;
    color: #f97316;
}

.analysis-header-btn.active {
    background: #fff7ed;
    border-color: #f97316;
    color: #f97316;
}

/* Analysis content area */
.analysis-content {
    font-size: 0.875rem;
    line-height: 1.6;
    color: #374151;
}

/* Analysis sections */
.analysis-section {
    margin-bottom: 24px;
}

.analysis-section h4 {
    font-size: 1rem;
    font-weight: 600;
    color: #111827;
    margin-bottom: 12px;
}

.analysis-section p {
    margin-bottom: 12px;
    color: #4b5563;
}

.analysis-section ul {
    list-style: disc;
    padding-left: 24px;
    margin-bottom: 12px;
}

.analysis-section ul li {
    margin-bottom: 8px;
    color: #4b5563;
}

/* Citations - clickable purple text */
.citation {
    color: #A218FF;
    font-weight: 500;
    cursor: pointer;
    text-decoration: underline;
    text-decoration-style: dotted;
    text-underline-offset: 2px;
    transition: color 0.2s;
}

.citation:hover {
    color: #8b14d9;
    text-decoration-style: solid;
}

/* Collapsible sections */
.analysis-collapsible {
    margin-top: 16px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    overflow: hidden;
}

.analysis-collapsible summary {
    padding: 12px 16px;
    background: #f9fafb;
    cursor: pointer;
    font-weight: 500;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.analysis-collapsible summary:hover {
    background: #f3f4f6;
}

.analysis-collapsible summary::marker {
    content: '▸ ';
}

.analysis-collapsible[open] summary::marker {
    content: '▾ ';
}

.analysis-collapsible-content {
    padding: 16px;
    background: white;
}

/* Loading animation for analysis */
.inline-analysis-loading {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Outline navigation items */
.outline-nav-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    width: 100%;
    text-align: left;
    background: transparent;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    color: #374151;
    cursor: pointer;
    transition: all 0.2s;
}

.outline-nav-item:hover {
    background: #f3e8ff;
    color: #7c3aed;
}

.outline-nav-item.active {
    background: #f3e8ff;
    color: #A218FF;
    font-weight: 500;
    border-left: 3px solid #A218FF;
}

.outline-nav-item.nested {
    padding-left: 28px;
    font-size: 0.8125rem;
}

/* Calculation step styling */
.calculation-step {
    margin-bottom: 16px;
    padding: 12px;
    background: #f9fafb;
    border-radius: 8px;
    border-left: 3px solid #A218FF;
}

.calculation-step-header {
    display: flex;
    gap: 12px;
}

.calculation-step-number {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    background: #A218FF;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

.calculation-step-content {
    flex: 1;
}

.calculation-step-text {
    font-size: 0.875rem;
    color: #374151;
    margin-bottom: 8px;
}

.calculation-step-formula {
    font-family: 'Courier New', monospace;
    font-size: 0.8125rem;
    color: #6b7280;
    background: white;
    padding: 8px;
    border-radius: 4px;
    border: 1px solid #e5e7eb;
}

/* Data source item */
.data-source-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: #f9fafb;
    border-radius: 6px;
    margin-bottom: 8px;
}

.data-source-name {
    font-size: 0.875rem;
    color: #374151;
}
