/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    line-height: 1.6;
    color: #000;
    background: #fff;
}

/* App Container */
#app {
    max-width: 600px;
    margin: 0 auto;
    min-height: 100vh;
    border-left: 1px solid #000;
    border-right: 1px solid #000;
    position: relative;
}

/* Header */
#header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 2px solid #000;
    background: #fff;
    position: sticky;
    top: 0;
    z-index: 100;
}

#page-title {
    font-size: 18px;
    font-weight: 600;
    position: absolute;
    left: 60px;
    right: 60px;
    text-align: center;
    pointer-events: none;
}

#menu-btn, #back-btn {
    z-index: 1;
}

.icon-btn {
    background: none;
    border: 1px solid #000;
    padding: 8px 12px;
    font-size: 18px;
    cursor: pointer;
    border-radius: 4px;
}

.icon-btn:hover {
    background: #f0f0f0;
}

/* Main Content */
#content {
    position: relative;
    min-height: calc(100vh - 60px);
}

.screen {
    display: none;
    padding: 16px;
    animation: fadeIn 0.2s ease-in;
}

.screen.active {
    display: block;
}

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

/* Welcome Section */
.welcome-section {
    padding: 48px 16px;
    text-align: center;
    margin-bottom: 24px;
}

.app-image-placeholder {
    width: 200px;
    height: 200px;
    border: 1px solid #999;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    color: #999;
    background: #f5f5f5;
    margin: 0 auto 24px;
}

.welcome-subtitle {
    font-size: 18px;
    color: #666;
    margin-bottom: 8px;
}

.welcome-section h2 {
    font-size: 28px;
    font-weight: 700;
    margin: 0;
}

/* Hero Video Section */
.hero-section {
    text-align: center;
    padding: 32px 16px 24px;
}

.hero-video-frame {
    position: relative;
    border: 2px solid #000;
    border-radius: 12px;
    aspect-ratio: 16/9;
    background: #1a1a1a;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    cursor: pointer;
    margin-bottom: 24px;
}

.hero-play-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.hero-play-circle {
    width: 64px;
    height: 64px;
    border: 3px solid #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
}

.hero-video-frame:hover .hero-play-circle {
    background: rgba(0, 0, 0, 0.7);
}

.hero-video-label {
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    position: absolute;
    bottom: 32px;
}

.hero-video-subtitle {
    color: #ccc;
    font-size: 14px;
    position: absolute;
    bottom: 14px;
}

.hero-image {
    margin-bottom: 24px;
}

/* 2x2 Navigation Grid */
.nav-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    padding: 0 16px 24px;
}

.grid-tile {
    border: 2px solid #000;
    border-radius: 12px;
    padding: 20px 12px;
    cursor: pointer;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-height: 130px;
    justify-content: center;
}

.grid-tile:hover {
    background: #f0f0f0;
}

.grid-tile-icon {
    margin-bottom: 4px;
    color: #333;
    line-height: 0;
}

.grid-tile h3 {
    font-size: 15px;
    font-weight: 600;
    margin: 0;
}

.grid-tile p {
    font-size: 12px;
    color: #666;
    margin: 0;
    line-height: 1.3;
}

.grid-tile.locked {
    border-color: #ccc;
    background: #fafafa;
}

.grid-tile.locked .grid-tile-icon {
    color: #999;
}

.grid-tile.locked h3 {
    color: #999;
}

.grid-tile .grid-lock-icon {
    color: #999;
    display: inline-flex;
    align-items: center;
}

/* Navigation List */
.nav-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.nav-card {
    border: 2px solid #000;
    padding: 20px;
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    gap: 20px;
    border-radius: 12px;
}

.nav-card:hover:not(.disabled) {
    background: #f0f0f0;
}

.nav-card.disabled {
    border-color: #ccc;
    color: #999;
    cursor: not-allowed;
}

.card-icon {
    width: 48px;
    height: 48px;
    border: 1px solid #000;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    flex-shrink: 0;
    background: #f5f5f5;
}

.nav-card.disabled .card-icon {
    border-color: #ccc;
    background: #fafafa;
}

.card-content {
    flex-grow: 1;
}

.card-content h3 {
    font-size: 18px;
    font-weight: 600;
    margin: 0 0 4px 0;
}

.card-content p {
    font-size: 14px;
    line-height: 1.4;
    margin: 0;
    color: #666;
}

.nav-card.disabled .card-content p {
    color: #999;
}

.card-arrow {
    font-size: 24px;
    color: #999;
    flex-shrink: 0;
}

.badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #000;
    color: #fff;
    padding: 4px 8px;
    font-size: 11px;
    border-radius: 3px;
}

.source-badge.local {
    background: #2e7d32;
}

.source-badge.online {
    background: #1565c0;
}

/* Drawer clip container — fixed overlay matching app bounds, clips the drawer */
#drawer-clip {
    position: fixed;
    top: 0;
    left: max(0px, calc((100vw - 600px) / 2));
    width: min(600px, 100vw);
    height: 100vh;
    overflow: hidden;
    pointer-events: none;
    z-index: 200;
}

/* Drawer Menu */
.drawer {
    position: absolute;
    top: 0;
    left: 1px;
    width: 280px;
    height: 100%;
    background: #fff;
    border-left: 1px solid #000;
    border-right: 2px solid #000;
    z-index: 200;
    transition: transform 0.3s ease;
    overflow-y: auto;
    transform: translateX(calc(-100% - 1px));
    pointer-events: auto;
}

.drawer.open {
    transform: translateX(0);
}

.drawer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 2px solid #000;
}

.drawer-header h2 {
    font-size: 20px;
}

.drawer-nav {
    display: flex;
    flex-direction: column;
}

.drawer-nav a {
    padding: 16px;
    border-bottom: 1px solid #ddd;
    text-decoration: none;
    color: #000;
    font-size: 16px;
}

.drawer-nav a:hover:not(.disabled) {
    background: #f0f0f0;
}

.drawer-nav a.disabled {
    color: #999;
    cursor: not-allowed;
}

.drawer-divider {
    height: 0;
    margin: 0;
}

/* Content Section */
.content-section {
    max-width: 100%;
}

.content-section h2 {
    font-size: 24px;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 2px solid #000;
}

.content-section h3 {
    font-size: 18px;
    margin: 20px 0 12px;
}

.content-section p {
    margin-bottom: 12px;
    line-height: 1.6;
}

.content-section ul {
    margin-left: 24px;
    margin-bottom: 16px;
}

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

.section-description {
    font-size: 16px;
    margin-bottom: 24px;
    padding: 12px;
    border: 1px solid #000;
    background: #f9f9f9;
}

/* Section List */
.section-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.section-card {
    border: 2px solid #000;
    padding: 16px;
    cursor: pointer;
    position: relative;
}

.section-card:hover:not(.no-link) {
    background: #f0f0f0;
}

.section-card.no-link {
    cursor: default;
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0;
}

.section-header h3 {
    font-size: 18px;
    margin: 0;
}

.arrow {
    font-size: 24px;
    color: #999;
}

.section-card p {
    font-size: 14px;
    margin: 0;
    line-height: 1.4;
}

.info-icon {
    width: 20px;
    height: 20px;
    border: 1.5px solid #666;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-style: italic;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    font-family: Georgia, serif;
    margin-left: 8px;
    vertical-align: middle;
}

.info-icon:hover {
    background: #eee;
    border-color: #333;
    color: #333;
}

/* Groups Container */
.groups-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.group-section {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.group-header {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-bottom: 8px;
}

.group-title {
    font-size: 16px;
    font-weight: 600;
    color: #000;
    flex-grow: 1;
}

.group-info-icon {
    width: 20px;
    height: 20px;
    border: 1.5px solid #666;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-style: italic;
    font-weight: 600;
    color: #666;
    cursor: pointer;
    font-family: Georgia, serif;
    flex-shrink: 0;
}

.group-info-icon:hover {
    background: #eee;
    border-color: #333;
    color: #333;
}

/* Chapter Cards */
.chapter-card {
    border: 1px solid #000;
    padding: 12px;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.chapter-card:hover {
    background: #f0f0f0;
}

.chapter-number {
    width: 36px;
    height: 36px;
    border: 2px solid #000;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    flex-shrink: 0;
}

.chapter-content {
    flex-grow: 1;
}

.chapter-description {
    font-size: 14px;
    line-height: 1.4;
}

.chapter-description.primary {
    font-size: 16px;
    font-weight: 600;
}

.chapter-info-icon {
    width: 18px;
    height: 18px;
    border: 1.5px solid #999;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-style: italic;
    font-weight: 600;
    color: #999;
    cursor: pointer;
    font-family: Georgia, serif;
    margin-left: 6px;
    vertical-align: middle;
    flex-shrink: 0;
}

.chapter-info-icon:hover {
    background: #eee;
    border-color: #333;
    color: #333;
}

.chapter-play-icon {
    font-size: 56px;
    color: #666;
    flex-shrink: 0;
    line-height: 1;
}

/* Day List */
.day-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.day-card {
    border: 2px solid #000;
    padding: 16px;
    cursor: pointer;
}

.day-card:hover {
    background: #f0f0f0;
}

.day-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.day-header h3 {
    font-size: 18px;
    margin: 0;
}

/* Exercises Container */
.exercises-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.exercise-card {
    border: 1px solid #000;
    padding: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
}

.exercise-card:hover {
    background: #f0f0f0;
}

.exercise-title {
    flex-grow: 1;
    font-size: 14px;
    font-weight: 500;
}

.play-icon {
    font-size: 24px;
}

/* Video Placeholder */
.video-placeholder {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.video-frame {
    border: 2px solid #000;
    aspect-ratio: 16/9;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f0f0f0;
    font-size: 36px;
}

.video-frame .note {
    font-size: 14px;
    margin-top: 8px;
}

.video-breadcrumb {
    font-size: 13px;
    color: #666;
    margin-bottom: 4px;
}

.video-info h3 {
    font-size: 18px;
    margin-bottom: 8px;
}

.video-info p {
    font-size: 14px;
    line-height: 1.4;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 300;
    align-items: center;
    justify-content: center;
}

.modal.open {
    display: flex;
}

.modal-content {
    background: #fff;
    border: 2px solid #000;
    max-width: 500px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 2px solid #000;
}

.modal-header h3 {
    font-size: 18px;
    margin: 0;
}

.modal-body {
    padding: 16px;
    overflow-y: auto;
}

.modal-body p {
    line-height: 1.6;
}

/* Purchase Modal */
.purchase-modal-content {
    text-align: center;
}

.purchase-cart-icon {
    margin: 8px 0 16px;
}

.purchase-modal-text {
    font-size: 15px;
    margin-bottom: 16px;
}

.purchase-modal-package {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 20px;
    text-align: left;
}

.purchase-package-name {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 4px;
}

.purchase-package-desc {
    font-size: 13px;
    color: #666;
}

.purchase-btn {
    display: block;
    width: 100%;
    padding: 14px;
    border: 2px solid #000;
    background: #000;
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    border-radius: 6px;
}

.purchase-btn:hover {
    opacity: 0.85;
}

.purchase-btn-all {
    background: #fff;
    color: #000;
}

.purchase-btn-all:hover {
    background: #f0f0f0;
}

.purchase-divider-text {
    padding: 10px 0;
    color: #999;
    font-size: 13px;
}

.purchase-note {
    margin-top: 16px;
    font-size: 11px;
    color: #999;
    font-style: italic;
}

/* Locked section card styling */
.section-card.locked {
    border-color: #ccc;
    background: #fafafa;
}

.section-card.locked .section-header h3 {
    color: #999;
}

.section-lock-icon {
    margin-left: 8px;
    color: #999;
    display: inline-flex;
    align-items: center;
}

.card-lock-icon {
    margin-left: 8px;
    color: #999;
    display: inline-flex;
    align-items: center;
}

/* Locked download item */
.download-item-status.locked-download {
    background: #f5f5f5;
    color: #999;
}

/* Chapter Status Indicator (offline/online/locked icon) */
.chapter-status-icon {
    flex-shrink: 0;
    align-self: center;
    font-size: 14px;
    width: 22px;
    text-align: center;
}

.chapter-status-icon.offline {
    color: #2e7d32;
    font-weight: bold;
}

.chapter-status-icon.online {
    color: #1565c0;
}

.chapter-status-icon.locked {
    color: #999;
    font-size: 13px;
}

/* Video Player — Fixed Bottom Status Toast */
.video-status-toast {
    position: fixed;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 600px;
    display: none;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    background: #fff;
    border-top: 2px solid #000;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
    z-index: 100;
}

.video-status-toast.visible {
    display: flex;
}

#video-player-screen {
    padding-bottom: 56px;
}

.video-source-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #1565c0;
    font-weight: 500;
}

.video-source-indicator.offline {
    color: #2e7d32;
}

.source-icon {
    font-size: 18px;
}

.video-download-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 2px solid #000;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
}

.video-download-btn:hover {
    background: #f0f0f0;
}

.download-btn-icon {
    font-size: 16px;
}

/* Downloads Management Screen */
.downloads-summary {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 16px;
    margin-bottom: 16px;
}

.downloads-summary-text {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 14px;
}

.downloads-count {
    font-weight: 600;
}

.downloads-size {
    color: #666;
}

.downloads-bar {
    height: 6px;
    background: #ddd;
    border-radius: 3px;
    overflow: hidden;
}

.downloads-bar-fill {
    height: 100%;
    background: #2e7d32;
    border-radius: 3px;
    transition: width 0.3s ease;
}

.downloads-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.downloads-action-btn {
    flex: 1;
    padding: 10px 16px;
    border: 2px solid #000;
    background: #000;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

.downloads-action-btn:hover {
    opacity: 0.85;
}

.downloads-action-btn.secondary {
    background: #fff;
    color: #000;
}

.downloads-action-btn.secondary:hover {
    background: #f0f0f0;
}

.downloads-group {
    margin-bottom: 24px;
}

.downloads-group-header {
    font-size: 13px;
    font-weight: bold;
    color: #666;
    letter-spacing: 0.5px;
    padding-bottom: 8px;
    border-bottom: 1px solid #ddd;
    margin-bottom: 4px;
}

.download-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
}

.download-item-info {
    flex: 1;
}

.download-item-title {
    font-size: 15px;
    font-weight: 500;
}

.download-item-meta {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

.download-item-status {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 500;
    flex-shrink: 0;
    cursor: pointer;
}

.download-item-status.downloaded {
    background: #e8f5e9;
    color: #2e7d32;
}

.download-item-status.online {
    background: #e3f2fd;
    color: #1565c0;
}

.download-item-status.downloading {
    background: #fff3e0;
    color: #e65100;
}

.download-status-icon {
    font-size: 14px;
    font-weight: bold;
}

.download-progress-ring {
    width: 16px;
    height: 16px;
    border: 2px solid #e65100;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Settings Screen */
.settings-section-header {
    font-size: 13px;
    font-weight: bold;
    color: #666;
    letter-spacing: 0.5px;
    padding: 16px 0 4px;
}

.settings-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    cursor: pointer;
}

.settings-item:hover {
    background: #f5f5f5;
    margin: 0 -16px;
    padding: 12px 16px;
}

.settings-item-icon {
    width: 24px;
    text-align: center;
    font-size: 18px;
    color: #666;
    flex-shrink: 0;
    margin-top: 2px;
}

.settings-item-content {
    flex: 1;
}

.settings-item-title {
    font-size: 16px;
    font-weight: 500;
}

.settings-item-subtitle {
    font-size: 13px;
    color: #666;
    margin-top: 2px;
}

.settings-item-arrow {
    font-size: 20px;
    color: #999;
    flex-shrink: 0;
}

.settings-divider {
    height: 1px;
    background: #ddd;
    margin: 8px 0;
}

/* Responsive */
@media (max-width: 480px) {
    #page-title {
        font-size: 16px;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .welcome-section {
        padding: 16px;
    }
}
