/**
 * EduModules Public Styles
 * Professional and refined base styles
 */

/* Reset and base styles */
.edumodules-container {
    position: relative;
    max-width: 100%;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", sans-serif;
    line-height: 1.6;
    color: #2c3e50;
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.edumodules-container * {
    box-sizing: border-box;
}

/* Skip navigation for accessibility */
.skip-link {
    position: absolute;
    left: -9999px;
    top: 0;
    padding: 8px 16px;
    background: #2c3e50;
    color: #fff;
    text-decoration: none;
    z-index: 999999;
    border-radius: 0 0 4px 4px;
    font-size: 14px;
}

.skip-link:focus {
    left: 6px;
    top: 6px;
}

/* Loading indicator */
.edumodules-loading {
    text-align: center;
    padding: 40px 20px;
    color: #7f8c8d;
}

.edumodules-loading.active {
    display: block;
}

.loading-spinner {
    width: 32px;
    height: 32px;
    margin: 0 auto 16px;
    border: 3px solid #ecf0f1;
    border-top: 3px solid #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Progress bar */
.progress-container {
    margin: 0;
    padding: 16px 20px;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-size: 14px;
    color: #6c757d;
}

.progress-label {
    font-weight: 500;
}

.progress-percentage {
    font-weight: 600;
    color: #495057;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #28a745;
    border-radius: 3px;
    transition: width 0.4s ease;
}

/* Navigation tabs */
.edumodules-nav {
    margin: 0;
    position: relative;
}

/* Toggle button for mobile */
.nav-toggle {
    display: none;
    background: #007bff;
    color: white;
    border: none;
    padding: 12px 16px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    margin-bottom: 8px;
    width: 100%;
    text-align: left;
    position: relative;
}

.nav-toggle:hover {
    background: #0056b3;
}

.nav-toggle::after {
    content: '▼';
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    transition: transform 0.3s ease;
}

.nav-toggle.collapsed::after {
    transform: translateY(-50%) rotate(-90deg);
}

.nav-tabs {
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    margin: 0;
    padding: 0;
    background: #fff;
    border-bottom: 1px solid #dee2e6;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

/* Desktop: ensure nav is always visible */
@media (min-width: 1025px) {
    .nav-tabs {
        display: flex !important;
        opacity: 1 !important;
        max-height: none !important;
        overflow: visible !important;
    }
}

/* Only apply collapsed state on mobile/tablet where toggle is shown */
@media (max-width: 1024px) {
    .nav-tabs.collapsed {
        max-height: 0;
        opacity: 0;
        overflow: hidden;
        border-bottom: none;
        transition: max-height 0.3s ease, opacity 0.3s ease;
    }
}

.nav-item {
    margin: 0;
    flex-shrink: 0;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: #6c757d;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    position: relative;
}

.nav-link:hover {
    color: #495057;
    background: rgba(0, 123, 255, 0.04);
}

.nav-link:focus {
    outline: 2px solid #007bff;
    outline-offset: -2px;
    background: rgba(0, 123, 255, 0.04);
}

.nav-link.active {
    color: #007bff;
    border-bottom-color: #007bff;
    background: #fff;
    font-weight: 600;
}

.nav-link.completed {
    position: relative;
}

.completion-indicator {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    margin-right: 8px;
    background: #28a745;
    color: white;
    border-radius: 50%;
    font-size: 10px;
    line-height: 1;
    font-weight: 600;
}

/* Course content */
.course-content {
    background: #fff;
    min-height: 400px;
}

.tab-pane {
    display: none;
    padding: 32px;
    animation: fadeIn 0.2s ease;
}

.tab-pane.active {
    display: block;
}

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

.tab-content-visual {
    line-height: 1.7;
    color: #2c3e50;
}

.tab-content-visual h1,
.tab-content-visual h2,
.tab-content-visual h3,
.tab-content-visual h4,
.tab-content-visual h5,
.tab-content-visual h6 {
    margin: 0 0 16px 0;
    color: #2c3e50;
    font-weight: 600;
    line-height: 1.3;
}

.tab-content-visual h1 { font-size: 28px; margin-bottom: 20px; }
.tab-content-visual h2 { font-size: 24px; margin-top: 32px; }
.tab-content-visual h3 { font-size: 20px; margin-top: 24px; }
.tab-content-visual h4 { font-size: 18px; margin-top: 20px; }

.tab-content-visual p {
    margin-bottom: 16px;
    color: #34495e;
}

.tab-content-visual ul,
.tab-content-visual ol {
    margin-bottom: 16px;
    padding-left: 24px;
    color: #34495e;
}

.tab-content-visual li {
    margin-bottom: 8px;
}

.tab-content-visual a {
    color: #007bff;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color 0.2s ease;
}

.tab-content-visual a:hover {
    border-bottom-color: #007bff;
}

.tab-content-visual img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
    margin: 16px 0;
}

.tab-content-visual blockquote {
    margin: 24px 0;
    padding: 16px 20px;
    border-left: 4px solid #007bff;
    background: #f8f9fa;
    color: #495057;
    font-style: italic;
}

.tab-content-visual code {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 14px;
    color: #e83e8c;
}

.tab-content-text pre {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 4px;
    padding: 20px;
    overflow-x: auto;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    color: #495057;
}

/* Tab actions */
.tab-actions {
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid #e9ecef;
    text-align: right;
}

.complete-tab-btn {
    background: #28a745;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: none;
    letter-spacing: 0;
}

.complete-tab-btn:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(40, 167, 69, 0.2);
}

.complete-tab-btn:focus {
    outline: 2px solid #28a745;
    outline-offset: 2px;
}

.complete-tab-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

.complete-tab-btn.completed {
    background: #17a2b8;
}

.complete-tab-btn.completed:hover {
    background: #138496;
}

/* Course controls */
.course-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
}

.control-btn {
    display: flex;
    align-items: center;
    padding: 10px 16px;
    background: #007bff;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
}

.control-btn:hover:not(:disabled) {
    background: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.2);
}

.control-btn:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

.control-btn:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    opacity: 0.6;
}

.control-btn span {
    font-size: 16px;
    line-height: 1;
}

.prev-btn span {
    margin-right: 6px;
}

.next-btn span {
    margin-left: 6px;
}


/* Completion message */
.completion-message {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.2s ease;
}

.completion-content {
    background: white;
    padding: 32px;
    border-radius: 8px;
    text-align: center;
    max-width: 400px;
    margin: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.completion-content h3 {
    margin: 0 0 16px;
    color: #28a745;
    font-size: 24px;
    font-weight: 600;
}

.completion-content p {
    margin: 0;
    color: #6c757d;
    font-size: 16px;
    line-height: 1.5;
}

/* Error messages */
.edumodules-error {
    background: #f8d7da;
    color: #721c24;
    padding: 12px 16px;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
    margin: 16px 0;
    font-size: 14px;
}

/* Responsive iframes */
.iframe-container {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
    margin: 20px 0;
    overflow: hidden;
    border-radius: 4px;
}

.iframe-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: none;
}

/* Direct iframe styling for cases where container isn't applied */
.tab-content-visual iframe {
    max-width: 100%;
    height: auto;
    min-height: 100%;
    border-radius: 4px;
    margin: 16px 0;
}

/* Embed and object tags */
.tab-content-visual embed,
.tab-content-visual object {
    max-width: 100%;
    margin: 16px 0;
    border-radius: 4px;
}

/* Tables */
.tab-content-visual table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 14px;
}

.tab-content-visual th,
.tab-content-visual td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}

.tab-content-visual th {
    background: #f8f9fa;
    font-weight: 600;
    color: #495057;
}

/* Responsive design */
@media (max-width: 768px) {
    .edumodules-container {
        margin: 0;
        border-radius: 0;
        box-shadow: none;
        border: 1px solid #dee2e6;
    }

    .nav-toggle {
        display: block;
    }

    .nav-tabs {
        flex-direction: column;
        display: flex;
        overflow-x: visible;
    }

    .nav-tabs.collapsed {
        max-height: 0;
        padding: 0;
    }

    .nav-item {
        width: 100%;
        margin-bottom: 2px;
    }

    .nav-link {
        padding: 14px 16px;
        font-size: 13px;
        border-bottom: 1px solid #dee2e6;
        margin: 0;
        border-radius: 0;
        width: 100%;
        text-align: left;
    }

    .nav-link.active {
        border-bottom-color: #007bff;
        background: rgba(0, 123, 255, 0.04);
    }

    .tab-pane {
        padding: 24px 20px;
    }

    .course-controls {
        flex-direction: column;
        gap: 12px;
        padding: 16px;
    }

    .control-btn {
        width: 100%;
        justify-content: center;
    }

    .completion-content {
        padding: 24px 20px;
        margin: 16px;
    }

    .progress-container {
        padding: 12px 16px;
    }

    .tab-content-visual h1 { font-size: 24px; }
    .tab-content-visual h2 { font-size: 20px; }
}

/* Tablet optimizations */
@media (max-width: 1024px) and (min-width: 769px) {
    .nav-toggle {
        display: block;
    }

    .nav-tabs {
        overflow-y: auto;
    }

    .nav-tabs.collapsed {
        max-height: 0;
    }
}

@media (max-width: 480px) {
    .nav-tabs {
        overflow-x: visible;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        flex-direction: column;
        display: flex;
    }

    .nav-tabs.collapsed {
        max-height: 0;
        padding: 0;
    }

    .nav-link {
        padding: 12px 14px;
        font-size: 12px;
    }

    .completion-indicator {
        width: 14px;
        height: 14px;
        font-size: 9px;
        margin-right: 6px;
    }

    .tab-pane {
        padding: 20px 16px;
    }

    .complete-tab-btn {
        width: 100%;
        padding: 14px;
    }

    .tab-content-visual {
        font-size: 15px;
    }

    /* Responsive iframe adjustments for mobile */
    .iframe-container {
        padding-bottom: 75%; /* More square aspect ratio for mobile */
        margin: 16px 0;
    }

    .tab-content-visual iframe {
        min-height: 100%;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .edumodules-container {
        border: 2px solid currentColor;
    }

    .nav-link:focus,
    .control-btn:focus,
    .complete-tab-btn:focus {
        outline: 3px solid currentColor;
        outline-offset: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .tab-pane,
    .completion-message {
        animation: none;
    }

    .control-btn:hover:not(:disabled),
    .complete-tab-btn:hover {
        transform: none;
    }

    .loading-spinner {
        animation: none;
    }
}

/* Print styles */
@media print {
    .course-controls,
    .complete-tab-btn,
    .progress-container {
        display: none;
    }

    .edumodules-container {
        box-shadow: none;
        border: 1px solid #000;
    }

    .tab-pane {
        display: block !important;
        page-break-inside: avoid;
        border-top: 2px solid #000;
        margin-top: 20px;
    }

    .nav-tabs {
        display: none;
    }
}