/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: #333;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
}

.main-content {
    min-height: calc(100vh - 140px);
    padding: 20px;
}

/* Navbar Styles */
.navbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
}

.nav-brand {
    font-size: 1.5rem;
    font-weight: bold;
    color: #667eea;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    transition: all 0.3s ease;
}

.nav-brand:hover {
    color: #5a6fd8;
    transform: translateY(-1px);
}

.nav-menu {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-link {
    color: #333;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.nav-link:hover {
    background: #667eea;
    color: white;
    transform: translateY(-1px);
}

.nav-user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    color: #666;
    font-size: 0.8rem;
}

.nav-user-info #sessionStatus {
    margin-left: 0.5rem;
    font-size: 0.75rem;
    opacity: 0.7;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    width: 40px;
    height: 40px;
    border-radius: 999px;
    border: none;
    background: rgba(102, 126, 234, 0.1);
    cursor: pointer;
    padding: 0;
}

.nav-toggle-bar {
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: #333;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

/* Logout button specific styling */
.logout-btn {
    background: linear-gradient(135deg, #dc3545, #c82333) !important;
    color: white !important;
    border: 2px solid transparent;
}

.logout-btn:hover {
    background: linear-gradient(135deg, #c82333, #bd2130) !important;
    border-color: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px) !important;
}

/* Dropdown */
.nav-dropdown {
    position: relative;
}

.dropdown-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: inherit;
}

.dropdown-content {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    border-radius: 8px;
    min-width: 160px;
    display: none;
    z-index: 1001;
}

.nav-dropdown:hover .dropdown-content {
    display: block;
}

.dropdown-content a {
    display: block;
    padding: 0.75rem 1rem;
    color: #333;
    text-decoration: none;
    transition: background 0.3s ease;
}

.dropdown-content a:hover {
    background: #f8f9fa;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Cards */
.card {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    padding: 2rem;
    margin-bottom: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.card-header {
    border-bottom: 2px solid #e9ecef;
    padding-bottom: 1rem;
    margin-bottom: 2rem;
}

.card-title {
    color: #667eea;
    font-size: 1.5rem;
    font-weight: bold;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #555;
}

.form-control {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background: rgba(255, 255, 255, 0.9);
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1em;
    padding-right: 2.5rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    justify-content: center;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-outline {
    background: transparent;
    border: 2px solid #667eea;
    color: #667eea;
}

.btn-outline:hover {
    background: #667eea;
    color: white;
}

/* Alerts */
.alert {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid #28a745;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid #dc3545;
}

/* Grid System */
.row {
    display: flex;
    flex-wrap: wrap;
    margin: 0 -10px;
}

.col-1 { flex: 0 0 8.333333%; max-width: 8.333333%; }
.col-2 { flex: 0 0 16.666667%; max-width: 16.666667%; }
.col-3 { flex: 0 0 25%; max-width: 25%; }
.col-4 { flex: 0 0 33.333333%; max-width: 33.333333%; }
.col-6 { flex: 0 0 50%; max-width: 50%; }
.col-8 { flex: 0 0 66.666667%; max-width: 66.666667%; }
.col-12 { flex: 0 0 100%; max-width: 100%; }

.col-1, .col-2, .col-3, .col-4, .col-6, .col-8, .col-12 {
    padding: 0 10px;
}

/* Course Cards */
.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.course-card {
    position: relative;
    background: radial-gradient(circle at top left, rgba(102, 126, 234, 0.2), transparent 55%), rgba(255, 255, 255, 0.96);
    border-radius: 16px;
    padding: 1.5rem 1.5rem 1.25rem;
    box-shadow: 0 10px 30px rgba(15, 35, 95, 0.18);
    transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
    border: 1px solid rgba(255, 255, 255, 0.9);
    overflow: hidden;
}

.course-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 14px 35px rgba(15, 35, 95, 0.28);
    border-color: rgba(102, 126, 234, 0.5);
}

.course-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
    gap: 0.75rem;
}

.course-title {
    color: #667eea;
    font-size: 1.25rem;
    font-weight: bold;
    margin-bottom: 0.25rem;
    line-height: 1.3;
}

.course-description {
    color: #666;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.course-meta {
    font-size: 0.9rem;
    color: #888;
    margin-bottom: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.course-meta-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.course-meta-row i {
    margin-right: 0.25rem;
}

.course-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.course-badge-enrolled {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    padding: 0.15rem 0.6rem;
    border-radius: 999px;
    background: rgba(40, 167, 69, 0.12);
    color: #0f7a2b;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid rgba(40, 167, 69, 0.25);
}

.course-badge-enrolled i {
    font-size: 0.9em;
}

.course-progress {
    margin: 1rem 0;
}

.course-progress-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    font-weight: 600;
}

.public-link-section {
    margin: 1rem 0;
    padding: 1rem;
    border-radius: 12px;
    border-left-width: 4px;
    border-left-style: solid;
}

.public-link-section--enabled {
    background: rgba(40, 167, 69, 0.08);
    border-left-color: #28a745;
}

.public-link-section--disabled {
    background: rgba(255, 193, 7, 0.08);
    border-left-color: #ffc107;
}

.public-link-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.public-link-header i {
    color: inherit;
}

.public-link-section--enabled .public-link-header {
    color: #155724;
}

.public-link-section--disabled .public-link-header {
    color: #856404;
}

.public-link-body {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.public-link-input {
    flex: 1;
    padding: 0.5rem;
    border: 1px solid #c3e6cb;
    border-radius: 8px;
    background: white;
    font-size: 0.9rem;
    font-family: monospace;
    user-select: all;
    cursor: pointer;
}

.public-link-footnote {
    font-size: 0.8rem;
    color: #6c757d;
    margin-top: 0.5rem;
}

.btn-copy {
    padding: 0.5rem 1rem;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    white-space: nowrap;
    min-width: 80px;
}

.btn-copy:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(33, 136, 56, 0.4);
}

.btn-enable-public {
    padding: 0.5rem 1rem;
    background: #ffc107;
    color: #212529;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.btn-enable-public:hover {
    background: #e0a800;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(224, 168, 0, 0.4);
}

/* Leaderboard */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #e9ecef;
}

.leaderboard-table th {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    font-weight: 600;
}

.leaderboard-table tbody tr:hover {
    background: rgba(102, 126, 234, 0.05);
}

.rank-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 999px;
    font-weight: 700;
    color: #fff;
    font-size: 1rem;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    letter-spacing: 0.02em;
}

.rank-1 {
    background: linear-gradient(135deg, #ffd700 0%, #ffa500 100%);
    box-shadow: 0 4px 12px rgba(255, 215, 0, 0.4);
    color: #332600;
}

.rank-2 {
    background: linear-gradient(135deg, #c0c0c0 0%, #808080 100%);
    box-shadow: 0 4px 12px rgba(192, 192, 192, 0.4);
    color: #1f1f1f;
}

.rank-3 {
    background: linear-gradient(135deg, #cd7f32 0%, #8b4513 100%);
    box-shadow: 0 4px 12px rgba(205, 127, 50, 0.4);
}

.rank-default {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.leaderboard-container {
    margin-top: 1rem;
    overflow-x: auto;
    border-radius: 12px;
}

.leaderboard-rank-cell {
    text-align: center;
}

.leaderboard-user-cell {
    min-width: 220px;
}

.leaderboard-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.leaderboard-user-text {
    display: flex;
    flex-direction: column;
}

.leaderboard-user-name {
    font-weight: 600;
    color: #222;
}

.leaderboard-user-email {
    font-size: 0.85rem;
    color: #777;
}

.leaderboard-score-cell {
    text-align: center;
    font-weight: 600;
    color: #667eea;
    font-size: 1.05rem;
}

.leaderboard-time-cell {
    text-align: center;
    font-weight: 600;
    color: #28a745;
}

.leaderboard-course-cell {
    text-align: center;
    font-size: 0.9rem;
    color: #555;
}

.leaderboard-tag {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem 0.75rem;
    border-radius: 999px;
    background: #e9ecef;
    font-size: 0.8rem;
    font-weight: 500;
    color: #495057;
    white-space: nowrap;
}

.leaderboard-tag-soft {
    background: rgba(102, 126, 234, 0.1);
    color: #4c5fd7;
}

.leaderboard-filters {
    margin-bottom: 1.5rem;
}

.leaderboard-filters-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    background: rgba(102, 126, 234, 0.06);
    border: 1px solid rgba(102, 126, 234, 0.15);
}

.leaderboard-filters-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.leaderboard-filter {
    min-width: 220px;
}

.leaderboard-filters-right {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    flex: 1;
}

.leaderboard-meta {
    font-size: 0.85rem;
    color: #555;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
}

.leaderboard-meta-group {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.leaderboard-page-size {
    display: flex;
    flex-direction: column;
    min-width: 130px;
}

.leaderboard-empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: #666;
}

.leaderboard-empty-icon {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    margin: 0 auto 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(102, 126, 234, 0.08);
    color: #667eea;
    font-size: 2.5rem;
}

.leaderboard-empty-cta {
    margin-top: 1.25rem;
}

.leaderboard-pagination {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
}

.leaderboard-pagination-info {
    font-size: 0.85rem;
    color: #666;
}

.leaderboard-pagination-controls {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.pagination-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.9rem;
    border-radius: 999px;
    border: 1px solid rgba(102, 126, 234, 0.4);
    background: white;
    color: #667eea;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.pagination-btn:hover {
    background: rgba(102, 126, 234, 0.08);
}

.pagination-btn.disabled {
    opacity: 0.5;
    cursor: default;
    background: #f1f3f5;
}

.pagination-current {
    min-width: 2rem;
    text-align: center;
    font-weight: 600;
    color: #444;
}

/* File Upload */
.file-upload-area {
    border: 2px dashed #667eea;
    border-radius: 12px;
    padding: 3rem;
    text-align: center;
    background: rgba(102, 126, 234, 0.05);
    transition: all 0.3s ease;
    cursor: pointer;
}

.file-upload-area:hover {
    border-color: #764ba2;
    background: rgba(102, 126, 234, 0.1);
}

.file-upload-area.dragover {
    border-color: #28a745;
    background: rgba(40, 167, 69, 0.1);
}

.upload-icon {
    font-size: 3rem;
    color: #667eea;
    margin-bottom: 1rem;
}

/* Progress Bar */
.progress {
    width: 100%;
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin: 1rem 0;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.3s ease;
}

/* Login/Register Forms */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 140px);
    padding: 2rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    padding: 2.5rem;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.auth-title {
    color: #667eea;
    font-size: 2rem;
    font-weight: bold;
    margin-bottom: 0.5rem;
}

.auth-subtitle {
    color: #666;
    margin-bottom: 2rem;
}

/* Footer */
.footer {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1rem 0;
    margin-top: auto;
}

.footer-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
    text-align: center;
    color: #666;
}

/* Responsive Design */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }
    
    .nav-toggle {
        display: flex;
        align-self: flex-end;
    }

    .nav-menu {
        display: none;
        flex-direction: column;
        width: 100%;
        gap: 0.25rem;
    }

    .nav-menu.is-open {
        display: flex;
    }

    .nav-link,
    .nav-user-info,
    .logout-btn {
        width: 100%;
        justify-content: flex-start;
    }

    .nav-link {
        padding: 0.75rem 1rem;
    }
    
    .course-grid {
        grid-template-columns: 1fr;
    }
    
    .row {
        flex-direction: column;
    }
    
    .col-1, .col-2, .col-3, .col-4, .col-6, .col-8, .col-12 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    .leaderboard-filters-inner {
        flex-direction: column;
        align-items: stretch;
    }

    .leaderboard-filters-left,
    .leaderboard-filters-right {
        width: 100%;
        justify-content: space-between;
    }

    .leaderboard-filter {
        width: 100%;
        min-width: 0;
    }

    .leaderboard-meta {
        justify-content: flex-start;
    }

    .leaderboard-container {
        margin-top: 0.75rem;
    }

    .leaderboard-table {
        font-size: 0.9rem;
        min-width: 600px;
    }
    
    .leaderboard-table th,
    .leaderboard-table td {
        padding: 0.5rem;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 10px;
    }
    
    .card {
        padding: 1rem;
    }
    
    .auth-container {
        padding: 1rem;
    }
    
    .auth-card {
        padding: 1.5rem;
    }
}

/* Animation Classes */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

.slide-up {
    animation: slideUp 0.5s ease-out;
}

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