/* Glassmorphism & Modern UI Styles */
:root {
    --primary: #4361ee;
    --secondary: #3f37c9;
    --accent: #f72585;
    --success: #4cc9f0;
    --bg-dark: #0f172a;
    --bg-grad: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    --card-bg: rgba(255, 255, 255, 0.05);
    --border: rgba(255, 255, 255, 0.1);
    --text: #f8fafc;
    --text-muted: #94a3b8;
    --font: 'Inter', -apple-system, sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: var(--font);
}

body {
    background: var(--bg-grad);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Glass Container */
.glass-panel {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-in {
    animation: fadeIn 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
    position: relative;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text);
    font-size: 1rem;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.3);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    width: 100%;
    text-align: center;
}

.btn-primary {
    background: linear-gradient(to right, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 4px 15px rgba(67, 97, 238, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(67, 97, 238, 0.6);
}

/* Utility */
.text-center {
    text-align: center;
}

.mt-2 {
    margin-top: 0.5rem;
}

.mt-4 {
    margin-top: 1.5rem;
}

.hidden {
    display: none !important;
}

/* Grid systems */
.dashboard-container {
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 3rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.header-title {
    font-size: 2rem;
    background: linear-gradient(to right, #4cc9f0, #4361ee);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}

.course-card {
    transition: transform 0.3s ease;
    cursor: pointer;
}

.course-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
}

.card-tag {
    background: rgba(67, 97, 238, 0.2);
    color: #4cc9f0;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: bold;
    display: inline-block;
    margin-bottom: 1rem;
}

/* Admin Specific */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #334155;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary);
}

input:checked+.slider:before {
    transform: translateX(26px);
}

/* Comments Section */
.comments-section {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border);
}

.comment-box {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.comment-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

/* Modal / Popup CSS */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    background: var(--bg-dark);
    border: 1px solid var(--border);
    border-radius: 12px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 2rem;
    color: var(--text);
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    cursor: pointer;
    font-size: 1.5rem;
    color: var(--text-muted);
    line-height: 1;
    border: none;
    background: none;
    transition: 0.2s;
}

.modal-close:hover {
    color: #fff;
}

/* Responsive / Mobile Design */
@media screen and (max-width: 768px) {
    .dashboard-container {
        padding: 0.8rem;
    }

    .glass-panel {
        padding: 0.8rem;
        border-radius: 12px;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
        /* Prevent container from expanding */
    }

    .header {
        flex-direction: column;
        align-items: center;
        text-align: center;
        gap: 1rem;
    }

    .header-title {
        font-size: 1.5rem;
    }

    .header .btn {
        width: 100%;
    }

    /* Tabs as Scrollable row */
    .tabs {
        display: flex;
        overflow-x: auto;
        gap: 0.5rem;
        margin-bottom: 1.5rem;
        padding-bottom: 5px;
        -webkit-overflow-scrolling: touch;
        border-bottom: 1px solid var(--border);
    }

    .tab-btn {
        flex: 0 0 auto;
        /* Prevent shrinking */
        width: auto;
        padding: 10px 15px;
        font-size: 0.85rem;
        white-space: nowrap;
        text-align: center;
        background: rgba(255, 255, 255, 0.03);
        border-radius: 8px;
        border: 1px solid var(--border);
    }

    .tab-btn.active {
        background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
        color: white;
        border: none;
        box-shadow: 0 4px 12px rgba(67, 97, 238, 0.3);
    }

    /* Table Improvements */
    .table-wrapper {
        width: 100% !important;
        overflow-x: auto !important;
        display: block !important;
        -webkit-overflow-scrolling: touch;
        margin-top: 1rem;
        border-radius: 8px;
        position: relative;
    }

    table {
        width: 100%;
        min-width: 1000px;
        /* Increase to force scroll on almost all mobile screens */
        table-layout: auto;
    }

    th,
    td {
        padding: 0.8rem 0.5rem;
        font-size: 0.8rem;
        white-space: nowrap;
        /* Prevent text wrapping from hiding the need to scroll */
    }

    /* Chat View Mobile adjustments */
    #chatsView {
        height: 85vh !important;
    }

    #chatsView>div {
        flex-direction: column;
    }

    #chatsView>div>div:first-child {
        width: 100% !important;
        height: 150px;
        border-right: none !important;
        border-bottom: 1px solid var(--border);
    }

    .comments-section>div {
        flex-direction: column;
        gap: 10px;
    }

    .comments-section input {
        width: 100%;
    }

    .comments-section button {
        width: 100% !important;
    }

    /* Modal adjustments for small screens */
    .modal-content {
        padding: 1.2rem;
        width: 95%;
    }
}