:root {
    --primary-color: #480e0e;
    --primary-light: #6d2424;
    --secondary-color: #ffffff;
    --text-color: #333333;
    --text-muted: #65676b;
    --bg-color: #f0f2f5; /* Facebook-style grey */
    --card-bg: #ffffff;
    --border-color: #e4e6eb;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --sidebar-width: 280px;
    --header-height: 60px;
    --font-family: 'Lexend', sans-serif;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --radius-md: 8px;
    --radius-lg: 12px;
}

[data-theme="dark"] {
    /* --primary-color: inherit; Brand color comes from root/theme_loader */
    --primary-light: #8a3b3b;
    --bg-color: #18191a;
    --card-bg: #242526;
    --text-color: #e4e6eb;
    --text-muted: #b0b3b8;
    --border-color: #3e4042;
    --secondary-color: #242526;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.5);
}

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

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.5;
    font-size: 15px;
    transition: background-color 0.3s, color 0.3s;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color 0.2s;
}

ul {
    list-style: none;
}

img {
    max-width: 100%;
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--card-bg);
    border-right: 1px solid var(--border-color);
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    left: 0;
    top: 0;
    z-index: 1000;
    transition: transform 0.3s ease;
}

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

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

.sidebar-nav {
    padding: 10px;
}

.nav-item {
    margin-bottom: 2px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    color: var(--text-color);
    font-weight: 500;
}

.nav-link:hover, .nav-link.active {
    background-color: rgba(72, 14, 14, 0.05); /* Tint of primary */
    color: var(--primary-color);
}

[data-theme="dark"] .nav-link:hover, [data-theme="dark"] .nav-link.active {
    background-color: rgba(255, 255, 255, 0.1);
    color: #ff8f8f; /* Lighter color for dark mode active state */
}

.nav-link i {
    margin-right: 12px;
    width: 20px;
    text-align: center;
    font-size: 1.1rem;
}

.nav-section-label {
    padding: 15px 12px 5px;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.3s;
    width: calc(100% - var(--sidebar-width));
}

/* Header/Navbar */
.top-header {
    height: var(--header-height);
    background-color: var(--card-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 999;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

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

.header-search input {
    background-color: var(--bg-color);
    border: none;
    padding: 8px 16px;
    border-radius: 20px;
    width: 250px;
    font-family: inherit;
    outline: none;
    color: var(--text-color);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

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

.user-profile-menu {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-color: #ddd;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Page Content */
.page-content {
    padding: 20px;
    max-width: 100%;
    margin: 0 auto;
    width: 100%;
}

.page-header {
    margin-bottom: 20px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 5px;
}

/* Cards */
.card {
    background-color: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
}

.card-header {
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.card-title {
    font-weight: 600;
    font-size: 1.1rem;
}

/* Forms */
.form-group {
    margin-bottom: 15px;
}

.form-label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-muted);
}

.form-control, input, select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-family: inherit;
    transition: border-color 0.2s;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin-bottom: 10px; /* Added spacing */
}

.form-control:focus, input:focus, select:focus, textarea:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 2px rgba(72, 14, 14, 0.1);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-family: inherit;
}

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

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

.btn-secondary {
    background-color: var(--bg-color);
    color: var(--text-color);
    border: 1px solid var(--border-color);
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

/* Tables */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
}

.table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* Force scroll on small screens */
}

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

.table th {
    font-weight: 600;
    color: var(--text-muted);
    background-color: var(--bg-color);
}

/* Widgets / Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

@media (max-width: 576px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

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

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-color: rgba(72, 14, 14, 0.1);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.stat-info h3 {
    font-size: 1.5rem;
    font-weight: 700;
}

.stat-info p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Public Site Styles (Landing Page) */
.hero {
    background: linear-gradient(rgba(72, 14, 14, 0.9), rgba(72, 14, 14, 0.8)), url('/assets/img/campus.jpg');
    background-size: cover;
    background-position: center;
    padding: 100px 20px;
    color: white;
    text-align: center;
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-content {
    max-width: 800px;
}

.hero h1 {
    font-size: 3rem;
    margin-bottom: 20px;
    line-height: 1.2;
}

.nav-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 5%;
    background: var(--card-bg);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background-color 0.3s;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 25px;
}

.nav-links a {
    font-weight: 500;
    color: var(--text-color);
}

.nav-links a:hover {
    color: var(--primary-color);
}

.mobile-menu-btn {
    display: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-color);
}

/* Section Styling */
.section {
    padding: 80px 5%;
}

.section-title {
    text-align: center;
    margin-bottom: 50px;
    font-size: 2.2rem;
    color: var(--primary-color);
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 40px;
}

@media (max-width: 768px) {
    .features-grid {
        grid-template-columns: 1fr;
    }
}

.feature-card {
    text-align: center;
    padding: 40px;
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s, box-shadow 0.3s;
    border: 1px solid var(--border-color);
}

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

.footer {
    background: #111;
    color: white;
    padding: 60px 5%;
    text-align: center;
}

/* Tips / Help Section */
.page-tips {
    background-color: rgba(23, 162, 184, 0.1);
    border-left: 4px solid var(--info-color);
    padding: 15px;
    margin-bottom: 20px;
    border-radius: 4px;
    color: var(--text-color);
    font-size: 0.95rem;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}
.page-tips-title {
    font-weight: 600;
    margin-bottom: 5px;
    color: var(--info-color);
    display: flex;
    align-items: center;
    gap: 8px;
}
.page-tips-content {
    flex: 1;
}
.page-tips-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    margin-left: 10px;
}

/* Responsive */
@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        width: 100%; /* Cover full width when open on mobile */
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        width: 100%;
    }

    .sidebar-toggle-btn {
        display: block;
    }

    .nav-bar .nav-links {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: var(--card-bg);
        flex-direction: column;
        padding: 20px;
        box-shadow: var(--shadow-md);
    }

    .nav-bar .nav-links.active {
        display: flex;
    }

    .mobile-menu-btn {
        display: block;
    }
}

@media (max-width: 768px) {
    .hero h1 { font-size: 2rem; }
    .section { padding: 50px 20px; }
    .header-search input { width: 150px; }

    /* Force 1 column on mobile */
    .stats-grid {
        grid-template-columns: 1fr !important;
    }

    .row {
        flex-direction: column !important;
        display: flex;
    }

    .col, .col-md-4, .col-md-6, .col-md-8, .col-md-3, .col-md-2 {
        flex: 0 0 100% !important;
        max-width: 100% !important;
        min-width: 100% !important;
        margin-bottom: 20px;
    }

    .card {
        margin-bottom: 15px;
    }

    /* Ensure tables scroll */
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    body {
        overflow-x: hidden;
    }
}
/* Enhanced Chat Styling (Global & Responsive) */
.chat-layout {
    display: flex;
    height: calc(100vh - 120px);
    background: #fff;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    margin-top: 15px;
}
.chat-sidebar { width: 320px; border-right: 1px solid var(--border-color); display: flex; flex-direction: column; background: #fff; }
.chat-main { flex: 1; display: flex; flex-direction: column; background: #efeae2; position: relative; }
.chat-search { padding: 15px; background: #f0f2f5; border-bottom: 1px solid var(--border-color); }
.chat-search input { width: 100%; border-radius: 20px; padding: 10px 15px; border: 1px solid #ccc; outline: none; }
.user-list { flex: 1; overflow-y: auto; }
.user-item { display: flex; align-items: center; gap: 15px; padding: 12px 15px; cursor: pointer; border-bottom: 1px solid #f0f2f5; transition: 0.2s; }
.user-item:hover { background: #f5f6f6; }
.user-item.active { background: #e9edef; }
.chat-avatar { width: 45px; height: 45px; border-radius: 50%; background: var(--primary-color); display: flex; justify-content: center; align-items: center; font-size: 1.2rem; color: #fff; flex-shrink: 0; }
.chat-header { padding: 10px 15px; background: #f0f2f5; border-bottom: 1px solid var(--border-color); display: flex; align-items: center; gap: 15px; height: 65px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.message { max-width: 75%; padding: 10px 14px; border-radius: 8px; position: relative; font-size: 0.95rem; line-height: 1.4; box-shadow: 0 1px 1px rgba(0,0,0,0.1); }
.msg-sent { align-self: flex-end; background: #d9fdd3; border-top-right-radius: 0; }
.msg-received { align-self: flex-start; background: #fff; border-top-left-radius: 0; }
.chat-input-area { padding: 12px 15px; background: #f0f2f5; display: flex; align-items: center; gap: 10px; border-top: 1px solid var(--border-color); }
.chat-input { flex: 1; border: none; padding: 12px 20px; border-radius: 24px; outline: none; font-size: 0.95rem; }
.chat-send-btn { background: var(--primary-color); color: #fff; border: none; border-radius: 50%; width: 45px; height: 45px; display: flex; align-items: center; justify-content: center; cursor: pointer; transition: 0.2s; }
.chat-send-btn:hover { background: var(--primary-color-dark); }
.back-btn { display: none; }

@media (max-width: 768px) {
    .chat-layout { height: calc(100vh - 80px); border-radius: 0; border: none; margin-top: 0; }
    .chat-sidebar { width: 100%; display: flex; }
    .chat-sidebar.hidden { display: none; }
    .chat-main { display: none; width: 100%; position: absolute; top: 0; left: 0; height: 100%; z-index: 10; }
    .chat-main.active { display: flex; }
    .back-btn { display: block !important; cursor: pointer; font-size: 1.4rem; color: var(--text-color); margin-right: 10px; }
}
