/**
 * Football Analytics Textbook - UX Enhancements CSS
 * Styles for progress tracking, mobile navigation, and interactive features
 */

/* ============================================
   PROGRESS TRACKING STYLES
   ============================================ */

.progress-container {
    padding: 15px 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 10px;
}

.progress-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.progress-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary-color);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.progress-count {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--secondary-color);
    background: white;
    padding: 2px 10px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.progress-bar-wrapper {
    width: 100%;
    height: 8px;
    background-color: #dee2e6;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}

.progress-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--secondary-color) 0%, var(--accent-color) 100%);
    border-radius: 4px;
    transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 1px 3px rgba(0,102,204,0.3);
}

.progress-percentage {
    text-align: center;
    font-size: 0.75rem;
    color: #666;
    margin-top: 5px;
    font-weight: 600;
}

/* Progress Control Buttons */
.progress-controls {
    padding: 10px 20px 15px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
    background-color: #f8f9fa;
}

.progress-btn {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    background: white;
    color: var(--text-color);
    border-radius: 5px;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.progress-btn:hover {
    background-color: var(--secondary-color);
    color: white;
    border-color: var(--secondary-color);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.progress-btn:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

.progress-btn.reset-btn {
    background-color: #fff3e0;
    border-color: #ff9800;
    color: #e65100;
}

.progress-btn.reset-btn:hover {
    background-color: #ff9800;
    color: white;
    border-color: #f57c00;
}

.btn-icon {
    font-size: 1.1em;
    font-weight: bold;
}

/* Chapter Checkboxes */
.chapter-checkbox {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border: 2px solid #ccc;
    border-radius: 4px;
    margin-right: 10px;
    cursor: pointer;
    transition: all 0.2s;
    background: white;
    flex-shrink: 0;
}

.chapter-checkbox:hover {
    border-color: var(--secondary-color);
    background-color: #e7f3ff;
    transform: scale(1.1);
}

.chapter-checkbox.completed {
    background-color: var(--secondary-color);
    border-color: var(--secondary-color);
}

.chapter-checkbox .checkmark {
    color: white;
    font-size: 14px;
    font-weight: bold;
    line-height: 1;
}

.nav-chapters li {
    display: flex;
    align-items: center;
}

.nav-chapters a {
    flex: 1;
}

/* Completion Celebration */
.completion-celebration {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    animation: fadeIn 0.3s ease-in;
}

.completion-celebration.fade-out {
    animation: fadeOut 0.3s ease-out forwards;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

.celebration-content {
    background: white;
    padding: 40px;
    border-radius: 15px;
    text-align: center;
    max-width: 500px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    position: relative;
    animation: slideUp 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.celebration-icon {
    font-size: 80px;
    margin-bottom: 20px;
    animation: bounce 1s infinite;
}

@keyframes bounce {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-10px);
    }
}

.celebration-content h3 {
    color: var(--primary-color);
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 2rem;
}

.celebration-content p {
    color: var(--text-color);
    font-size: 1.1rem;
    margin-bottom: 0;
}

.celebration-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: none;
    border: none;
    font-size: 30px;
    color: #999;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.celebration-close:hover {
    background-color: #f0f0f0;
    color: #333;
}

/* ============================================
   MOBILE NAVIGATION STYLES
   ============================================ */

/* Hamburger Menu */
.hamburger-menu {
    display: none;
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 1001;
    width: 44px;
    height: 44px;
    background: var(--primary-color);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s;
}

.hamburger-menu:hover {
    background: var(--secondary-color);
    transform: scale(1.05);
}

.hamburger-menu:active {
    transform: scale(0.95);
}

.hamburger-line {
    width: 24px;
    height: 3px;
    background: white;
    border-radius: 2px;
    transition: all 0.3s;
}

.hamburger-menu.active .hamburger-line:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.hamburger-menu.active .hamburger-line:nth-child(2) {
    opacity: 0;
}

.hamburger-menu.active .hamburger-line:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

/* Mobile Header */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--primary-color);
    color: white;
    z-index: 999;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.mobile-header-content {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 0 70px;
}

.mobile-chapter-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Bottom Navigation */
.mobile-nav-bottom {
    display: none;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 1px solid var(--border-color);
    z-index: 999;
    padding: 8px;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    grid-template-columns: 1fr auto 1fr;
    gap: 8px;
}

.mobile-nav-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 10px 15px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.mobile-nav-btn:hover,
.mobile-nav-btn:active {
    background: var(--secondary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.mobile-nav-btn.mobile-nav-top {
    background: #6c757d;
}

.mobile-nav-btn.mobile-nav-top:hover {
    background: #5a6268;
}

.nav-arrow {
    font-size: 1.2em;
    font-weight: bold;
}

.mobile-nav-spacer {
    min-width: 44px;
}

/* Sidebar mobile states */
@media (max-width: 768px) {
    .sidebar.mobile-hidden {
        transform: translateX(-100%);
        transition: transform 0.3s ease-in-out;
    }

    .sidebar.mobile-visible {
        transform: translateX(0);
        transition: transform 0.3s ease-in-out;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.2);
        z-index: 1000;
    }
}

/* Collapsible Sections */
.collapsible-header {
    cursor: pointer;
    user-select: none;
    position: relative;
    padding-right: 30px;
    transition: color 0.2s;
}

.collapsible-header:hover {
    color: var(--secondary-color);
}

.collapse-icon {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--secondary-color);
    width: 25px;
    height: 25px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #e9ecef;
    border-radius: 50%;
    transition: all 0.2s;
}

.collapsible-header:hover .collapse-icon {
    background: var(--secondary-color);
    color: white;
}

.collapsible-content {
    overflow: hidden;
    transition: max-height 0.3s ease-in-out;
    max-height: 5000px;
}

.collapsible-content.collapsed {
    max-height: 0;
    margin: 0;
    padding: 0;
}

/* Touch Optimized Elements */
.touch-optimized {
    min-height: 44px;
    min-width: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* ============================================
   RESPONSIVE MOBILE STYLES
   ============================================ */

@media (max-width: 768px) {
    /* Show mobile UI elements */
    .hamburger-menu {
        display: flex;
    }

    .mobile-header {
        display: block;
    }

    .mobile-nav-bottom {
        display: grid;
    }

    /* Adjust main content for mobile header and bottom nav */
    .main-content {
        margin-top: 60px;
        padding-bottom: 80px;
    }

    /* Sidebar adjustments */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 280px;
        max-width: 85vw;
        height: 100vh;
        z-index: 1000;
    }

    /* Hide desktop chapter navigation on mobile */
    .chapter-nav {
        display: none;
    }

    /* Adjust progress controls for mobile */
    .progress-controls {
        padding: 8px 15px 12px;
    }

    .progress-btn {
        font-size: 0.8rem;
        padding: 7px 10px;
    }

    /* Optimize tables for mobile */
    table {
        font-size: 0.85rem;
    }

    th, td {
        padding: 8px 6px;
    }

    /* Adjust code blocks */
    pre {
        font-size: 0.8rem;
        padding: 10px;
    }

    /* Smaller headings on mobile */
    h1 {
        font-size: 1.8rem;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    /* Interactive tools */
    .interactive-tool {
        padding: 15px;
    }

    /* Better touch targets for nav links */
    .nav-chapters a {
        padding: 12px 20px 12px 25px;
        font-size: 0.95rem;
    }

    /* Progress container adjustments */
    .progress-container {
        padding: 12px 15px;
    }

    /* Celebration modal */
    .celebration-content {
        margin: 20px;
        padding: 30px 20px;
    }

    .celebration-icon {
        font-size: 60px;
    }

    .celebration-content h3 {
        font-size: 1.5rem;
    }

    .celebration-content p {
        font-size: 1rem;
    }
}

/* Landscape phone adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .mobile-header {
        height: 50px;
    }

    .main-content {
        margin-top: 50px;
    }

    .mobile-chapter-title {
        font-size: 0.9rem;
    }

    .celebration-content {
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .sidebar {
        max-width: 90vw;
    }

    .mobile-header-content {
        padding: 0 60px;
    }

    .mobile-chapter-title {
        font-size: 0.85rem;
    }

    .mobile-nav-btn {
        font-size: 0.85rem;
        padding: 8px 12px;
    }

    .nav-text {
        display: none;
    }

    .mobile-nav-btn {
        min-width: 44px;
    }

    .progress-label {
        font-size: 0.75rem;
    }

    .progress-count {
        font-size: 0.8rem;
        padding: 2px 8px;
    }
}

/* Tablet devices */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 250px;
    }

    .main-content {
        margin-left: 250px;
        padding: 30px 40px;
    }
}

/* ============================================
   ACCESSIBILITY ENHANCEMENTS
   ============================================ */

/* Focus visible styles for keyboard navigation */
.chapter-checkbox:focus-visible,
.progress-btn:focus-visible,
.hamburger-menu:focus-visible,
.mobile-nav-btn:focus-visible,
.collapsible-header:focus-visible {
    outline: 3px solid var(--accent-color);
    outline-offset: 2px;
}

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

    .sidebar {
        transition: none !important;
    }

    .progress-bar-fill {
        transition: none !important;
    }

    .celebration-icon {
        animation: none !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .chapter-checkbox {
        border-width: 3px;
    }

    .progress-bar-wrapper {
        border: 2px solid #000;
    }

    .mobile-nav-btn,
    .hamburger-menu {
        border: 2px solid #000;
    }
}

/* Dark mode support (optional) */
@media (prefers-color-scheme: dark) {
    .progress-container {
        background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
    }

    .progress-count {
        background: #2d3748;
        color: #63b3ed;
    }

    .progress-bar-wrapper {
        background-color: #1a202c;
    }

    .celebration-content {
        background: #2d3748;
        color: #e2e8f0;
    }

    .celebration-content h3 {
        color: #63b3ed;
    }

    .mobile-header {
        background: #1a202c;
    }

    .mobile-nav-bottom {
        background: #2d3748;
        border-top-color: #4a5568;
    }
}

/* ============================================
   SEARCH AND NAVIGATION STYLES
   ============================================ */

/* Search Container */
.search-container {
    padding: 15px 15px;
    border-bottom: 1px solid var(--border-color);
    background-color: #f8f9fa;
}

.search-wrapper {
    position: relative;
}

.search-input {
    width: 100%;
    padding: 10px 35px 10px 15px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.95rem;
    background: white;
    color: var(--text-color);
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--secondary-color);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
    background: #fafbfc;
}

.search-input::placeholder {
    color: #999;
}

.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    font-size: 1rem;
    color: #999;
}

/* Search Results */
.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 400px;
    overflow-y: auto;
    z-index: 100;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.search-result-item {
    padding: 12px 15px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-color);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background-color: #e7f3ff;
    color: var(--secondary-color);
    padding-left: 18px;
}

.search-no-results {
    padding: 20px 15px;
    text-align: center;
    color: #999;
    font-style: italic;
}

/* Chapter Navigation Arrows */
.chapter-nav-arrows {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 50px;
    padding-top: 30px;
    border-top: 2px solid var(--border-color);
}

.nav-arrow {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 20px;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-color);
    transition: all 0.3s;
    background: #f8f9fa;
}

.nav-arrow:hover:not(.disabled) {
    border-color: var(--secondary-color);
    background: #e7f3ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 102, 204, 0.2);
}

.nav-arrow.nav-prev {
    text-align: left;
}

.nav-arrow.nav-next {
    text-align: right;
}

.nav-arrow.disabled {
    opacity: 0.3;
    cursor: not-allowed;
    border-color: #ddd;
}

.nav-arrow .arrow {
    font-weight: 600;
    color: var(--secondary-color);
    font-size: 0.9rem;
}

.nav-arrow .chapter-title {
    font-size: 0.95rem;
    font-weight: 500;
}

/* Table of Contents Modal */
.toc-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    animation: fadeIn 0.2s;
}

.toc-modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 500px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s;
}

.toc-header {
    padding: 25px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toc-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--primary-color);
}

.toc-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.toc-close:hover {
    background: #f0f0f0;
    color: #333;
}

.toc-content {
    overflow-y: auto;
    padding: 0;
    flex: 1;
}

.toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.toc-item {
    margin: 0;
}

.toc-item a {
    display: block;
    padding: 12px 25px;
    color: var(--secondary-color);
    text-decoration: none;
    border-left: 3px solid transparent;
    transition: all 0.2s;
    border-bottom: 1px solid #f0f0f0;
}

.toc-item:last-child a {
    border-bottom: none;
}

.toc-item a:hover {
    background-color: #f8f9fa;
    border-left-color: var(--secondary-color);
    padding-left: 30px;
}

.toc-item.toc-level-3 a {
    padding-left: 45px;
    font-size: 0.9rem;
    color: #666;
}

.toc-item.toc-level-3 a:hover {
    padding-left: 50px;
}

/* Keyboard Help Modal */
.keyboard-help-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 5000;
    animation: fadeIn 0.2s;
}

.help-modal {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    max-width: 550px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s;
}

.help-header {
    padding: 25px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.help-header h2 {
    margin: 0;
    font-size: 1.5rem;
    color: var(--primary-color);
}

.help-close {
    background: none;
    border: none;
    font-size: 28px;
    color: #999;
    cursor: pointer;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.help-close:hover {
    background: #f0f0f0;
    color: #333;
}

.help-content {
    overflow-y: auto;
    padding: 25px;
}

.shortcut-group {
    margin-bottom: 25px;
}

.shortcut-group:last-child {
    margin-bottom: 0;
}

.shortcut-group h3 {
    margin: 0 0 12px 0;
    font-size: 1.1rem;
    color: var(--primary-color);
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 8px;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 12px;
    font-size: 0.95rem;
}

.shortcut-item kbd {
    background: var(--secondary-color);
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.85rem;
    font-weight: 600;
    min-width: 40px;
    text-align: center;
    white-space: nowrap;
}

.shortcut-item span {
    color: var(--text-color);
}

.help-tip {
    background: #f0f7ff;
    border-left: 4px solid var(--secondary-color);
    padding: 12px 15px;
    border-radius: 4px;
    margin-top: 20px;
    font-size: 0.9rem;
    color: #333;
}

.help-tip strong {
    color: var(--primary-color);
}

/* ============================================
   PRINT HIDING FOR INTERACTIVE ELEMENTS
   ============================================ */

@media print {
    .hamburger-menu,
    .mobile-header,
    .mobile-nav-bottom,
    .progress-container,
    .progress-controls,
    .chapter-checkbox,
    .completion-celebration,
    .collapse-icon,
    .collapsible-header,
    .search-container,
    .chapter-nav-arrows,
    .toc-overlay,
    .keyboard-help-overlay {
        display: none !important;
    }

    .collapsible-content.collapsed {
        max-height: none !important;
        display: block !important;
    }
}
