/*
 * Wikipedia Explorer - Advanced Educational Tool
 * Enhanced CSS with Dark Mode, Animations, and Premium UI/UX
 * Developed by RSK World (https://rskworld.in)
 * Founder: Molla Samser
 * Designer & Tester: Rima Khatun
 * Contact: info@rskworld.com, +91 93305 39277
 * Location: Nutanhat, Mongolkote, Purba Burdwan, West Bengal, India - 713147
 * © 2026 RSK World. All rights reserved.
 * Content used for educational purposes only.
 */

/* CSS Custom Properties for Theming */
:root {
    --primary-color: #0d6efd;
    --primary-dark: #0a58ca;
    --secondary-color: #6c757d;
    --success-color: #198754;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --info-color: #0dcaf0;
    --light-color: #f8f9fa;
    --dark-color: #212529;
    --border-radius: 0.5rem;
    --box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
    --box-shadow-lg: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s ease;
    --font-size-base: 1rem;
    --font-size-sm: 0.875rem;
    --font-size-lg: 1.125rem;
    --gradient-primary: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --gradient-secondary: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --gradient-success: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

/* Dark Mode Variables */
[data-theme="dark"] {
    --primary-color: #4dabf7;
    --primary-dark: #339af0;
    --secondary-color: #868e96;
    --success-color: #51cf66;
    --warning-color: #ffd43b;
    --danger-color: #ff6b6b;
    --info-color: #74c0fc;
    --light-color: #343a40;
    --dark-color: #f8f9fa;
    --bg-primary: #1a1d23;
    --bg-secondary: #2d3139;
    --bg-tertiary: #3d4147;
    --text-primary: #f8f9fa;
    --text-secondary: #adb5bd;
    --border-color: #495057;
}

/* Global Styles & Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.6;
    color: var(--dark-color);
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    transition: var(--transition);
    font-feature-settings: 'kern' 1, 'liga' 1;
}

[data-theme="dark"] body {
    background: linear-gradient(135deg, #1a1d23 0%, #2d3139 100%);
    color: var(--text-primary);
}

main {
    flex: 1;
    padding: 2rem 0;
}

/* Enhanced Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    line-height: 1.2;
    margin-bottom: 1rem;
    letter-spacing: -0.025em;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.75rem; }
h4 { font-size: 1.5rem; }
h5 { font-size: 1.25rem; }
h6 { font-size: 1.125rem; }

p {
    margin-bottom: 1rem;
    line-height: 1.7;
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

/* Enhanced Header */
header {
    background: var(--gradient-primary);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] header {
    background: linear-gradient(135deg, #2d3139 0%, #1a1d23 100%);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

header h1 {
    font-weight: 800;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Enhanced Search Section */
.search-section .card {
    border: none;
    border-radius: 1rem;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    box-shadow: var(--box-shadow-lg);
    transition: var(--transition);
    overflow: hidden;
}

[data-theme="dark"] .search-section .card {
    background: rgba(45, 49, 57, 0.95);
    border: 1px solid var(--border-color);
}

.search-section .card:hover {
    transform: translateY(-5px);
    box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.2);
}

.gradient-bg {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    backdrop-filter: blur(10px);
}

/* Enhanced Form Controls */
.form-control, .form-select {
    border: 2px solid #e9ecef;
    border-radius: var(--border-radius);
    padding: 0.75rem 1rem;
    font-size: var(--font-size-base);
    transition: var(--transition);
    background: rgba(255, 255, 255, 0.9);
}

[data-theme="dark"] .form-control,
[data-theme="dark"] .form-select {
    background: var(--bg-secondary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.25);
    outline: none;
}

/* Enhanced Buttons */
.btn {
    border-radius: var(--border-radius);
    font-weight: 600;
    padding: 0.75rem 1.5rem;
    transition: var(--transition);
    border: none;
    position: relative;
    overflow: hidden;
    text-transform: none;
    letter-spacing: 0.025em;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn-primary {
    background: var(--gradient-primary);
    box-shadow: 0 4px 15px rgba(13, 110, 253, 0.3);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(13, 110, 253, 0.4);
}

/* Search Suggestions */
.suggestions-container {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.98);
    border: 1px solid #e9ecef;
    border-top: none;
    border-radius: 0 0 var(--border-radius) var(--border-radius);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
    box-shadow: var(--box-shadow-lg);
    backdrop-filter: blur(10px);
}

[data-theme="dark"] .suggestions-container {
    background: var(--bg-secondary);
    border-color: var(--border-color);
}

.suggestion-item {
    padding: 1rem;
    cursor: pointer;
    border-bottom: 1px solid #f1f3f5;
    transition: var(--transition);
    display: flex;
    align-items: center;
}

[data-theme="dark"] .suggestion-item {
    border-bottom-color: var(--border-color);
    color: var(--text-primary);
}

.suggestion-item:hover {
    background: var(--light-color);
    padding-left: 1.25rem;
}

[data-theme="dark"] .suggestion-item:hover {
    background: var(--bg-tertiary);
}

/* Loading Indicator */
#loadingIndicator {
    padding: 3rem;
}

.spinner-border {
    width: 3rem;
    height: 3rem;
    border-width: 0.25rem;
}

/* Enhanced Results Section */
.search-result-card {
    margin-bottom: 2rem;
    border: none;
    border-radius: 1rem;
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    cursor: pointer;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
}

[data-theme="dark"] .search-result-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

.search-result-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 1rem 3rem rgba(0, 0, 0, 0.15);
}

.search-result-card .card-img-top {
    height: 250px;
    object-fit: cover;
    transition: var(--transition);
}

.search-result-card:hover .card-img-top {
    transform: scale(1.05);
}

.search-result-card .card-body {
    padding: 2rem;
}

.search-result-card .card-title {
    color: var(--primary-color);
    font-size: 1.375rem;
    font-weight: 700;
    margin-bottom: 1rem;
    line-height: 1.3;
}

.search-result-card .card-text {
    color: var(--secondary-color);
    font-size: var(--font-size-base);
    line-height: 1.6;
}

/* Enhanced Article Section */
.article-section .card {
    border: none;
    border-radius: 1rem;
    box-shadow: var(--box-shadow);
    background: rgba(255, 255, 255, 0.98);
    backdrop-filter: blur(20px);
}

[data-theme="dark"] .article-section .card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

.article-header {
    border-bottom: 3px solid var(--primary-color);
    padding-bottom: 1.5rem;
    margin-bottom: 2rem;
    background: linear-gradient(135deg, rgba(13, 110, 253, 0.05) 0%, rgba(13, 110, 253, 0.02) 100%);
    border-radius: var(--border-radius);
    padding: 1.5rem;
}

.article-title {
    color: var(--dark-color);
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
    line-height: 1.2;
}

[data-theme="dark"] .article-title {
    color: var(--text-primary);
}

.article-content {
    font-size: var(--font-size-lg);
    line-height: 1.8;
    color: var(--dark-color);
}

[data-theme="dark"] .article-content {
    color: var(--text-primary);
}

.article-content img {
    max-width: 100%;
    height: auto;
    border-radius: var(--border-radius);
    margin: 2rem 0;
    box-shadow: var(--box-shadow);
}

/* Reading Progress Bar */
.progress {
    height: 6px;
    border-radius: 3px;
    background: rgba(13, 110, 253, 0.1);
    overflow: hidden;
}

.progress-bar {
    background: var(--gradient-primary);
    transition: width 0.3s ease;
}

/* Related Articles */
.related-article {
    display: block;
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: var(--light-color);
    border: 1px solid #e9ecef;
    border-radius: var(--border-radius);
    text-decoration: none;
    color: var(--dark-color);
    transition: var(--transition);
    font-weight: 500;
}

[data-theme="dark"] .related-article {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
}

.related-article:hover {
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    transform: translateX(8px);
    box-shadow: var(--box-shadow);
}

/* Enhanced Category Cards */
.category-card {
    border: none;
    border-radius: 1rem;
    box-shadow: var(--box-shadow);
    transition: var(--transition);
    cursor: pointer;
    text-align: center;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    position: relative;
    overflow: hidden;
}

[data-theme="dark"] .category-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

.category-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--gradient-primary);
    opacity: 0;
    transition: var(--transition);
}

.category-card:hover {
    transform: translateY(-10px) scale(1.05);
    box-shadow: 0 1rem 2rem rgba(0, 0, 0, 0.15);
}

.category-card:hover::before {
    opacity: 0.1;
}

.category-card .card-body {
    padding: 2.5rem 1.5rem;
    position: relative;
    z-index: 1;
}

.category-card i {
    transition: var(--transition);
    font-size: 3rem;
}

.category-card:hover i {
    transform: scale(1.2) rotate(5deg);
}

.category-card .card-title {
    margin: 1rem 0 0.5rem;
    font-weight: 700;
    color: var(--dark-color);
}

[data-theme="dark"] .category-card .card-title {
    color: var(--text-primary);
}

/* Enhanced Footer */
footer {
    background: linear-gradient(135deg, #1a1d23 0%, #2d3139 100%);
    margin-top: auto;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

footer a {
    color: #adb5bd;
    transition: var(--transition);
}

footer a:hover {
    color: #f8f9fa;
    text-decoration: none;
    transform: translateY(-2px);
}

/* Dark Mode Toggle */
.form-check-input:checked {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
}

.form-switch .form-check-input {
    width: 3rem;
    height: 1.5rem;
    cursor: pointer;
}

.form-switch .form-check-input:checked {
    background-color: var(--warning-color);
    border-color: var(--warning-color);
}

/* Modal Enhancements */
.modal-content {
    border: none;
    border-radius: 1rem;
    box-shadow: 0 2rem 4rem rgba(0, 0, 0, 0.15);
    backdrop-filter: blur(20px);
}

[data-theme="dark"] .modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
}

.modal-header {
    border-bottom: 1px solid #e9ecef;
    background: linear-gradient(135deg, rgba(13, 110, 253, 0.05) 0%, rgba(13, 110, 253, 0.02) 100%);
    border-radius: 1rem 1rem 0 0;
}

[data-theme="dark"] .modal-header {
    border-bottom-color: var(--border-color);
    background: var(--bg-tertiary);
}

/* Quick Tags */
.quick-tag {
    border-radius: 2rem;
    font-size: var(--font-size-sm);
    font-weight: 500;
    transition: var(--transition);
    border: 2px solid transparent;
}

.quick-tag:hover {
    transform: translateY(-2px);
    box-shadow: var(--box-shadow);
    border-color: var(--primary-color);
}

/* Utility Classes */
.text-truncate-2 {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.text-truncate-3 {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Enhanced Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInLeft {
    from {
        opacity: 0;
        transform: translateX(-50px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.fade-in {
    animation: fadeInUp 0.6s ease-out;
}

.slide-in {
    animation: slideInLeft 0.5s ease-out;
}

.pulse {
    animation: pulse 2s infinite;
}

/* Responsive Design */
@media (max-width: 768px) {
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }
    
    .article-title {
        font-size: 1.75rem;
    }
    
    .search-result-card .card-title {
        font-size: 1.125rem;
    }
    
    .category-card .card-body {
        padding: 2rem 1rem;
    }
    
    header .row {
        text-align: center !important;
    }
    
    header .text-md-end {
        text-align: center !important;
        margin-top: 1rem;
    }
    
    .btn {
        padding: 0.6rem 1.2rem;
        font-size: var(--font-size-sm);
    }
}

@media (max-width: 576px) {
    main {
        padding: 1rem 0;
    }
    
    .input-group-lg .form-control,
    .input-group-lg .btn {
        font-size: var(--font-size-base);
        padding: 0.75rem;
    }
    
    .suggestions-container {
        position: relative;
        margin-top: 0.5rem;
        border: 1px solid #e9ecef;
        border-radius: var(--border-radius);
    }
    
    .article-content {
        font-size: var(--font-size-base);
    }
    
    .category-card i {
        font-size: 2.5rem;
    }
    
    .search-result-card .card-body {
        padding: 1.5rem;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 10px;
}

::-webkit-scrollbar-track {
    background: var(--light-color);
}

[data-theme="dark"] ::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--secondary-color);
    border-radius: 5px;
    transition: var(--transition);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Print Styles */
@media print {
    header,
    footer,
    #backBtn,
    .category-card,
    .modal,
    .btn,
    .progress,
    .quick-tags {
        display: none !important;
    }
    
    .search-section,
    .categories-section {
        display: none !important;
    }
    
    .article-section {
        display: block !important;
    }
    
    body {
        background: white !important;
        color: black !important;
    }
    
    .card {
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }
    
    .card {
        border: 2px solid currentColor;
    }
}

/* Performance Optimizations */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

.will-change-transform {
    will-change: transform;
}
