/* Common Styles for ServiceNow JavaScript Exam Guide */

:root {
    --primary-color: #0066cc;
    --success-color: #2fb344;
    --info-color: #4299e1;
    --warning-color: #f59f00;
    --danger-color: #d63939;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, San Francisco, Segoe UI, Roboto, Helvetica Neue, sans-serif;
    background-color: #f4f6fa;
}

/* Code Editor Styles */
.code-editor {
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    margin: 1rem 0;
    background: #1e1e1e;
}

.code-editor-header {
    background: #2d2d2d;
    color: #fff;
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.code-editor-body {
    background: #1e1e1e;
    color: #d4d4d4;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.6;
    padding: 1.5rem;
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}

.code-editor-body pre {
    margin: 0;
    color: #d4d4d4;
    white-space: pre;
    word-wrap: normal;
    overflow-wrap: normal;
}

/* Syntax Highlighting */
.keyword { color: #569cd6; font-weight: 500; }
.string { color: #ce9178; }
.comment { color: #6a9955; font-style: italic; }
.function { color: #dcdcaa; }
.number { color: #b5cea8; }
.operator { color: #d4d4d4; }
.variable { color: #9cdcfe; }
.property { color: #9cdcfe; }
.punctuation { color: #d4d4d4; }

/* Question Card Styles */
.question-card {
    margin-bottom: 1.5rem;
    border-left: 4px solid var(--primary-color);
    transition: all 0.3s ease;
    overflow: visible;
    display: block;
    width: 100%;
}

.question-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    transform: translateY(-2px);
}

.question-header {
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
    padding: 1rem 1.5rem;
    font-weight: 600;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    min-height: 60px;
}

/* Fix question text display and prevent extreme shrinking */
.question-header > span:first-child {
    flex: 1 1 auto;
    min-width: 280px;
    white-space: normal;
    overflow-wrap: break-word;
    word-break: normal;
    line-height: 1.5;
    padding-right: 1rem;
}

.question-number {
    background: var(--primary-color);
    color: white;
    padding: 0.35rem 0.85rem;
    border-radius: 16px;
    font-size: 0.875rem;
    font-weight: 700;
    flex-shrink: 0;
    white-space: nowrap;
}

.card-body {
    padding: 1.5rem;
}

.options-list {
    list-style: none;
    padding: 0;
    margin: 1rem 0;
}

.options-list li {
    padding: 0.875rem 1.25rem;
    margin: 0.75rem 0;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: white;
    line-height: 1.6;
}

.options-list li:hover {
    border-color: var(--primary-color);
    background: #f0f7ff;
    transform: translateX(4px);
}

.options-list li.correct {
    border-color: var(--success-color);
    background: #e6f4ea;
}

.options-list li.incorrect {
    border-color: var(--danger-color);
    background: #fce8e8;
}

.answer-section {
    background: #e6f4ea;
    border-left: 4px solid var(--success-color);
    padding: 1.25rem 1.5rem;
    margin-top: 1.5rem;
    border-radius: 8px;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        max-height: 0;
        padding-top: 0;
        padding-bottom: 0;
    }
    to {
        opacity: 1;
        max-height: 500px;
    }
}

.answer-section.show {
    display: block;
}

.answer-section.hide {
    display: none;
}

.explanation {
    margin-top: 0.75rem;
    color: #2d3748;
    line-height: 1.7;
    font-size: 0.95rem;
}

.answer-section strong {
    display: block;
    color: #047857;
    font-size: 1.05rem;
    margin-bottom: 0.75rem;
}

/* Exam Badge */
.exam-badge {
    display: inline-block;
    padding: 0.35rem 0.85rem;
    border-radius: 16px;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 1rem;
}

.exam-badge.csa {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

.exam-badge.cad {
    background: #f3e8ff;
    color: #6b21a8;
    border: 1px solid #d8b4fe;
}

/* Toggle Answer Button */
.toggle-answer {
    cursor: pointer;
    color: var(--primary-color);
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.2s ease;
    padding: 0.5rem 0;
    margin-top: 0.5rem;
    font-size: 0.95rem;
}

.toggle-answer:hover {
    color: #004999;
    gap: 0.75rem;
}

.toggle-answer i {
    transition: transform 0.2s ease;
}

.toggle-answer:hover i {
    transform: scale(1.1);
}

/* Topic Navigation */
.topic-nav {
    position: sticky;
    top: 20px;
}

.topic-nav .list-group-item {
    border-left: 3px solid transparent;
    transition: all 0.2s ease;
}

.topic-nav .list-group-item:hover {
    border-left-color: var(--primary-color);
    background: #f8f9fa;
}

/* Best Practices Box */
.best-practice {
    background: #fffbeb;
    border-left: 4px solid var(--warning-color);
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.best-practice-title {
    font-weight: 700;
    color: #92400e;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
}

.best-practice p {
    margin: 0;
    color: #78350f;
    line-height: 1.6;
}

/* Note Box */
.note-box {
    background: #dbeafe;
    border-left: 4px solid var(--info-color);
    padding: 1.25rem 1.5rem;
    margin: 1.5rem 0;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.note-box-title {
    font-weight: 700;
    color: #1e40af;
    margin-bottom: 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
}

.note-box p {
    margin: 0;
    color: #1e3a8a;
    line-height: 1.6;
}

/* Comparison Table */
.comparison-table {
    width: 100%;
    margin: 1.5rem 0;
    border-collapse: separate;
    border-spacing: 0;
    border-radius: 8px;
    overflow: hidden;
}

.comparison-table th {
    background: #f1f5f9;
    font-weight: 700;
    padding: 1rem;
    border: 1px solid #e2e8f0;
    color: #1e293b;
    text-align: left;
}

.comparison-table td {
    padding: 0.875rem 1rem;
    border: 1px solid #e2e8f0;
    background: white;
    vertical-align: top;
}

.comparison-table tbody tr:hover {
    background: #f8fafc;
}

/* Copy Button */
.copy-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff;
    padding: 0.35rem 0.85rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 500;
}

.copy-btn:hover {
    background: rgba(255,255,255,0.15);
    border-color: rgba(255,255,255,0.5);
    transform: translateY(-1px);
}

.copy-btn:active {
    transform: translateY(0);
}

/* Card Improvements */
.card {
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 1.5rem;
    overflow: visible;
}

.card-header {
    border-bottom: 1px solid #e2e8f0;
    background: white;
    padding: 1.25rem 1.5rem;
    border-radius: 12px 12px 0 0;
}

.card-title {
    font-weight: 700;
    font-size: 1.15rem;
    margin: 0;
    color: #1e293b;
}

/* Section Divider */
.section-divider {
    border-top: 2px solid #e2e8f0;
    margin: 3rem 0 2rem 0;
}

/* Responsive Design */
@media (max-width: 992px) {
    .topic-nav {
        position: static;
        margin-top: 2rem;
    }
}

@media (max-width: 768px) {
    .code-editor-body {
        font-size: 12px;
        padding: 1rem;
    }
    
    .question-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }
    
    .question-header > span:first-child {
        padding-right: 0;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .options-list li {
        padding: 0.75rem 1rem;
    }
}

@media (max-width: 576px) {
    .code-editor-header {
        font-size: 0.75rem;
        padding: 0.5rem 0.75rem;
    }
    
    .copy-btn {
        padding: 0.25rem 0.6rem;
        font-size: 0.7rem;
    }
}

/* Print Styles */
@media print {
    .navbar,
    .footer,
    .toggle-answer,
    .copy-btn {
        display: none !important;
    }
    
    .answer-section {
        display: block !important;
        page-break-inside: avoid;
    }
    
    .question-card {
        page-break-inside: avoid;
    }
    
    .code-editor-body {
        max-height: none;
    }
}

/* Smooth Scrolling */
html {
    scroll-behavior: smooth;
}

/* Scrollbar Styling */
.code-editor-body::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.code-editor-body::-webkit-scrollbar-track {
    background: #2d2d2d;
}

.code-editor-body::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

.code-editor-body::-webkit-scrollbar-thumb:hover {
    background: #777;
}

/* List Group Improvements */
.list-group-item {
    transition: all 0.2s ease;
}

.list-group-item:hover {
    background: #f8fafc;
    transform: translateX(2px);
}

/* Small utility classes */
.small {
    font-size: 0.875rem;
}

code {
    background: #f1f5f9;
    padding: 0.2rem 0.4rem;
    border-radius: 4px;
    font-size: 0.875em;
    color: #dc2626;
    font-family: 'Monaco', 'Menlo', monospace;
}

/* Badge improvements */
.badge {
    font-weight: 600;
    padding: 0.35rem 0.75rem;
    border-radius: 12px;
}

/* Button improvements */
.btn {
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.btn:active {
    transform: translateY(0);
}

/* Page header improvements */
.page-title {
    color: #1e293b;
    font-weight: 700;
}

.page-pretitle {
    color: #64748b;
    font-size: 0.875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Footer */
.footer {
    margin-top: 3rem;
    padding: 2rem 0;
    border-top: 1px solid #e2e8f0;
}

/* Loading animation for code highlighting */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.code-editor-body {
    animation: fadeIn 0.3s ease;
}

/* Focus styles for accessibility */
.toggle-answer:focus,
.copy-btn:focus,
.options-list li:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast for better readability */
strong {
    font-weight: 700;
}

/* Navbar improvements */
.navbar-brand {
    font-weight: 700;
    font-size: 1.1rem;
}

.navbar {
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    background: white;
    border-bottom: 1px solid #e2e8f0;
}

/* Ensure cards stack vertically inside main content columns */
.page-body .col-lg-8 > .card,
.page-body .col-lg-4 > .card {
    display: block;
    width: 100%;
    max-width: 100%;
    float: none;
}

/* Defensive rule in case a deck/grid tries to compress cards */
.row-cards .card {
    flex: 0 0 100%;
}