@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
    --bg-color: #0b0e14;
    --card-bg: rgba(23, 27, 34, 0.8);
    --primary: #3b82f6;
    --primary-hover: #2563eb;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --border-color: rgba(255, 255, 255, 0.08);
    --radius: 16px;
    --shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; margin: 0; padding: 0; font-family: 'Inter', sans-serif; }

html, body {
    overflow-x: hidden;
    width: 100%;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(59, 130, 246, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(59, 130, 246, 0.05) 0%, transparent 40%),
        radial-gradient(circle at 50% -20%, #1e293b 0%, #0b0e14 100%);
    color: var(--text-main);
    min-height: 100vh;
    position: relative;
}

body::before {
    content: '';
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: url('https://www.transparenttextures.com/patterns/carbon-fibre.png');
    opacity: 0.03;
    pointer-events: none;
    z-index: -1;
}

/* Background Animation */
.bg-animate {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    z-index: -2;
    overflow: hidden;
}
.circle {
    position: absolute;
    border-radius: 50%;
    background: var(--primary);
    filter: blur(80px);
    opacity: 0.1;
    animation: float 20s infinite alternate;
}
@keyframes float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(100px, 100px) scale(1.5); }
}

.container { max-width: 1600px; margin: 0 auto; padding: 1.5rem; width: 100%; }

/* Navbar & Brand */
.navbar {
    background: rgba(11, 14, 20, 0.8); backdrop-filter: blur(20px); border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1.5rem; display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; z-index: 1000;
    max-width: 100vw;
}
.nav-brand { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.logo-img { height: 40px; width: auto; max-width: 150px; object-fit: contain; }
.user-badge { background: rgba(59, 130, 246, 0.15); color: #60a5fa; padding: 4px 12px; border-radius: 8px; font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }

/* Desktop Navigation */
.nav-links { display: flex; gap: 1.5rem; align-items: center; }
.nav-links a { color: var(--text-muted); font-size: 0.9rem; font-weight: 500; text-decoration: none; transition: 0.2s; }
.nav-links a.active, .nav-links a:hover { color: var(--text-main); }
.btn-logout { background: rgba(239, 68, 68, 0.1); color: var(--danger) !important; padding: 6px 14px; border-radius: 8px; border: 1px solid rgba(239, 68, 68, 0.2); }
.btn-logout:hover { background: var(--danger); color: white !important; }

/* Burger Menu */
.burger-menu {
    display: none; width: 30px; height: 24px; position: relative; background: none; border: none; cursor: pointer; z-index: 1010;
}
.burger-menu span {
    display: block; width: 100%; height: 2px; background: var(--text-main); position: absolute; left: 0; transition: 0.3s;
}
.burger-menu span:nth-child(1) { top: 0; }
.burger-menu span:nth-child(2) { top: 50%; transform: translateY(-50%); }
.burger-menu span:nth-child(3) { bottom: 0; }

.burger-menu.active span:nth-child(1) { transform: rotate(45deg); top: 11px; }
.burger-menu.active span:nth-child(2) { opacity: 0; }
.burger-menu.active span:nth-child(3) { transform: rotate(-45deg); bottom: 11px; }

/* Cards & Components */
.card {
    background: var(--card-bg); backdrop-filter: blur(12px); border: 1px solid var(--border-color);
    border-radius: var(--radius); padding: 1.5rem; box-shadow: var(--shadow);
    max-width: 100%; overflow: hidden;
}
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; margin-bottom: 0.5rem; font-size: 0.85rem; font-weight: 500; color: var(--text-muted); }
.form-control {
    width: 100%; padding: 0.85rem 1rem; background: rgba(0,0,0,0.3); border: 1px solid var(--border-color);
    border-radius: 10px; color: var(--text-main); font-size: 0.95rem; transition: all 0.2s;
}
.form-control:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15); }

.btn {
    display: inline-flex; align-items: center; justify-content: center; padding: 0.85rem 1.5rem;
    font-size: 0.95rem; font-weight: 600; border-radius: 10px; border: none; cursor: pointer; transition: 0.2s;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 0.4rem 0.8rem; font-size: 0.8rem; border-radius: 6px; }

.alert { padding: 1rem; border-radius: 10px; margin-bottom: 1.5rem; font-size: 0.9rem; border: 1px solid; }
.alert-error { background: rgba(239, 68, 68, 0.1); color: #fca5a5; border-color: rgba(239, 68, 68, 0.2); }
.alert-success { background: rgba(16, 185, 129, 0.1); color: #6ee7b7; border-color: rgba(16, 185, 129, 0.2); }

table { width: 100%; border-collapse: collapse; }
th, td { padding: 1rem; text-align: left; border-bottom: 1px solid var(--border-color); }
th { color: var(--text-muted); font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700; }

.badge { padding: 4px 10px; border-radius: 6px; font-size: 0.75rem; font-weight: 700; }
.badge-paid { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.badge-unpaid { background: rgba(239, 68, 68, 0.15); color: #f87171; }

/* Activity Table */
.activity-table { margin-top: 1rem; }
.activity-table th { padding: 0.75rem; background: rgba(255,255,255,0.02); }
.activity-table td { padding: 1rem 0.75rem; vertical-align: middle; }
.activity-table tr:hover { background: rgba(255,255,255,0.02); }

/* Table Responsiveness Utility */
.table-responsive {
    width: 100%;
    overflow-x: auto !important;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    display: block;
}
.table-responsive table {
    width: 100%;
    min-width: 800px !important; /* Force a wide layout to guarantee scroll */
    border-collapse: collapse;
}
.table-responsive th, .table-responsive td {
    white-space: nowrap; /* Prevent text from wrapping and squeezing the table */
}
@media (max-width: 768px) {
    .card { padding: 1rem; }
    .table-responsive table {
        font-size: 0.85rem;
    }
}

/* Page Headers */
.page-header { margin-bottom: 2rem; }
.page-header h2 { font-size: 1.75rem; }

/* Desktop Grids */
.grid-wide { grid-template-columns: 2.5fr 1fr; display: grid; gap: 1.5rem; }
.dashboard-layout { display: grid; grid-template-columns: 300px 1fr 350px; gap: 1.5rem; align-items: flex-start; }

/* Media Queries for Responsiveness */

@media (max-width: 1400px) {
    .dashboard-layout { grid-template-columns: 250px 1fr 300px; }
}

@media (max-width: 1200px) {
    .dashboard-layout { grid-template-columns: 1fr 300px; }
    .left-sidebar { display: none; }
    .grid-wide { grid-template-columns: 1fr; }
}

@media (max-width: 992px) {
    .burger-menu { display: block; }
    .nav-links {
        position: fixed; top: 0; right: 0; width: 280px; height: 100vh;
        background: #0b0e14; flex-direction: column; padding: 5rem 2rem;
        box-shadow: -10px 0 30px rgba(0,0,0,0.5); border-left: 1px solid var(--border-color);
        z-index: 1001;
        backdrop-filter: blur(20px);
        transform: translate3d(100%, 0, 0);
        transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex !important;
    }
    .nav-links.active { transform: translate3d(0, 0, 0); }
    
    .dashboard-layout { grid-template-columns: 1fr !important; }
    .right-sidebar { order: -1; width: 100% !important; max-width: 100%; }
    .main-content { width: 100% !important; max-width: 100%; min-width: 0; }
    
    /* Force grid/flex items to not overflow */
    .card, .container, .dashboard-layout > * {
        min-width: 0;
    }
}

@media (max-width: 768px) {
    .navbar { padding: 0.75rem 1rem; }
    .logo-img { height: 32px; }
    .container { padding: 0.75rem; width: 100%; }
    th, td { padding: 0.75rem 0.5rem; }
    
    /* Force stack all elements */
    .dashboard-layout, .grid-wide { grid-template-columns: 1fr !important; }
    
    /* Chat adjustments */
    .msg { max-width: 90%; }
    .chat-container { height: calc(100vh - 150px); }
}

/* Chat Styles */
.chat-container { display: flex; flex-direction: column; height: calc(100vh - 200px); min-height: 500px; }
.chat-messages { flex: 1; overflow-y: auto; padding: 1.5rem; display: flex; flex-direction: column; gap: 1rem; }
.msg { max-width: 80%; padding: 0.8rem 1.2rem; border-radius: 14px; position: relative; }
.msg-received { background: rgba(255,255,255,0.05); align-self: flex-start; border-bottom-left-radius: 2px; }
.msg-sent { background: var(--primary); color: white; align-self: flex-end; border-bottom-right-radius: 2px; }
.msg-info { font-size: 0.7rem; color: var(--text-muted); margin-bottom: 4px; display: block; }
.msg-sent .msg-info { color: rgba(255,255,255,0.7); }
.chat-input-area { padding: 1.5rem; border-top: 1px solid var(--border-color); display: flex; gap: 1rem; }

.floating-chat-btn {
    position: fixed; bottom: 2rem; right: 2rem; width: 60px; height: 60px;
    background: var(--primary); border-radius: 50%; display: flex; align-items: center; justify-content: center;
    box-shadow: 0 8px 32px rgba(59, 130, 246, 0.4); color: white; text-decoration: none; font-size: 1.5rem;
    z-index: 999; transition: transform 0.3s;
}
.floating-chat-btn:hover { transform: scale(1.1); }
@media (max-width: 768px) { .floating-chat-btn { bottom: 1.5rem; right: 1.5rem; width: 50px; height: 50px; font-size: 1.2rem; } }

/* Mention Dropdown */
.mention-dropdown {
    position: absolute; background: #1f2937; border: 1px solid var(--border-color);
    border-radius: 8px; box-shadow: 0 10px 25px rgba(0,0,0,0.5); z-index: 2000;
    max-height: 200px; overflow-y: auto; width: 200px; display: none;
}
.mention-item {
    padding: 10px 15px; cursor: pointer; border-bottom: 1px solid rgba(255,255,255,0.05);
    font-size: 0.85rem; color: var(--text-main); transition: 0.2s;
}
.mention-item:hover, .mention-item.active { background: var(--primary); }
.mention-item:last-child { border-bottom: none; }
