:root {
    /* Color Palette */
    --primary: #0F5B99;
    --primary-light: #E7F0F8;
    --primary-dark: #0A3D66;
    --background: #F8F9FA;
    --surface: #FFFFFF;
    --text-primary: #1A1A1A;
    --text-secondary: #666666;
    --border: #E5E7EB;
    
    /* Typography */
    --font-family: 'Plus Jakarta Sans', sans-serif;
    
    /* Spacing & Sizing */
    --sidebar-width: 280px;
    --topbar-height: 72px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px; /* rounded-2xl */
    --radius-xl: 24px;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family);
    background-color: var(--background);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

/* App Layout */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--background);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    overflow-y: auto;
}

.sidebar-header {
    margin-bottom: 2rem;
    padding: 0 0.5rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.avatar-placeholder {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.user-role {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-top: 2px;
}

/* Sidebar Navigation */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.875rem 1rem;
    border-radius: var(--radius-lg);
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 600;
    transition: all 0.2s ease;
}

.nav-item:hover {
    background-color: rgba(15, 91, 153, 0.05); /* very light primary */
    color: var(--primary);
}

.nav-item.active {
    background-color: var(--primary);
    color: white;
    box-shadow: var(--shadow-md);
}

.nav-icon {
    font-size: 1.5rem;
}

.nav-item.active .nav-icon {
    font-variation-settings: 'FILL' 1;
}

/* Main Wrapper */
.main-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Top Bar */
.top-bar {
    height: var(--topbar-height);
    background-color: transparent;
    display: flex;
    align-items: center;
    padding: 0 2rem;
}

.brand {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.top-bar-logo {
    height: 32px;
    width: auto;
}

.brand-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary);
}

/* App Content */
.app-content {
    flex: 1;
    padding: 1rem 2rem 2rem 2rem;
    overflow-y: auto;
}

/* --- Common UI Components --- */

.page-header {
    margin-bottom: 2rem;
}

.page-title {
    font-size: 2.5rem;
    font-weight: 800;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.page-subtitle {
    font-size: 1.125rem;
    color: var(--primary);
    font-weight: 600;
    margin-bottom: 1rem;
}

.page-description {
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 60ch;
    line-height: 1.6;
}

.card {
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    transition: box-shadow 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.grid-layouts {
    display: grid;
    gap: 1.5rem;
}

.grid-cols-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-cols-3 {
    grid-template-columns: repeat(3, 1fr);
}

.btn-primary {
    background-color: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    font-family: var(--font-family);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: background-color 0.2s ease;
}

.btn-primary:hover {
    background-color: var(--primary-dark);
}

/* View transition fade */
.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Form Styles */
.form-group {
    margin-bottom: 1.25rem;
}
.form-label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}
.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-family: inherit;
    font-size: 1rem;
    transition: border-color 0.2s;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

/* Basic Tables */
.table-container {
    width: 100%;
    overflow-x: auto;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.data-table th {
    font-weight: 600;
    color: var(--text-secondary);
    background: rgba(248, 249, 250, 0.5);
}

/* Add custom scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}
::-webkit-scrollbar-track {
    background: transparent; 
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1; 
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8; 
}

/* Chatbot Widget Styles */
.chat-widget {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.chat-toggle-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--primary);
    color: white;
    border: none;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease, background-color 0.2s;
}

.chat-toggle-btn .material-symbols-outlined {
    font-size: 2rem;
}

.chat-toggle-btn:hover {
    transform: scale(1.05);
    background-color: var(--primary-dark);
}

.chat-window {
    width: 350px;
    height: 500px;
    background-color: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    transition: opacity 0.3s ease, transform 0.3s ease;
    transform-origin: bottom right;
}

.chat-window.hidden {
    opacity: 0;
    transform: scale(0.8);
    pointer-events: none;
}

.chat-header {
    background-color: var(--primary);
    color: white;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h4 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 600;
}

.chat-status {
    font-size: 0.75rem;
    opacity: 0.8;
}

.chat-header .icon-btn {
    background: transparent;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.8;
}
.chat-header .icon-btn:hover { opacity: 1; }

.chat-messages {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    background-color: #f0f4f8;
}

.message {
    max-width: 80%;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    line-height: 1.4;
    word-wrap: break-word;
}

.ai-message {
    background-color: white;
    color: var(--text-primary);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.user-message {
    background-color: var(--primary);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
    box-shadow: var(--shadow-sm);
}

.chat-input-area {
    padding: 1rem;
    background-color: white;
    border-top: 1px solid var(--border);
}

#chat-form {
    display: flex;
    gap: 0.5rem;
}

#chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 20px;
    outline: none;
    font-family: inherit;
}

#chat-input:focus {
    border-color: var(--primary);
}

.send-btn {
    background-color: var(--primary);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.send-btn:hover {
    background-color: var(--primary-dark);
}
