:root {
    /* Color Palette */
    --primary-color: #2563eb; /* Blue */
    --primary-hover: #1d4ed8;
    --secondary-color: #0f172a; /* Deep Navy / Sidebar */
    --sidebar-hover: #1e293b;
    --sidebar-text: #94a3b8;
    --sidebar-text-active: #ffffff;
    
    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --border-color: #e2e8f0;
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    --purple: #8b5cf6;

    /* Spacing & Shadows */
    --radius: 8px;
    --radius-lg: 12px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow: hidden; /* Prevent body scroll, layout handles scrolling */
}

h1, h2, h3, h4, h5, h6 {
    font-family: 'Poppins', sans-serif;
    color: var(--text-main);
}

/* Layout */
.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* --- Sidebar --- */
.sidebar {
    width: 260px;
    background-color: var(--secondary-color);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    z-index: 100;
}

.sidebar.collapsed {
    width: 80px;
}

.sidebar-header {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.25rem;
    font-weight: 600;
    color: white;
    font-family: 'Poppins', sans-serif;
}

.logo i {
    font-size: 1.5rem;
    color: var(--primary-color);
}

.sidebar.collapsed .logo span {
    display: none;
}

.toggle-btn {
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 1.5rem;
    cursor: pointer;
    transition: var(--transition);
}

.toggle-btn:hover {
    color: white;
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 20px 0;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

/* Custom Scrollbar for dark area */
.sidebar-menu::-webkit-scrollbar { width: 4px; }
.sidebar-menu::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 4px; }

.menu-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 10px 20px;
    margin-top: 10px;
    color: rgba(255,255,255,0.4);
}

.sidebar.collapsed .menu-label {
    display: none;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px 20px;
    text-decoration: none;
    color: var(--sidebar-text);
    transition: var(--transition);
    border-left: 3px solid transparent;
    position: relative;
}

.menu-item:hover, .menu-item.active {
    background-color: var(--sidebar-hover);
    color: var(--sidebar-text-active);
}

.menu-item.active {
    border-left-color: var(--primary-color);
}

.menu-item i {
    font-size: 1.3rem;
}

.sidebar.collapsed .menu-item span:not(.badge) {
    display: none;
}

.badge {
    background-color: var(--danger);
    color: white;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: auto;
    font-weight: 600;
}

.sidebar.collapsed .badge {
    position: absolute;
    top: 5px;
    right: 15px;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), var(--purple));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}

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

.user-info .name {
    color: white;
    font-size: 0.9rem;
    font-weight: 500;
}

.user-info .role {
    font-size: 0.8rem;
}

.sidebar.collapsed .user-info {
    display: none;
}

/* --- Main Content --- */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Topbar */
.topbar {
    height: 70px;
    background-color: var(--surface-color);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 30px;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.search-bar {
    display: flex;
    align-items: center;
    background-color: var(--bg-color);
    padding: 8px 15px;
    border-radius: 20px;
    width: 350px;
    border: 1px solid transparent;
    transition: var(--transition);
}

.search-bar:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
    background-color: var(--surface-color);
}

.search-bar i {
    color: var(--text-muted);
    font-size: 1.2rem;
}

.search-bar input {
    border: none;
    background: none;
    outline: none;
    margin-left: 10px;
    width: 100%;
    font-size: 0.9rem;
    color: var(--text-main);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.action-btn {
    background: none;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    position: relative;
}

.action-btn:hover {
    background-color: var(--bg-color);
    color: var(--text-main);
}

.notification-dot {
    position: absolute;
    top: 8px;
    right: 10px;
    width: 8px;
    height: 8px;
    background-color: var(--danger);
    border-radius: 50%;
    border: 2px solid var(--surface-color);
}

/* Views Container */
.view-container {
    flex: 1;
    overflow-y: auto;
    padding: 30px;
    position: relative;
}

.view {
    display: none;
    animation: fadeIn 0.4s ease;
}

.view.active {
    display: block;
}

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

.view-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    margin-bottom: 30px;
}

.view-header h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

.subtitle {
    color: var(--text-muted);
    margin-top: 5px;
}

/* Buttons */
.primary-btn {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--transition);
    box-shadow: var(--shadow-sm);
}

.primary-btn:hover {
    background-color: var(--primary-hover);
    box-shadow: var(--shadow-md);
}

.primary-btn.full-width {
    width: 100%;
    justify-content: center;
    margin-top: 20px;
}

.icon-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.2rem;
    cursor: pointer;
    border-radius: 5px;
    padding: 5px;
    transition: var(--transition);
}

.icon-btn:hover {
    background-color: var(--bg-color);
    color: var(--text-main);
}

/* Welcome Banner */
.welcome-banner {
    background: linear-gradient(135deg, #1e3a8a, var(--primary-color));
    border-radius: var(--radius-lg);
    padding: 40px;
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 30px;
    box-shadow: var(--shadow-md);
    position: relative;
    overflow: hidden;
}

.welcome-banner::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    background: url('data:image/svg+xml;utf8,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="40" stroke="rgba(255,255,255,0.1)" stroke-width="2" fill="none"/></svg>') repeat;
    opacity: 0.5;
    pointer-events: none;
}

.banner-content {
    max-width: 600px;
    position: relative;
    z-index: 1;
}

.banner-content h2 {
    color: white;
    font-size: 1.8rem;
    margin-bottom: 15px;
}

.banner-content .lead {
    font-size: 1.1rem;
    font-weight: 500;
    margin-bottom: 10px;
    color: #e0e7ff;
}

.banner-content p {
    margin-bottom: 10px;
    line-height: 1.6;
    color: #d1d5db;
    font-size: 0.95rem;
}

.banner-illustration i {
    font-size: 8rem;
    color: rgba(255,255,255,0.2);
    position: relative;
    z-index: 1;
    transform: rotate(15deg);
}

/* Metrics Grid */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.metric-card {
    background-color: var(--surface-color);
    padding: 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 20px;
    border: 1px solid var(--border-color);
    transition: var(--transition);
}

.metric-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.metric-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    background-color: rgba(37, 99, 235, 0.1);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.metric-icon.blue { background-color: rgba(59, 130, 246, 0.1); color: var(--info); }
.metric-icon.green { background-color: rgba(16, 185, 129, 0.1); color: var(--success); }
.metric-icon.purple { background-color: rgba(139, 92, 246, 0.1); color: var(--purple); }

.metric-info {
    display: flex;
    flex-direction: column;
}

.metric-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    font-family: 'Poppins', sans-serif;
}

.metric-label {
    font-size: 0.85rem;
    color: var(--text-muted);
}

/* Panels */
.panel {
    background-color: var(--surface-color);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    overflow: hidden;
    margin-bottom: 30px;
}

.panel-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.view-all {
    color: var(--primary-color);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

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

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

.data-table th {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    background-color: #f8fafc;
}

.data-table td {
    font-size: 0.9rem;
}

.data-table tbody tr:hover {
    background-color: #f8fafc;
}

.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* Badges */
.status-badge {
    padding: 5px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-badge.in-progress { background-color: rgba(59, 130, 246, 0.1); color: var(--info); }
.status-badge.pending { background-color: rgba(245, 158, 11, 0.1); color: var(--warning); }
.status-badge.completed { background-color: rgba(16, 185, 129, 0.1); color: var(--success); }

/* Placeholder Panel */
.placeholder-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 80px 20px;
    text-align: center;
    color: var(--text-muted);
}

.placeholder-panel i {
    font-size: 4rem;
    color: var(--border-color);
    margin-bottom: 20px;
}

.placeholder-panel h2 {
    color: var(--text-main);
    margin-bottom: 10px;
}

/* --- Chat App View --- */
.chat-app {
    display: flex;
    height: calc(100vh - 220px);
    background-color: var(--surface-color);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
}

.chat-sidebar {
    width: 320px;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background-color: #fff;
}

.chat-search {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
}

.chat-search input {
    width: 100%;
    padding: 10px 15px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    outline: none;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    display: flex;
    gap: 15px;
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition);
}

.chat-item:hover, .chat-item.active {
    background-color: var(--bg-color);
}

.chat-item.unread .chat-name {
    font-weight: 700;
}

.chat-item.unread p {
    font-weight: 600;
    color: var(--text-main);
}

.chat-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background-color: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    flex-shrink: 0;
}

.chat-preview {
    flex: 1;
    min-width: 0;
}

.chat-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
}

.chat-name {
    font-size: 0.9rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-time {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.chat-preview p {
    font-size: 0.85rem;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: #fcfcfc;
}

.chat-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--surface-color);
}

.chat-title h3 {
    font-size: 1.1rem;
    margin-bottom: 2px;
}

.status-indicator {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-indicator.online::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: var(--success);
    border-radius: 50%;
}

.chat-messages {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message {
    max-width: 70%;
}

.message.incoming {
    align-self: flex-start;
}

.message-bubble {
    background-color: var(--surface-color);
    border: 1px solid var(--border-color);
    padding: 15px;
    border-radius: 0 15px 15px 15px;
    box-shadow: var(--shadow-sm);
    position: relative;
}

.message-bubble p {
    font-size: 0.95rem;
    line-height: 1.5;
    margin-bottom: 5px;
}

.message-bubble .time {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: right;
    display: block;
}

.chat-input-area {
    padding: 20px;
    background-color: var(--surface-color);
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 15px;
}

.chat-input-area input {
    flex: 1;
    padding: 12px 20px;
    border-radius: 25px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-color);
    outline: none;
    font-size: 0.95rem;
}

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

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: all;
}

.modal-content {
    background-color: var(--surface-color);
    width: 100%;
    max-width: 450px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    transform: translateY(20px);
    transition: var(--transition);
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    padding: 20px 25px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 1.2rem;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
}

.close-btn:hover {
    color: var(--danger);
}

.modal-body {
    padding: 25px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-main);
}

.form-group input, .form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    outline: none;
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    transition: var(--transition);
}

.form-group input:focus, .form-group select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: -260px;
        height: 100%;
    }
    .sidebar.mobile-active {
        left: 0;
    }
    .topbar {
        padding: 0 15px;
    }
    .search-bar {
        width: 200px;
    }
    .view-container {
        padding: 15px;
    }
    .welcome-banner {
        flex-direction: column;
        padding: 25px;
        text-align: center;
    }
    .banner-illustration {
        display: none;
    }
    .chat-app {
        flex-direction: column;
    }
    .chat-sidebar {
        width: 100%;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
        height: 40%;
    }
}
