/* Modern Design System */
:root {
    --primary: #3ba984;
    --primary-light: #e6f4ee;
    --secondary: #3b82f6;
    --accent: #319e6b;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --background: #e3f0fa;
    --white: #ffffff;
    --gray-50: #e6f4ee;
    --gray-100: #e3f0fa;
    --gray-200: #b7e4d8;
    --gray-300: #d1fae5;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #25603b;
    --gray-800: #1f2937;
    --gray-900: #111827;

    --shadow-sm: 0 1px 2px 0 rgb(59 168 132 / 0.05);
    --shadow: 0 4px 6px -1px rgb(59 168 132 / 0.1), 0 2px 4px -2px rgb(59 168 132 / 0.1);
    --shadow-md: 0 10px 15px -3px rgb(59 168 132 / 0.1), 0 4px 6px -4px rgb(59 168 132 / 0.1);
    --shadow-lg: 0 20px 25px -5px rgb(59 168 132 / 0.1), 0 8px 10px -6px rgb(59 168 132 / 0.1);

    --radius-sm: 0.375rem;
    --radius: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--background);
    color: var(--gray-800);
    line-height: 1.6;
}

/* Navbar */
.navbar {
    background: linear-gradient(135deg, #3ba984 0%, #3b82f6 100%);
    color: white;
    padding: 1rem 2rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 10px rgba(59,168,132,0.10);
}

.nav-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.nav-content h2 {
    font-size: 1.5rem;
}

.nav-right {
    display: flex;
    gap: 1rem;
    align-items: center;
}

/* Container Layout */
.container {
    display: flex;
    max-width: 1400px;
    margin: 0 auto;
    gap: 2rem;
    padding: 2rem;
}

.sidebar {
    width: 250px;
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    height: fit-content;
    position: sticky;
    top: 100px;
}

.nav-item {
    display: block;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    color: #333;
    text-decoration: none;
    border-radius: 6px;
    transition: all 0.3s ease;
    border-left: 3px solid transparent;
}

.nav-item:hover {
    background-color: #f0f0f0;
    border-left-color: #667eea;
}

.nav-item.active {
    background-color: #f0f0f0;
    border-left-color: #667eea;
    color: #667eea;
    font-weight: 600;
}

.main-content {
    flex: 1;
    background: white;
    padding: 2rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.main-content.full-width {
    width: 100%;
    margin-left: 0;
}

h1 {
    margin-bottom: 1.5rem;
    color: #333;
    font-size: 2rem;
}

h2 {
    margin-bottom: 1rem;
    color: #333;
    font-size: 1.5rem;
}

h3 {
    color: #555;
    margin-bottom: 0.75rem;
}

/* Login Page */
.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: radial-gradient(circle at top left, var(--gradient-1), transparent),
        radial-gradient(circle at bottom right, var(--gradient-2), transparent),
        var(--primary);
    background-attachment: fixed;
}

:root {
    --gradient-1: rgba(99, 102, 241, 0.8);
    --gradient-2: rgba(139, 92, 246, 0.8);
}

.login-box {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 3.5rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 450px;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.login-box h1 {
    text-align: center;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
    font-size: 2.25rem;
    font-weight: 800;
    letter-spacing: -0.025em;
}

.login-box p {
    text-align: center;
    color: var(--gray-600);
    margin-bottom: 2.5rem;
    font-size: 1rem;
}

/* Forms */
.form-group {
    margin-bottom: 1.5rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: #333;
    font-weight: 600;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="datetime-local"]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

textarea {
    resize: vertical;
    font-family: 'Courier New', monospace;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background-color: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    font-size: 1rem;
    transition: all 0.3s ease;
    text-align: center;
}

.btn:hover {
    background-color: #5568d3;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-primary {
    background-color: #667eea;
}

.btn-primary:hover {
    background-color: #5568d3;
}

/* Error and Success Messages */
.error-message {
    background-color: #f8d7da;
    color: #721c24;
    padding: 0.75rem 1.25rem;
    border-radius: 6px;
    border: 1px solid #f5c6cb;
    margin-bottom: 1.5rem;
    text-align: center;
}

.success-message {
    background-color: #d4edda;
    color: #155724;
    padding: 0.75rem 1.25rem;
    border-radius: 6px;
    border: 1px solid #c3e6cb;
    margin-bottom: 1.5rem;
    text-align: center;
}

.btn-success {
    background-color: #48bb78;
}

.btn-success:hover {
    background-color: #38a169;
}

.btn-danger {
    background-color: #f56565;
}

.btn-danger:hover {
    background-color: #e53e3e;
}

.btn-small {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-small.btn-success {
    background-color: #48bb78;
}

.btn-small.btn-danger {
    background-color: #f56565;
}

/* Statistics Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 3rem;
}

.stat-card {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
    transition: transform 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-5px);
}

.stat-card h3 {
    color: white;
    margin-bottom: 1rem;
    font-size: 1.1rem;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: bold;
}

/* Tables */
.table-section {
    margin-top: 2rem;
}

.table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    overflow: hidden;
}

.table thead {
    background-color: #667eea;
    color: white;
}

.table th {
    padding: 1rem;
    text-align: left;
    font-weight: 600;
}

.table td {
    padding: 1rem;
    border-bottom: 1px solid #eee;
}

.table tbody tr:hover {
    background-color: #f9f9f9;
}

.table form {
    display: inline;
}

/* Forms Section */
.form-section {
    background-color: #f9f9f9;
    padding: 2rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

.form {
    max-width: 600px;
}

.form-group label {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

/* Alert Messages */
.alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: 6px;
    background-color: #c6f6d5;
    color: #22543d;
    border: 1px solid #9ae6b4;
}

.alert.error {
    background-color: #fed7d7;
    color: #742a2a;
    border: 1px solid #fc8181;
}

/* Exam Taking Styles */
.exam-container {
    max-width: 800px;
}

.timer {
    background-color: #fff5f5;
    border: 2px solid #f56565;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    text-align: center;
}

.timer h3 {
    color: #f56565;
    margin: 0;
}

.timer #timer {
    font-size: 2rem;
    font-weight: bold;
    color: #e53e3e;
}

.question-block {
    background-color: #f9f9f9;
    padding: 1.5rem;
    margin-bottom: 2rem;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.question-block h3 {
    color: #333;
    margin-bottom: 1rem;
}

.question-block p {
    margin-bottom: 1rem;
    line-height: 1.8;
}

.options {
    margin-top: 1rem;
}

.option {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.option:hover {
    background-color: #f0f0f0;
    border-color: #667eea;
}

.option input[type="radio"] {
    margin-right: 1rem;
    cursor: pointer;
}

.option span {
    background-color: #667eea;
    color: white;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.75rem;
    font-weight: bold;
    font-size: 0.875rem;
}

.answer-input {
    margin-top: 1rem;
}

.answer-input textarea {
    width: 100%;
}

/* Result Styles */
.result-summary {
    text-align: center;
    margin-bottom: 3rem;
}

.result-card {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin-top: 2rem;
    flex-wrap: wrap;
}

.result-score {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem 3rem;
    border-radius: 12px;
    text-align: center;
    min-width: 250px;
}

.result-score h2 {
    color: white;
    font-size: 3rem;
    margin-bottom: 0.5rem;
}

.result-status {
    font-size: 1.5rem;
    font-weight: bold;
    margin-top: 0.5rem;
}

.result-status.passed {
    color: #48bb78;
}

.result-status.failed {
    color: #f56565;
}

.result-details {
    padding: 2rem;
    background-color: #f9f9f9;
    border-radius: 8px;
}

.result-details p {
    margin-bottom: 1rem;
}

.answer-review {
    margin-top: 3rem;
}

.answer-block {
    background-color: #f9f9f9;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border-radius: 8px;
    border-left: 4px solid #667eea;
}

.answer-block h3 {
    color: #333;
    margin-bottom: 1rem;
}

.mcq-review {
    margin-top: 1rem;
}

.options-review {
    background: white;
    padding: 1.5rem;
    border-radius: 6px;
    margin-top: 1rem;
    border: 1px solid #ddd;
}

.options-review p {
    font-weight: 600;
    margin-bottom: 1rem;
    color: #333;
}

.option-item {
    display: flex;
    align-items: center;
    padding: 0.75rem;
    margin-bottom: 0.75rem;
    border: 2px solid #ddd;
    border-radius: 6px;
    background: white;
    transition: all 0.3s ease;
}

.option-item.correct-answer {
    border-color: #48bb78;
    background-color: #f0fdf4;
}

.option-letter {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    min-width: 32px;
    background-color: #667eea;
    color: white;
    border-radius: 50%;
    margin-right: 1rem;
    font-weight: bold;
}

.option-item.correct-answer .option-letter {
    background-color: #48bb78;
}

.option-content {
    flex: 1;
    color: #333;
}

.correct-badge {
    display: inline-block;
    background-color: #48bb78;
    color: white;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.85rem;
    margin-left: 0.5rem;
}

.short-answer-text {
    background: white;
    padding: 1rem;
    border-left: 3px solid #667eea;
    margin: 1rem 0;
    border-radius: 4px;
}

.answer-status {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.875rem;
}

.answer-status.correct {
    background-color: #c6f6d5;
    color: #22543d;
}

.answer-status.incorrect {
    background-color: #fed7d7;
    color: #742a2a;
}

.answer-status.pending {
    background-color: #feebc8;
    color: #7c2d12;
}

.action-buttons {
    text-align: center;
    margin-top: 2rem;
}

.action-buttons .btn {
    margin: 0 0.5rem;
}

/* Test Credentials Box */
.test-credentials {
    background-color: #f9f9f9;
    padding: 1.5rem;
    border-radius: 8px;
    margin-top: 1.5rem;
    border-left: 4px solid #667eea;
}

.test-credentials h3 {
    color: #333;
    margin-bottom: 1rem;
}

.test-credentials p {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: #555;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        flex-direction: column;
        padding: 1rem;
    }

    .sidebar {
        width: 100%;
        position: relative;
        top: 0;
        display: flex;
        gap: 0.5rem;
        overflow-x: auto;
        padding: 0.5rem;
    }

    .nav-item {
        white-space: nowrap;
        flex: 1;
    }

    .main-content {
        padding: 1rem;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .table {
        font-size: 0.875rem;
    }

    .table th,
    .table td {
        padding: 0.5rem;
    }

    .nav-content {
        flex-direction: column;
        gap: 1rem;
    }

    .nav-right {
        flex-direction: column;
        width: 100%;
    }

    .login-box {
        padding: 2rem;
    }

    .result-card {
        flex-direction: column;
        align-items: center;
    }
}

/* Results Grid Styling */
.results-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 2rem;
}

.result-card-item {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    border-left: 5px solid #667eea;
}

.result-card-item:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transform: translateY(-2px);
}

.result-card-item.passed {
    border-left-color: #11998e;
    background: linear-gradient(135deg, rgba(17, 153, 142, 0.05) 0%, rgba(56, 239, 125, 0.05) 100%);
}

.result-card-item.failed {
    border-left-color: #ee0979;
    background: linear-gradient(135deg, rgba(238, 9, 121, 0.05) 0%, rgba(255, 106, 0, 0.05) 100%);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
    gap: 1rem;
}

.result-header h3 {
    margin: 0;
    color: #333;
    flex: 1;
    font-size: 1.1rem;
}

.status-badge {
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
    text-transform: uppercase;
}

.status-badge.passed {
    background-color: #d4edda;
    color: #155724;
}

.status-badge.failed {
    background-color: #f8d7da;
    color: #721c24;
}

.subject-name {
    color: #666;
    font-size: 0.9rem;
    margin: 0.5rem 0 1rem 0;
}

.result-score-display {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    padding: 1rem;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 6px;
    margin-bottom: 1rem;
    text-align: center;
}

.score,
.marks {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-value,
.marks-value {
    font-size: 1.8rem;
    font-weight: bold;
    color: #667eea;
}

.score-label,
.marks-label {
    font-size: 0.8rem;
    color: #666;
    margin-top: 0.25rem;
}

.result-action {
    display: flex;
    gap: 0.5rem;
}

.btn-view {
    flex: 1;
    background-color: #667eea;
    color: white;
    padding: 0.6rem 1rem;
    border: none;
    border-radius: 6px;
    text-decoration: none;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    text-align: center;
}

.btn-view:hover {
    background-color: #5568d3;
    transform: translateY(-2px);
}

/* Additional styling for exam result view */
.full-width {
    width: 100%;
}

/* Global fixed logout button (placed top-right across site pages) */
a[href$="logout.php"] {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 3000;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.85rem;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--primary) 0%, #14b8a6 100%);
    color: #fff;
    text-decoration: none;
    font-weight: 700;
    box-shadow: 0 8px 26px rgba(0,0,0,0.12);
}

/* Hide top-bar logout duplicates on wide layouts */
.nav-right a[href$="logout.php"], .nav-right .btn[href$="logout.php"] {
    display: none !important;
}

@media (max-width: 1024px) {
    a[href$="logout.php"] {
        position: static;
        top: auto;
        right: auto;
        box-shadow: none;
        margin-left: 0.5rem;
    }
    .nav-right a[href$="logout.php"], .nav-right .btn[href$="logout.php"] {
        display: inline-flex !important;
    }
}

/* mobile navigation toggle + overlay */
.hamburger {
    display: none;              /* shown only on small screens */
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--primary);
    cursor: pointer;
    padding: 0.25rem;
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.4);
    z-index: 999;
}

@media (max-width: 768px) {
    .hamburger {
        display: inline-block;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: -260px;
        height: 100%;
        width: 240px;
        max-width: 80%;
        transition: left 0.3s ease;
        z-index: 1000;
    }

    .sidebar.open {
        left: 0;
    }

    .sidebar.open + .sidebar-overlay,
    .sidebar-overlay.open {
        display: block;
    }
}