/**
 * Mythscribe Nexus - Custom CSS
 * Enhances Bootstrap with custom theming
 */

/* ====================================
   Variables and Root Styles
   ==================================== */
:root {
    --nexus-primary: #0d6efd;
    --nexus-secondary: #6c757d;
    --nexus-success: #198754;
    --nexus-danger: #dc3545;
    --nexus-warning: #ffc107;
    --nexus-info: #0dcaf0;
    --nexus-dark: #212529;
    --nexus-light: #f8f9fa;

    /* Light mode colors */
    --bg-body: #ffffff;
    --bg-secondary: #f8f9fa;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-muted: #6c757d;
    --border-color: #dee2e6;
    --card-bg: #ffffff;
    --card-shadow: rgba(0, 0, 0, 0.075);
    --card-shadow-hover: rgba(0, 0, 0, 0.15);
    --navbar-bg: #212529;
    --footer-bg: #212529;
}

/* Dark mode color variables */
[data-theme="dark"] {
    --nexus-light: #212529;
    --bg-body: #0d1117;
    --bg-secondary: #161b22;
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --text-muted: #8b949e;
    --border-color: #30363d;
    --card-bg: #161b22;
    --card-shadow: rgba(0, 0, 0, 0.3);
    --card-shadow-hover: rgba(0, 0, 0, 0.5);
    --navbar-bg: #0d1117;
    --footer-bg: #0d1117;
}

/* ====================================
   General Styles
   ==================================== */
body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-body);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

main {
    flex: 1;
}

/* Dark mode specific styles */
[data-theme="dark"] .bg-light {
    background-color: var(--bg-secondary) !important;
    color: var(--text-primary) !important;
}

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

[data-theme="dark"] .text-muted {
    color: var(--text-muted) !important;
}

[data-theme="dark"] .navbar-dark {
    background-color: var(--navbar-bg) !important;
}

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

/* Link colors inherit by default unless styled */
a.text-decoration-none {
    color: inherit;
}

a.text-decoration-none:hover {
    color: var(--nexus-primary);
}

/* ====================================
   Typography
   ==================================== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
}

.display-1, .display-2, .display-3, .display-4 {
    font-weight: 700;
}

/* ====================================
   Navigation
   ==================================== */
.navbar-brand {
    font-size: 1.5rem;
    letter-spacing: -0.5px;
}

.navbar-dark .navbar-nav .nav-link {
    transition: all 0.3s ease;
}

.navbar-dark .navbar-nav .nav-link:hover {
    color: rgba(255, 255, 255, 0.9);
    transform: translateY(-1px);
}

/* ====================================
   Cards and Components
   ==================================== */
.card {
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    box-shadow: 0 0.125rem 0.25rem var(--card-shadow);
    transition: all 0.3s ease;
    color: var(--text-primary);
}

.card.hover-shadow:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.5rem 1rem var(--card-shadow-hover);
}

.card-img-top {
    border-top-left-radius: calc(0.375rem - 1px);
    border-top-right-radius: calc(0.375rem - 1px);
}

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

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

/* ====================================
   Buttons
   ==================================== */
.btn {
    font-weight: 500;
    border-radius: 0.375rem;
    padding: 0.5rem 1.25rem;
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.1);
}

.btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: 1.125rem;
}

.btn-sm {
    padding: 0.375rem 0.875rem;
    font-size: 0.875rem;
}

/* ====================================
   Badges
   ==================================== */
.badge {
    font-weight: 500;
    padding: 0.35em 0.65em;
    border-radius: 0.25rem;
}

/* ====================================
   Forms
   ==================================== */
.form-control,
.form-select {
    border-radius: 0.375rem;
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    color: var(--text-primary);
    transition: all 0.3s ease;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--nexus-primary);
    box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
    background-color: var(--card-bg);
    color: var(--text-primary);
}

.form-control-lg {
    padding: 0.75rem 1rem;
    font-size: 1.125rem;
}

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

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

/* Form validation */
.was-validated .form-control:valid,
.form-control.is-valid {
    border-color: var(--nexus-success);
}

.was-validated .form-control:invalid,
.form-control.is-invalid {
    border-color: var(--nexus-danger);
}

/* ====================================
   Alerts
   ==================================== */
.alert {
    border-radius: 0.5rem;
    border: none;
    box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

.alert-dismissible .btn-close {
    padding: 1rem;
}

/* ====================================
   Accessibility
   ==================================== */
.visually-hidden-focusable:not(:focus):not(:focus-within) {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.visually-hidden-focusable:focus {
    position: fixed !important;
    top: 10px;
    left: 10px;
    z-index: 9999;
    padding: 1rem 1.5rem;
    background: var(--nexus-dark);
    color: white;
    border-radius: 0.5rem;
    text-decoration: none;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.3);
}

/* ====================================
   Pagination
   ==================================== */
.pagination {
    gap: 0.25rem;
}

.page-link {
    border-radius: 0.375rem;
    border: 1px solid #dee2e6;
    color: var(--nexus-primary);
    transition: all 0.3s ease;
}

.page-link:hover {
    background-color: var(--nexus-light);
    transform: translateY(-2px);
}

.page-item.active .page-link {
    background-color: var(--nexus-primary);
    border-color: var(--nexus-primary);
}

/* ====================================
   Footer
   ==================================== */
footer {
    margin-top: auto;
    background-color: var(--footer-bg) !important;
}

footer a:hover {
    opacity: 0.8;
}

[data-theme="dark"] footer {
    border-top: 1px solid var(--border-color);
}

/* ====================================
   Hero Section
   ==================================== */
.hero {
    background: linear-gradient(135deg, var(--nexus-primary) 0%, #0a58ca 100%);
    color: white;
}

/* ====================================
   Rating Stars
   ==================================== */
.rating-stars {
    color: var(--nexus-warning);
}

.bi-star-fill {
    color: var(--nexus-warning);
}

.bi-star-half {
    color: var(--nexus-warning);
}

.bi-star {
    color: #dee2e6;
}

/* ====================================
   Work/Edition Cards
   ==================================== */
.work-card {
    transition: all 0.3s ease;
}

.work-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.work-card .card-img-top {
    height: 300px;
    object-fit: cover;
}

/* ====================================
   Progress Bars
   ==================================== */
.progress {
    border-radius: 0.5rem;
    background-color: var(--nexus-light);
}

.progress-bar {
    border-radius: 0.5rem;
}

/* ====================================
   Tables
   ==================================== */
.table {
    margin-bottom: 0;
    color: var(--text-primary);
}

.table-hover tbody tr {
    transition: background-color 0.3s ease;
}

[data-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-striped-bg: var(--bg-secondary);
    --bs-table-hover-bg: var(--bg-secondary);
    border-color: var(--border-color);
}

[data-theme="dark"] .table thead {
    border-color: var(--border-color);
}

[data-theme="dark"] .table td,
[data-theme="dark"] .table th {
    border-color: var(--border-color);
}

/* ====================================
   Dropdown Menus
   ==================================== */
.dropdown-menu {
    border: 1px solid var(--border-color);
    background-color: var(--card-bg);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
    border-radius: 0.5rem;
    padding: 0.5rem;
}

.dropdown-item {
    border-radius: 0.375rem;
    transition: all 0.2s ease;
    color: var(--text-primary);
}

.dropdown-item:hover {
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    transform: translateX(3px);
}

[data-theme="dark"] .dropdown-menu {
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.5);
}

/* ====================================
   Theme Toggle Button
   ==================================== */
.theme-toggle-btn {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.75);
    font-size: 1.25rem;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-toggle-btn:hover {
    color: rgba(255, 255, 255, 1);
    transform: rotate(20deg);
}

.theme-toggle-btn i {
    transition: transform 0.3s ease;
}

/* ====================================
   Loading States
   ==================================== */
.loading {
    opacity: 0.5;
    pointer-events: none;
}

.spinner-border {
    width: 1.5rem;
    height: 1.5rem;
    border-width: 0.2em;
}

/* ====================================
   Responsive Utilities
   ==================================== */
@media (max-width: 767.98px) {
    .navbar-brand {
        font-size: 1.25rem;
    }

    .display-4 {
        font-size: 2.5rem;
    }

    .card-img-top,
    .work-card .card-img-top {
        height: 250px;
    }

    /* Touch-friendly buttons */
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
}

@media (max-width: 575.98px) {
    .container {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    .card-img-top,
    .work-card .card-img-top {
        height: 200px;
    }
}

/* ====================================
   Dark Mode Support (Future)
   ==================================== */
@media (prefers-color-scheme: dark) {
    /* Dark mode styles will be added in future versions */
}

/* ====================================
   Print Styles
   ==================================== */
@media print {
    .navbar,
    .btn,
    footer {
        display: none;
    }

    .card {
        box-shadow: none;
        border: 1px solid #dee2e6;
    }
}

/* ====================================
   Animations
   ==================================== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

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

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

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

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

.cursor-pointer {
    cursor: pointer;
}

.hover-opacity:hover {
    opacity: 0.8;
}

/* ====================================
   Level Badges (Gamification)
   ==================================== */
/* Font size utilities for badges */
.fs-7 {
    font-size: 0.875rem !important;
}

.fs-8 {
    font-size: 0.75rem !important;
    padding: 0.25em 0.5em !important;
}

/* Level badge styling */
.badge[data-bs-toggle="tooltip"] {
    cursor: help;
    vertical-align: middle;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

/* Level badge hover effect */
.badge[data-bs-toggle="tooltip"]:hover {
    opacity: 0.9;
    transform: scale(1.05);
    transition: all 0.2s ease;
}

/* Dark mode adjustments for level badges */
[data-theme="dark"] .badge {
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ====================================
   Card Dropdown Z-Index Fix
   ==================================== */
/* Ensure dropdowns in cards don't get hidden behind other cards */
.card:has(.dropdown.show),
.card:has(.dropdown-menu.show) {
    z-index: 10;
    position: relative;
}

.dropdown-menu {
    z-index: 1050;
}

/* Ensure card footers with dropdowns are on top */
.card-footer:has(.dropdown.show) {
    z-index: 11;
    position: relative;
}
