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

:root {
    /* Color Palette - 2026 Neon Glass */
    --primary: #7f5af0;
    --primary-hover: #6242c7;
    --secondary: #2cb67d;
    --danger: #ef4565;
    --warning: #ffbe0b;

    /* Backgrounds */
    --bg-dark: #0f0e17;
    --bg-card: rgba(255, 255, 255, 0.05);
    --bg-glass: rgba(22, 22, 26, 0.8);

    /* Text */
    --text-main: #fffffe;
    --text-muted: #94a1b2;

    /* Borders & Shadows */
    --border-glass: rgba(255, 255, 255, 0.1);
    --shadow-soft: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-neon: 0 0 15px rgba(127, 90, 240, 0.3);

    /* Dimensions */
    --sidebar-width: 280px;
    --header-height: 70px;
    --radius-md: 12px;
    --radius-lg: 16px;
}

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

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    /* Deep Gradient Background */
    background: radial-gradient(circle at 0% 0%, #2e1065 0%, #0f0e17 50%, #0f0e17 100%);
    background-attachment: fixed;
    color: var(--text-main);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: var(--primary);
    transition: all 0.2s ease;
}

ul {
    list-style: none;
}

/* =========================
   SIDEBAR COMPONENT
   ========================= */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-glass);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 50;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-glass);
}

.sidebar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    letter-spacing: -0.5px;
}

.sidebar-brand img {
    height: 32px;
    width: auto;
}

.sidebar-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 1rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background: var(--bg-card);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-glass);
    margin-bottom: 2rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    color: white;
}

.user-details h4 {
    font-size: 0.95rem;
    margin-bottom: 2px;
}

.user-details span {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Navigation Links */
.nav-link {
    display: flex;
    align-items: center;
    padding: 0.85rem 1rem;
    color: var(--text-muted);
    border-radius: var(--radius-md);
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.nav-link i {
    width: 24px;
    margin-right: 12px;
    text-align: center;
    font-size: 1.1rem;
    transition: transform 0.2s;
}

.nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
    transform: translateX(4px);
}

.nav-link:hover i {
    color: var(--primary);
    transform: scale(1.1);
}

.nav-link.active {
    background: rgba(127, 90, 240, 0.15);
    color: var(--primary);
    border: 1px solid rgba(127, 90, 240, 0.2);
    box-shadow: 0 0 15px rgba(127, 90, 240, 0.1);
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid var(--border-glass);
}

/* =========================
   MAIN CONTENT AREA
   ========================= */
.main-content-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Top Bar (Mobile) */
.top-bar {
    height: var(--header-height);
    background: rgba(15, 14, 23, 0.9);
    backdrop-filter: blur(10px);
    display: none;
    /* Desktop hidden */
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    position: sticky;
    top: 0;
    z-index: 40;
    border-bottom: 1px solid var(--border-glass);
}

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

/* Container */
.dashboard-container {
    padding: 2.5rem;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    flex: 1;
}

/* =========================
   UI COMPONENTS
   ========================= */

/* Cards */
.card,
.content,
.auth-container {
    background: var(--bg-card);
    backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow-soft);
}

/* Typography */
h1 {
    font-size: 2rem;
    margin-bottom: 1.5rem;
    font-weight: 700;
    letter-spacing: -1px;
}

h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

h3 {
    font-size: 1.25rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

p {
    margin-bottom: 1rem;
    color: var(--text-muted);
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-muted);
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 0.85rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    color: var(--text-main);
    font-size: 0.95rem;
    font-family: inherit;
    transition: all 0.2s ease;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(0, 0, 0, 0.4);
    box-shadow: 0 0 0 3px rgba(127, 90, 240, 0.2);
}

/* Buttons */
button,
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.85rem 1.5rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
    gap: 0.5rem;
}

button[type="submit"],
.btn-primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 14px 0 rgba(127, 90, 240, 0.39);
}

button[type="submit"]:hover,
.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(127, 90, 240, 0.23);
}

.btn-icon {
    background: transparent;
    color: var(--text-main);
    font-size: 1.25rem;
    padding: 0.5rem;
}

.btn-logout {
    background: rgba(239, 69, 101, 0.1);
    color: var(--danger);
    width: 100%;
    justify-content: flex-start;
}

.btn-logout:hover {
    background: rgba(239, 69, 101, 0.2);
    transform: translateX(4px);
}

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

.btn-secondary:hover {
    background: var(--bg-glass);
    border-color: var(--primary);
    transform: translateY(-2px);
}

.btn-danger {
    background: rgba(239, 69, 101, 0.2);
    color: var(--danger);
    border: 1px solid rgba(239, 69, 101, 0.3);
}

.btn-danger:hover {
    background: var(--danger);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(239, 69, 101, 0.3);
}

.btn-small {
    padding: 0.5rem 0.8rem;
    font-size: 0.85rem;
    height: fit-content;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}

.btn-outline:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
}

/* Tables */
.table-responsive {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-glass);
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 800px;
}

thead {
    background: rgba(255, 255, 255, 0.03);
}

th {
    padding: 1.25rem 1.5rem;
    text-align: left;
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
    color: var(--text-muted);
}

td {
    padding: 1.25rem 1.5rem;
    border-top: 1px solid var(--border-glass);
    color: var(--text-main);
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* Auth Page Specifics */
.auth-container {
    width: 100%;
    max-width: 420px;
    margin: auto;
    /* Center in flex body */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.auth-container button {
    width: 100%;
    margin-top: 1rem;
    padding: 1rem;
    font-size: 1.1rem;
}

.auth-container h1,
.auth-container h2 {
    text-align: center;
}

/* =========================
   RESPONSIVE DESIGN
   ========================= */
@media (max-width: 991px) {
    :root {
        --sidebar-width: 0px;
        /* Collapsed by default on mobile */
    }

    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        /* Expand to full width when active */
    }

    .sidebar.active {
        transform: translateX(0);
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.5);
    }

    .main-content-wrapper {
        margin-left: 0;
    }

    .top-bar {
        display: flex;
    }

    .dashboard-container {
        padding: 1.5rem;
    }
}

/* Tablets and typical Mobile Landscape */
@media (max-width: 768px) {
    h1 {
        font-size: 1.5rem;
    }
    
    h2 {
        font-size: 1.25rem;
    }
    
    .card, .content {
        padding: 1.2rem;
    }
    
    /* Make custom manual grids (like forms displaying side-by-side) stack */
    div[style*="display: grid; grid-template-columns: repeat(2, 1fr)"],
    div[style*="grid-template-columns: repeat(auto-fit"],
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    button, .btn {
        width: 100%;
        margin-bottom: 0.5rem;
        justify-content: center;
    }
    
    .table-responsive {
        border-radius: var(--radius-md);
        margin-bottom: 1rem;
    }

    /* Small screens pagination and floating buttons */
    .chat-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .chat-header a {
        width: 100%;
        text-align: center;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .dashboard-container {
        padding: 1rem 0.5rem;
    }
    
    .auth-container {
        padding: 1.5rem;
    }

    /* Adjust tables slightly for tiny screens */
    td, th {
        padding: 0.8rem 1rem;
        font-size: 0.85rem;
    }
}

/* Global Fixes for Inline PHP layouts */
@media (max-width: 768px) {
    div[style*="justify-content: space-between"] {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 1rem !important;
    }
    div[style*="justify-content: space-between"] > div,
    div[style*="justify-content: space-between"] > form {
        width: 100% !important;
        flex-direction: column !important;
        align-items: stretch !important;
    }
}