:root {
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --sidebar-bg: #1e293b;
    --sidebar-hover: #334155;
    --bg-light: #f1f5f9;
    --text-dark: #334155;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    height: 100vh;
    overflow-x: hidden;
}

/* Sidebar Styling */
.wrapper {
    display: flex;
    width: 100%;
    align-items: stretch;
    min-height: 100vh;
}

#sidebar {
    min-width: 250px;
    max-width: 250px;
    background: var(--sidebar-bg);
    color: #fff;
    transition: all 0.3s;
    display: flex;
    flex-direction: column;
    position: fixed; /* FIXED POSITION */
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1000;
    overflow-y: auto; /* Allow scrolling inside sidebar if needed */
}

#sidebar .sidebar-header {
    background: rgba(0,0,0,0.1);
}

#sidebar ul.components {
    padding: 20px 0;
}

#sidebar ul li a {
    padding: 10px;
    font-size: 0.95em;
    display: block;
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    transition: all 0.2s;
}

#sidebar ul li a:hover {
    color: #fff;
    background: var(--sidebar-hover);
    padding-left: 20px;
}

#sidebar ul li a.active {
    color: #fff;
    background: var(--primary-color);
}

#sidebar ul li a i {
    text-align: center;
}

#content {
    width: 100%;
    min-height: 100vh;
    transition: all 0.3s;
    margin-left: 250px; /* OFFSET CONTENT */
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    #sidebar {
        margin-left: -250px;
    }
    #sidebar.active {
        margin-left: 0;
    }
    #content {
        margin-left: 0;
    }
}

/* Utility Classes */
.bg-dark-blue {
    background-color: var(--secondary-color) !important;
}

.text-primary {
    color: var(--primary-color) !important;
}

.card {
    border: none;
    box-shadow: 0 1px 3px 0 rgba(0,0,0,0.1), 0 1px 2px 0 rgba(0,0,0,0.06);
    transition: all 0.2s;
}

.card:hover {
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.btn-primary:hover {
    background-color: #2980b9;
    border-color: #2980b9;
}

/* Highlighted Search Terms */
mark {
    background-color: #fff3cd;
    color: #856404;
    padding: 0.1em 0.3em;
    border-radius: 0.2em;
    font-weight: bold;
}

.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.8);
    z-index: 9999;
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
}

/* Chat Sidebar Styles */
#chat-sidebar {
    position: fixed;
    top: 0;
    right: -350px;
    width: 350px;
    height: 100vh;
    transition: right 0.3s ease-in-out;
    z-index: 1050;
    display: flex;
    flex-direction: column;
}

#chat-sidebar.active {
    right: 0;
}

#chatToggleBtn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    z-index: 1040;
    transition: transform 0.2s;
}

#chatToggleBtn:hover {
    transform: scale(1.1);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    background-color: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.chat-bubble {
    max-width: 85%;
    padding: 10px 15px;
    border-radius: 15px;
    font-size: 0.9rem;
    line-height: 1.4;
    position: relative;
}

.chat-bubble.user {
    background-color: var(--primary-color);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 2px;
}

.chat-bubble.ai {
    background-color: white;
    color: var(--text-dark);
    align-self: flex-start;
    border-bottom-left-radius: 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.typing-indicator span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: #ccc;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
    margin: 0 2px;
}

.typing-indicator span:nth-child(1) { animation-delay: -0.32s; }
.typing-indicator span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Calculator Sidebar & Print */
.calc-sidebar .nav-link {
    color: var(--text-dark);
    border-radius: 0.5rem;
    margin-bottom: 0.5rem;
    text-align: left;
    padding: 0.75rem 1rem;
}

.calc-sidebar .nav-link:hover {
    background-color: #e2e8f0;
}

.calc-sidebar .nav-link.active {
    background-color: var(--primary-color);
    color: white;
}

.calc-sidebar .nav-link i {
    width: 24px;
    text-align: center;
    margin-right: 0.5rem;
}

@media print {
    body * {
        visibility: hidden;
    }
    #wrapper, #sidebar, #chatToggleBtn, #chat-sidebar {
        display: none !important;
    }
    .calc-print-area, .calc-print-area * {
        visibility: visible;
    }
    .calc-print-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
    }
    .no-print {
        display: none !important;
    }
}

/* Timeline Styling */
.timeline-vertical {
    position: relative;
    padding-left: 15px;
}

.timeline-vertical::before {
    content: '';
    position: absolute;
    left: 5px;
    top: 0;
    bottom: 0;
    width: 2px;
    background: #e9ecef;
}

.timeline-item {
    position: relative;
    margin-bottom: 1.5rem;
}

.timeline-marker {
    position: absolute;
    left: -14px;
    top: 5px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    z-index: 1;
}

.timeline-content {
    position: relative;
    padding-bottom: 1.5rem;
    border-bottom: 1px dashed #e9ecef;
}

.timeline-item:last-child .timeline-content {
    border-bottom: none;
    padding-bottom: 0;
}
