/* Base Reset & Variables */
:root {
    --bg-gradient: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --glass-bg: rgba(255, 255, 255, 0.05);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --danger: #ef4444;
    --danger-hover: #dc2626;
    --font-family: 'Outfit', 'Inter', sans-serif;
}

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

body {
    font-family: var(--font-family);
    background: var(--bg-gradient);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* Glassmorphism Utilities */
.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: 16px;
}

/* Typography */
h1, h2, h3, h4 {
    color: #fff;
    margin-bottom: 1rem;
}

a {
    color: var(--accent);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: #60a5fa;
}

/* Buttons */
button, .btn-primary, .btn-secondary, .btn-danger {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s ease, background 0.3s ease, box-shadow 0.3s ease;
    display: inline-block;
    text-align: center;
}

button:active {
    transform: scale(0.95);
}

.btn-primary {
    background: var(--accent);
    color: #fff;
    box-shadow: 0 4px 14px 0 rgba(59, 130, 246, 0.39);
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 6px 20px 0 rgba(59, 130, 246, 0.23);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

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

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

.btn-small {
    padding: 6px 12px;
    font-size: 0.85rem;
}

.icon-btn {
    background: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    padding: 0 5px;
    border: none;
    cursor: pointer;
}
.icon-btn:hover {
    color: #fff;
}
.text-danger:hover {
    color: var(--danger);
}

/* Forms */
input[type="text"],
input[type="password"],
input[type="file"] {
    width: 100%;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: rgba(0,0,0,0.2);
    color: #fff;
    margin-bottom: 1rem;
    font-family: inherit;
    transition: border-color 0.3s ease;
}

input:focus {
    outline: none;
    border-color: var(--accent);
}

/* Admin Login */
.login-container {
    max-width: 400px;
    margin: 10vh auto;
    padding: 2rem;
    text-align: center;
}

.error-msg {
    color: #fca5a5;
    background: rgba(239, 68, 68, 0.2);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 1rem;
}

/* Admin Dashboard */
.admin-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    margin-bottom: 2rem;
    border-radius: 0 0 16px 16px;
}

.admin-nav .nav-brand {
    font-size: 1.5rem;
    font-weight: 800;
}

.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 2rem;
}

.card {
    padding: 2rem;
    margin-bottom: 2rem;
}

.inline-form {
    display: flex;
    gap: 1rem;
}
.inline-form input {
    margin-bottom: 0;
    flex-grow: 1;
}

.projects-list {
    display: flex;
    flex-direction: column;
    gap: 2rem;
    padding-bottom: 4rem;
}

.project-card {
    padding: 2rem;
}

.project-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 1rem;
    margin-bottom: 1.5rem;
}

.editable-item h3 {
    margin-bottom: 0;
}

.project-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.project-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

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

.manage-section {
    background: rgba(0,0,0,0.1);
    padding: 1.5rem;
    border-radius: 12px;
}

ul {
    list-style: none;
}

.file-list li, .question-list li {
    padding: 0.75rem 0;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.display-element {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
}

.item-actions {
    display: flex;
    gap: 0.2rem;
}

.file-display .date {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-left: auto;
    margin-right: 1rem;
}

.upload-form, .question-form {
    margin-top: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.edit-form {
    display: flex;
    gap: 0.5rem;
    width: 100%;
    align-items: center;
}
.edit-form input {
    margin-bottom: 0;
    flex-grow: 1;
    padding: 8px 12px;
}

/* Home Page */
.home-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
}

.home-header {
    text-align: center;
    padding: 3rem 1rem;
    margin-bottom: 3rem;
}

.projects-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 2rem;
}

.project-card-link {
    display: block;
    color: inherit;
    text-decoration: none;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.hover-lift:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px rgba(0,0,0,0.5);
    border-color: rgba(255,255,255,0.2);
}

.card-content {
    padding: 2rem;
}
.card-content h2 {
    margin-bottom: 0.5rem;
}
.card-content .file-count {
    display: inline-block;
    background: rgba(255,255,255,0.1);
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    margin-bottom: 1rem;
}
.card-content .latest-update {
    color: var(--text-secondary);
    font-size: 0.9rem;
}

/* Project Viewer */
.viewer-body {
    overflow: hidden;
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 300px;
    height: 100vh;
    flex-shrink: 0;
    border-radius: 0;
    border-right: 1px solid var(--glass-border);
    border-top: none;
    border-bottom: none;
    border-left: none;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 100;
}

.sidebar.closed {
    transform: translateX(-100%);
    position: absolute;
}

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

.version-list {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
}

.version-list li a {
    display: block;
    padding: 10px 15px;
    border-radius: 8px;
    color: var(--text-primary);
    margin-bottom: 5px;
    transition: background 0.2s;
}

.version-list li a:hover {
    background: rgba(255,255,255,0.1);
}

.version-list li a.active {
    background: var(--accent);
    font-weight: 600;
}

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

.open-sidebar-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 90;
    display: none;
    padding: 10px 15px;
    font-size: 1rem;
}

.main-content {
    flex-grow: 1;
    position: relative;
    height: 100vh;
}

.html-iframe {
    width: 100%;
    height: 100%;
    background: #fff;
}

/* Question Bubble */
.question-bubble-container {
    position: absolute;
    bottom: 30px;
    right: 30px;
    width: 350px;
    z-index: 200;
    animation: slideUp 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.bubble-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    border-radius: 16px 16px 0 0;
    background: var(--accent);
    border: none;
}
.bubble-header h3 {
    margin: 0;
    font-size: 1.1rem;
}
.bubble-header .icon-btn {
    color: #fff;
}

.bubble-content {
    border-radius: 0 0 16px 16px;
    padding: 1.5rem;
    max-height: 400px;
    overflow-y: auto;
    background: rgba(15, 23, 42, 0.95); /* Dark solid background for visibility over white iframe */
    color: #fff;
    border: 1px solid rgba(255,255,255,0.1);
    border-top: none;
}

.questions li {
    background: rgba(255,255,255,0.1);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 10px;
    font-size: 0.95rem;
    position: relative;
    color: #fff;
}
.questions li::before {
    content: "Q:";
    font-weight: bold;
    color: var(--accent);
    margin-right: 5px;
}

.open-bubble-btn {
    position: absolute;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 199;
    background: var(--accent);
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.5);
    border: none;
    transition: transform 0.3s ease;
}
.open-bubble-btn:hover {
    transform: scale(1.1);
}

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

@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        z-index: 999;
        background: var(--bg-gradient);
    }
    .question-bubble-container {
        width: 300px;
        right: 15px;
        bottom: 15px;
    }
    .open-bubble-btn {
        right: 15px;
        bottom: 15px;
    }
}
