/**
 * Exam Application Stylesheet
 * Mobile-First Design
 */

:root {
    /* Primary Colors */
    --blue: #2c7fd6;
    --blue-dark: #2365aa;
    --blue-darker: #1a4a7a;
    
    /* Grey Scale */
    --grey-side: #b3b3b3;
    --grey-header: #e5e5e5;
    --grey-answer: #f7f7f7;
    --grey-bottom: #f3f3f3;
    --grey-page: #dedede;
    --grey-page-active: #a8a8a8;
    --grey-light: #f8f9fa;
    --grey-border: #d9d9d9;
    
    /* Text Colors */
    --text-main: #555555;
    --text-muted: #888888;
    --text-dark: #333333;
    --text-light: #ffffff;
    
    /* Status Colors */
    --success: #28a745;
    --danger: #dc3545;
    --warning: #ffc107;
    --info: #17a2b8;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.12);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.15);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.2);
    
    /* Border Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    /* Transitions */
    --transition: all 0.3s ease;
}

/* Reset & Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, 'Roboto', sans-serif;
    background: #e3e7ee;
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
}

a {
    color: var(--blue);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--blue-dark);
}

img {
    max-width: 100%;
    height: auto;
}

/* =====================================================
   UTILITY CLASSES
   ===================================================== */

.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

.text-center { text-align: center; }
.text-right { text-align: right; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-muted { color: var(--text-muted); }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }

.hidden { display: none !important; }

/* =====================================================
   BUTTONS
   ===================================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    gap: 8px;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--blue);
    color: var(--text-light);
}

.btn-primary:hover:not(:disabled) {
    background: var(--blue-dark);
    color: var(--text-light);
}

.btn-secondary {
    background: var(--grey-side);
    color: var(--text-light);
}

.btn-secondary:hover:not(:disabled) {
    background: #999;
    color: var(--text-light);
}

.btn-success {
    background: var(--success);
    color: var(--text-light);
}

.btn-success:hover:not(:disabled) {
    background: #218838;
}

.btn-danger {
    background: var(--danger);
    color: var(--text-light);
}

.btn-danger:hover:not(:disabled) {
    background: #c82333;
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 12px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 16px;
}

/* =====================================================
   FORMS
   ===================================================== */

.form-group {
    margin-bottom: 1rem;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-dark);
}

.form-control {
    display: block;
    width: 100%;
    padding: 12px 16px;
    font-size: 16px;
    border: 2px solid var(--grey-border);
    border-radius: var(--radius-sm);
    background: #fff;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--blue);
    box-shadow: 0 0 0 3px rgba(44, 127, 214, 0.15);
}

.form-control.is-invalid {
    border-color: var(--danger);
}

.invalid-feedback {
    color: var(--danger);
    font-size: 13px;
    margin-top: 4px;
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

select.form-control {
    appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23555' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 12px center;
    background-size: 16px;
    padding-right: 40px;
}

.form-check {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0.5rem;
}

.form-check-input {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* =====================================================
   CARDS
   ===================================================== */

.card {
    background: #fff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    padding: 16px 20px;
    background: var(--grey-light);
    border-bottom: 1px solid var(--grey-border);
    font-weight: 600;
}

.card-body {
    padding: 20px;
}

.card-footer {
    padding: 16px 20px;
    background: var(--grey-light);
    border-top: 1px solid var(--grey-border);
}

/* =====================================================
   ALERTS
   ===================================================== */

.alert {
    padding: 12px 20px;
    border-radius: var(--radius-sm);
    margin-bottom: 1rem;
    font-weight: 500;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-danger {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-warning {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* =====================================================
   TABLES
   ===================================================== */

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--grey-border);
}

.table th {
    background: var(--grey-light);
    font-weight: 600;
    white-space: nowrap;
}

.table tbody tr:hover {
    background: var(--grey-light);
}

/* =====================================================
   AUTH PAGES (Login/Register)
   ===================================================== */

.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
}

.auth-card {
    width: 100%;
    max-width: 420px;
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.auth-header {
    padding: 30px 30px 20px;
    text-align: center;
    background: #fff;
}

.auth-logo {
    width: 80px;
    height: 80px;
    background: var(--blue);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    color: #fff;
    font-size: 32px;
    font-weight: bold;
}

.auth-title {
    font-size: 24px;
    color: var(--text-dark);
    margin-bottom: 8px;
}

.auth-subtitle {
    color: var(--text-muted);
    font-size: 14px;
}

.auth-body {
    padding: 20px 30px 30px;
}

.auth-footer {
    text-align: center;
    padding: 20px;
    background: var(--grey-light);
    font-size: 14px;
}

/* =====================================================
   DASHBOARD
   ===================================================== */

.dashboard-header {
    background: var(--blue);
    color: #fff;
    padding: 20px 0;
    margin-bottom: 30px;
}

.dashboard-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 15px;
}

.dashboard-logo {
    font-size: 20px;
    font-weight: 700;
    color: #fff;
}

.dashboard-user {
    display: flex;
    align-items: center;
    gap: 15px;
}

.dashboard-user span {
    font-weight: 500;
}

.exam-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.exam-card {
    background: #fff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
    transition: var(--transition);
}

.exam-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
}

.exam-card-header {
    padding: 20px;
    background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
    color: #fff;
}

.exam-card-title {
    font-size: 18px;
    margin-bottom: 8px;
}

.exam-card-meta {
    font-size: 13px;
    opacity: 0.9;
    display: flex;
    gap: 15px;
}

.exam-card-body {
    padding: 20px;
}

.exam-card-desc {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 15px;
}

/* =====================================================
   EXAM PAGE
   ===================================================== */

.exam-wrapper {
    max-width: 100%;
    margin: 0 auto;
    border: 6px solid var(--blue);
    background: #ffffff;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Top Bar */
.top-bar {
    display: flex;
    min-height: 70px;
    background: var(--grey-header);
}

.top-bar__side {
    min-width: 70px;
    padding: 10px;
    background: var(--grey-side);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    flex-shrink: 0;
}

.top-bar__side.timer {
    font-family: 'Courier New', monospace;
    font-size: 16px;
}

.top-bar__side.timer.warning {
    background: var(--warning);
    color: var(--text-dark);
    animation: pulse 1s infinite;
}

.top-bar__side.timer.danger {
    background: var(--danger);
    animation: pulse 0.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

.top-bar__question {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 15px 20px;
    text-align: center;
    font-size: 16px;
    line-height: 1.4;
    color: var(--text-main);
    background: var(--grey-header);
}

/* Content Area */
.content {
    flex: 1;
    padding: 20px 15px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
}

.question-image {
    width: 100%;
    max-width: 500px;
    margin: 0 auto 20px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
}

.answer {
    background: var(--grey-answer);
    padding: 16px 20px;
    margin-bottom: 12px;
    font-size: 15px;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    gap: 12px;
}

.answer:hover {
    background: #e8e8e8;
}

.answer.selected {
    background: var(--blue);
    color: #fff;
    border-color: var(--blue-dark);
}

.answer-radio {
    width: 20px;
    height: 20px;
    border: 2px solid var(--grey-side);
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.answer.selected .answer-radio {
    border-color: #fff;
    background: #fff;
}

.answer.selected .answer-radio::after {
    content: '';
    width: 10px;
    height: 10px;
    background: var(--blue);
    border-radius: 50%;
}

/* Bottom Bar */
.bottom-bar {
    display: flex;
    min-height: 60px;
    border-top: 1px solid var(--grey-border);
    background: var(--grey-bottom);
}

.bottom-bar__mark {
    min-width: 100px;
    padding: 10px 15px;
    background: var(--blue);
    color: #ffffff;
    font-weight: 600;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.bottom-bar__mark:hover {
    background: var(--blue-dark);
}

.bottom-bar__mark.marked {
    background: var(--blue-dark);
}

.bottom-bar__pages {
    flex: 1;
    display: flex;
    overflow-x: auto;
    background: var(--grey-bottom);
    scrollbar-width: thin;
    -webkit-overflow-scrolling: touch;
}

.bottom-bar__pages::-webkit-scrollbar {
    height: 6px;
}

.bottom-bar__pages::-webkit-scrollbar-track {
    background: #f0f0f0;
}

.bottom-bar__pages::-webkit-scrollbar-thumb {
    background: #a0a0a0;
    border-radius: 3px;
}

.page {
    min-width: 50px;
    border-left: 1px solid var(--grey-border);
    background: var(--grey-page);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.page:last-child {
    border-right: 1px solid var(--grey-border);
}

.page:hover {
    background: #ccc;
}

.page.active {
    background: var(--grey-page-active);
    color: #ffffff;
    font-weight: 600;
}

.page.answered {
    background: var(--success);
    color: #fff;
}

.page.marked {
    background: var(--blue-dark);
    color: #fff;
}

.bottom-bar__next {
    min-width: 100px;
    padding: 10px 15px;
    background: var(--grey-side);
    color: #ffffff;
    font-weight: 600;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-transform: uppercase;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.bottom-bar__next:not(.disabled):hover {
    background: #999;
}

.bottom-bar__next.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* =====================================================
   RESULT PAGE
   ===================================================== */

.result-wrapper {
    min-height: 100vh;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-card {
    width: 100%;
    max-width: 600px;
    background: #fff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.result-header {
    padding: 30px;
    text-align: center;
    color: #fff;
}

.result-header.passed {
    background: linear-gradient(135deg, var(--info) 0%, #15458b 100%);
}

.result-header.failed {
    background: linear-gradient(135deg, var(--danger) 0%, #a71d2a 100%);
}

.result-score {
    font-size: 64px;
    font-weight: 700;
    margin-bottom: 10px;
}

.result-status {
    font-size: 24px;
    font-weight: 600;
}

.result-body {
    padding: 30px;
}

.category-score {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid var(--grey-border);
}

.category-score:last-child {
    border-bottom: none;
}

.category-name {
    font-weight: 600;
    color: var(--text-dark);
}

.category-value {
    font-weight: 700;
    color: var(--blue);
}

.result-footer {
    padding: 20px 30px;
    background: var(--grey-light);
    text-align: center;
}

/* =====================================================
   ADMIN PANEL
   ===================================================== */

.admin-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: 250px;
    background: var(--blue-darker);
    color: #fff;
    z-index: 1000;
    transform: translateX(-100%);
    transition: var(--transition);
}

.admin-sidebar.open {
    transform: translateX(0);
}

.admin-sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.admin-sidebar-brand {
    font-size: 18px;
    font-weight: 700;
}

.admin-sidebar-nav {
    padding: 20px 0;
}

.admin-nav-item {
    display: block;
    padding: 12px 20px;
    color: rgba(255,255,255,0.8);
    transition: var(--transition);
}

.admin-nav-item:hover,
.admin-nav-item.active {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

.admin-content {
    padding: 20px;
    min-height: 100vh;
    background: var(--grey-light);
}

.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--grey-border);
    flex-wrap: wrap;
    gap: 15px;
}

.admin-title {
    font-size: 24px;
    color: var(--text-dark);
}

.menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--blue);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 20px;
}

.admin-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
}

.admin-overlay.show {
    display: block;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0,0,0,0.5);
}

.modal.show {
    display: flex;
}

.modal-content {
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    background: #fff;
    border-radius: var(--radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 15px 20px;
    background: var(--blue);
    color: #fff;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.modal-footer {
    padding: 15px 20px;
    background: var(--grey-light);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

/* Status Badge */
.badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 20px;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-danger {
    background: #f8d7da;
    color: #721c24;
}

/* Switch Toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 26px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #ccc;
    border-radius: 26px;
    transition: var(--transition);
}

.slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
}

input:checked + .slider {
    background: var(--success);
}

input:checked + .slider:before {
    transform: translateX(24px);
}

/* =====================================================
   RESPONSIVE DESIGN
   ===================================================== */

/* Small devices (landscape phones) */
@media (min-width: 576px) {
    .top-bar__side {
        min-width: 80px;
        font-size: 15px;
    }
    
    .top-bar__question {
        font-size: 17px;
        padding: 15px 30px;
    }
    
    .page {
        min-width: 60px;
    }
    
    .bottom-bar__mark,
    .bottom-bar__next {
        min-width: 120px;
        font-size: 13px;
    }
}

/* Medium devices (tablets) */
@media (min-width: 768px) {
    .exam-wrapper {
        max-width: 1200px;
        min-height: 500px;
        margin: 20px auto;
        border-radius: var(--radius-md);
    }
    
    .top-bar {
        min-height: 80px;
    }
    
    .top-bar__side {
        min-width: 90px;
        font-size: 16px;
    }
    
    .top-bar__question {
        font-size: 18px;
        padding: 15px 40px;
    }
    
    .content {
        padding: 30px 25px;
    }
    
    .answer {
        font-size: 16px;
        padding: 18px 24px;
    }
    
    .bottom-bar {
        min-height: 70px;
    }
    
    .page {
        min-width: 70px;
        font-size: 15px;
    }
    
    .bottom-bar__mark,
    .bottom-bar__next {
        min-width: 150px;
        font-size: 14px;
    }
    
    .admin-sidebar {
        transform: translateX(0);
    }
    
    .admin-content {
        margin-left: 250px;
        padding: 30px;
    }
    
    .menu-toggle {
        display: none;
    }
    
    .admin-overlay {
        display: none !important;
    }
}

/* Large devices (desktops) */
@media (min-width: 992px) {
    .top-bar__question {
        font-size: 20px;
        padding: 15px 60px;
    }
    
    .page {
        min-width: 80px;
        font-size: 16px;
    }
}

/* Extra large devices */
@media (min-width: 1200px) {
    .admin-content {
        padding: 40px;
    }
}

/* Touch device optimizations */
@media (hover: none) {
    .answer:hover {
        background: var(--grey-answer);
    }
    
    .answer.selected:hover {
        background: var(--blue);
    }
}

/* Print styles */
@media print {
    .bottom-bar,
    .btn {
        display: none;
    }
}