/* ══════════════════════════════════════════════
   HOME APP — Instagram-inspired UI
   ══════════════════════════════════════════════ */

.home-container {
    height: 100vh;
    height: 100dvh;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    background: var(--bg-primary);
}

/* ── Bottom Tab Bar ── */
.tabs-navigation {
    display: flex;
    justify-content: space-around;
    align-items: center;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 50px;
    background: var(--bg-primary);
    border-top: 1px solid var(--separator);
    z-index: 1000;
    padding: 0;
    border-radius: 0;
    backdrop-filter: none;
    box-shadow: none;
}

.tab-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    cursor: pointer;
    transition: color .15s;
    border-radius: 0;
    height: auto;
    font-family: inherit;
    position: relative;
}

.tab-btn i {
    font-size: 1.375rem;
    line-height: 1;
}

.tab-btn svg {
    display: none;
}

.tab-btn span {
    font-size: .625rem;
    font-weight: 500;
    letter-spacing: .02em;
}

.tab-btn:hover {
    color: var(--text-primary);
    background: none;
}

.tab-btn.active {
    color: var(--text-primary);
    transform: none;
}

/* ── Tab Content ── */
.tabs-content {
    flex: 1;
    overflow: hidden;
}

.tab-pane {
    display: none;
    height: 100%;
    overflow-y: auto;
    padding-bottom: 50px;
}

.tab-pane.active {
    display: block;
}

/* Custom scrollbar for non-home tabs */
.tab-pane:not(#tab-home)::-webkit-scrollbar {
    width: 4px;
}

.tab-pane:not(#tab-home)::-webkit-scrollbar-track {
    background: transparent;
}

.tab-pane:not(#tab-home)::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}

/* ══════════════════════════════════════════════
   HOME TAB — Reels / Feed
   ══════════════════════════════════════════════ */
#tab-home {
    overflow: hidden;
    background: #000;
}

.reels-container {
    height: 100%;
    scroll-snap-type: y mandatory;
    overflow-y: scroll;
    scrollbar-width: none;
}

.reels-container::-webkit-scrollbar {
    display: none;
}

.reel-item {
    height: 100%;
    width: 100%;
    scroll-snap-align: start;
    scroll-snap-stop: always;
    position: relative;
    background: #000;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Video always shown in portrait box — landscape videos fit inside portrait container */
.reel-video {
    height: 100%;
    width: 100%;
    object-fit: contain;
    background: #000;
}

/* Play icon overlay */
.reel-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    pointer-events: none;
    width: 64px;
    height: 64px;
    display: none;
    align-items: center;
    justify-content: center;
    transition: opacity .2s;
}

.reel-play-icon i {
    font-size: 3rem;
    color: rgba(255, 255, 255, .85);
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, .5));
}

/* Bottom-left info overlay */
.reel-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1.5rem 1rem 1rem;
    color: #fff;
    pointer-events: none;
    z-index: 100;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.75));
}

.reel-info {
    padding-right: 72px;
}

.reel-overlay * {
    pointer-events: auto;
}

.reel-info h3 {
    font-size: .8125rem;
    font-weight: 700;
    margin-bottom: .25rem;
}

.reel-info .reel-title {
    font-size: .9375rem;
    font-weight: 600;
    margin-bottom: .25rem;
    line-height: 1.3;
}

.reel-info small {
    font-size: .75rem;
    color: rgba(255, 255, 255, .6);
}

.reel-description-container {
    margin-bottom: .375rem;
}

.reel-description {
    font-size: .8125rem;
    line-height: 1.4;
    color: rgba(255, 255, 255, .85);
    margin: 0;
}

.read-more {
    font-size: .8125rem;
    font-weight: 600;
    color: rgba(255, 255, 255, .5);
    cursor: pointer;
    display: inline;
    margin-left: 4px;
}

.read-more:hover {
    color: #fff;
}

/* Right-side action buttons */
.reel-actions {
    position: absolute;
    right: .75rem;
    bottom: 80px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    z-index: 100;
}

.action-btn {
    background: none;
    border: none;
    color: #fff;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: transform .15s;
    width: 40px;
    padding: 0;
}

.action-btn i {
    font-size: 1.625rem;
    filter: drop-shadow(0 1px 3px rgba(0, 0, 0, .5));
}

.action-btn:hover {
    transform: scale(1.1);
}

.action-btn span.count {
    font-size: .6875rem;
    font-weight: 600;
}

.action-btn.liked i {
    color: var(--danger);
}

.action-btn.favorited i {
    color: var(--warning);
}

.action-btn.completed i {
    color: var(--success);
}

/* ── Loading ── */
.reel-loading {
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── End of feed ── */
.end-message {
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    color: var(--text-primary);
    padding: 2rem;
}

.end-message .glass {
    padding: 2rem;
    border-radius: var(--radius-md);
}

/* ══════════════════════════════════════════════
   ROADMAP TAB
   ══════════════════════════════════════════════ */
.roadmap-header {
    padding: 1.5rem 1rem .75rem;
    max-width: 600px;
    margin: 0 auto;
}

.roadmap-header h1 {
    font-size: 1.375rem;
    margin-bottom: .25rem;
}

.roadmap-header p {
    color: var(--text-secondary);
    font-size: .875rem;
}

.roadmap-tree {
    padding: 0 1rem 2rem;
    max-width: 600px;
    margin: 0 auto;
}

.roadmap-step {
    position: relative;
    padding-left: 1.75rem;
    margin-bottom: 0;
    border-left: 2px solid var(--border-color);
    padding-bottom: 1.5rem;
}

.roadmap-step:last-child {
    border-left-color: transparent;
    padding-bottom: 0;
}

.roadmap-step::before {
    content: '';
    position: absolute;
    left: -5px;
    top: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
    border: 2px solid var(--bg-primary);
}

.step-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: var(--radius-md);
    transition: border-color .15s;
}

.step-card:hover {
    border-color: var(--border-light);
}

.step-card h4 {
    font-size: .9375rem;
    font-weight: 600;
    margin: 0;
}

.step-card p {
    font-size: .8125rem;
    color: var(--text-secondary);
    margin-top: .25rem;
}

.step-card .btn {
    margin-top: .5rem;
}

.step-children {
    margin-top: .75rem;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.step-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-badge {
    background: rgba(88, 195, 34, .12);
    color: var(--success);
    padding: .125rem .5rem;
    border-radius: 999px;
    font-size: .6875rem;
    font-weight: 600;
    text-transform: uppercase;
}

.step-completed::before {
    background: var(--success);
}

.step-completed .step-card {
    border-color: rgba(88, 195, 34, .25);
}

/* ══════════════════════════════════════════════
   PLAYLISTS TAB
   ══════════════════════════════════════════════ */
.lessons-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: .75rem;
    padding: 0 1rem;
    max-width: 600px;
    margin: 0 auto;
}

.playlist-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    overflow: hidden;
    transition: border-color .15s;
    cursor: pointer;
}

.playlist-card:hover {
    border-color: var(--border-light);
    transform: none;
}

.playlist-info {
    padding: 1rem;
}

.playlist-info h4 {
    font-size: .9375rem;
    font-weight: 600;
    margin: 0 0 .375rem 0;
    background: none;
    -webkit-background-clip: unset;
    -webkit-text-fill-color: unset;
    color: var(--text-primary);
}

.playlist-info p {
    font-size: .8125rem;
    color: var(--text-secondary);
    margin: 0;
}

.playlist-info small {
    font-size: .75rem;
    color: var(--text-muted);
}

.playlist-info .btn {
    font-size: .75rem;
    padding: .3rem .6rem;
}

/* ══════════════════════════════════════════════
   PROFILE TAB
   ══════════════════════════════════════════════ */
.profile-grid {
    max-width: 600px;
    margin: 0 auto;
    padding: 0 1rem;
}

.profile-card {
    padding: 1.5rem;
    border-radius: var(--radius-md);
    text-align: center;
    margin-bottom: 1rem;
}

.profile-header {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .75rem;
    margin-bottom: 1.25rem;
}

#profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    object-fit: cover;
}

.profile-info h2 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.profile-info p {
    font-size: .875rem;
    color: var(--text-secondary);
    margin: .125rem 0 0;
}

.profile-actions {
    display: flex;
    flex-direction: column;
    gap: .5rem;
    align-items: stretch;
}

.profile-actions .btn {
    width: 100%;
}

.profile-guest-state {
    padding: 2rem 1rem;
}

.profile-guest-state h3 {
    font-size: 1.25rem;
    margin-bottom: .5rem;
}

.profile-guest-state p {
    color: var(--text-secondary);
    font-size: .875rem;
    margin-bottom: 1rem;
}

/* Password reset inline form */
#password-reset-form {
    background: var(--bg-primary) !important;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 1rem !important;
    text-align: left;
}

#password-reset-form h4 {
    font-size: .9375rem;
    font-weight: 600;
    margin-bottom: .75rem;
}

#password-reset-form .form-group {
    margin-bottom: .75rem;
}

#password-reset-form label {
    font-size: .75rem;
    font-weight: 500;
    color: var(--text-secondary);
    display: block;
    margin-bottom: .25rem;
}

#password-reset-form .form-input {
    width: 100%;
    padding: .5rem .625rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: .875rem;
    font-family: inherit;
}

#password-reset-form .form-input:focus {
    outline: none;
    border-color: var(--border-light);
}

.favorites-section,
.progress-section {
    margin-bottom: 1rem;
}

.favorites-section h3,
.progress-section h3 {
    font-size: .9375rem;
    font-weight: 600;
    padding: .75rem 0 .5rem;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: .75rem;
}

.lesson-mini-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: .75rem;
    display: flex;
    align-items: center;
    gap: .75rem;
}

.lesson-mini-card h5 {
    font-size: .875rem;
    font-weight: 600;
    margin: 0;
    flex: 1;
}

.lesson-mini-card small {
    color: var(--text-muted);
    font-size: .75rem;
}

.lesson-mini-card .btn {
    flex-shrink: 0;
}

/* ══════════════════════════════════════════════
   LANGUAGE SELECTOR
   ══════════════════════════════════════════════ */
.lang-selector-container {
    position: fixed;
    top: 4px;
    right: .75rem;
    z-index: 1100;
}

.lang-select {
    background: rgba(0, 0, 0, .6);
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-color);
    color: #fff;
    padding: .375rem .5rem;
    border-radius: var(--radius-sm);
    outline: none;
    cursor: pointer;
    font-family: inherit;
    font-size: .75rem;
    font-weight: 500;
}

.lang-select option {
    background: var(--bg-secondary);
    color: #fff;
}

/* ══════════════════════════════════════════════
   MODALS — Clean, minimal, shadcn-style
   ══════════════════════════════════════════════ */
.modal {
    position: fixed;
    inset: 0;
    background: var(--overlay);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    backdrop-filter: blur(4px);
}

.modal-content {
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 92%;
    max-width: 480px;
    max-height: 85vh;
    position: relative;
    overflow: hidden;
    animation: modalSlideUp .25s ease-out;
}

@keyframes modalSlideUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: .875rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
    font-size: .9375rem;
    font-weight: 600;
    margin: 0;
}

.close-modal {
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 1.25rem;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 50%;
    transition: background .15s;
    position: static;
}

.close-modal:hover {
    background: var(--bg-elevated);
    transform: none;
}

/* ── Comment Modal ── */
.comment-modal-content {
    max-width: 420px;
    display: flex;
    flex-direction: column;
    max-height: 70vh;
}

.comments-list {
    flex: 1;
    overflow-y: auto;
    padding: .75rem 1rem;
    min-height: 120px;
}

.comments-list::-webkit-scrollbar {
    width: 3px;
}

.comments-list::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.comment-item {
    padding: .5rem 0;
    font-size: .8125rem;
    line-height: 1.4;
    border-bottom: 1px solid var(--border-color);
}

.comment-item:last-child {
    border-bottom: none;
}

.comment-item strong {
    font-weight: 600;
    margin-right: .375rem;
}

.comment-input-area {
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .625rem .75rem;
    border-top: 1px solid var(--border-color);
}

.comment-input-area textarea {
    flex: 1;
    resize: none;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-family: inherit;
    font-size: .875rem;
    padding: .25rem 0;
    outline: none;
    min-height: 20px;
    max-height: 80px;
}

.comment-input-area textarea::placeholder {
    color: var(--text-muted);
}

.comment-input-area button {
    background: none;
    border: none;
    color: var(--primary);
    font-weight: 600;
    font-size: .875rem;
    cursor: pointer;
    font-family: inherit;
    opacity: .7;
    transition: opacity .15s;
}

.comment-input-area button:hover {
    opacity: 1;
}

/* ── Lesson Player Modal ── */
.lesson-player-content {
    max-width: 520px !important;
    padding: 0 !important;
    border-radius: var(--radius-lg) !important;
}

.lesson-player-content .modal-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 10;
    background: linear-gradient(rgba(0, 0, 0, .6), transparent);
    border-bottom: none;
    padding: .75rem 1rem;
}

.lesson-player-content .modal-header h3 {
    color: #fff;
    font-size: .875rem;
}

.lesson-player-content .close-modal {
    color: #fff;
}

.lesson-player-content .close-modal:hover {
    background: rgba(255, 255, 255, .15);
}

.player-container {
    width: 100%;
    aspect-ratio: 9/16;
    max-height: 70vh;
    background: #000;
    position: relative;
    overflow: hidden;
}

#player-video {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Styled video controls for player modal */
.player-container video::-webkit-media-controls-panel {
    background: linear-gradient(transparent, rgba(0, 0, 0, .7));
}

.player-info {
    padding: 1rem;
    border-top: 1px solid var(--border-color);
}

.player-info p {
    font-size: .8125rem;
    color: var(--text-secondary);
}

.player-controls {
    display: flex;
    gap: .5rem;
    margin-top: .75rem;
}

.player-controls .btn {
    flex: 1;
    font-size: .8125rem;
}

/* ══════════════════════════════════════════════
   DESKTOP RESPONSIVE — IG-like centered feed
   ══════════════════════════════════════════════ */
@media (min-width: 640px) {
    .home-container {
        max-width: 100%;
    }

    .tabs-navigation {
        position: fixed;
        bottom: auto;
        top: 0;
        left: 0;
        width: 64px;
        height: 100vh;
        flex-direction: column;
        justify-content: flex-start;
        padding: 1rem .25rem 0;
        gap: 0;
        border-top: none;
        border-right: 1px solid var(--separator);
        background: var(--bg-primary);
    }

    .tab-btn {
        width: 100%;
        padding: .625rem .25rem;
        border-radius: var(--radius-sm);
        margin: 0;
    }

    .tab-btn:hover {
        background: rgba(255, 255, 255, .05);
    }

    .tab-btn span {
        font-size: .5625rem;
    }

    .tabs-content {
        margin-left: 64px;
    }

    .tab-pane {
        padding-bottom: 0;
    }

    .reels-container {
        max-width: 420px;
        margin: 0 auto;
        border-left: 1px solid var(--border-color);
        border-right: 1px solid var(--border-color);
    }

    .reel-overlay {
        bottom: 0;
    }

    .reel-actions {
        bottom: 32px;
    }

    .roadmap-header,
    .roadmap-tree {
        max-width: 560px;
    }

    .lessons-grid {
        max-width: 560px;
    }

    .profile-grid {
        max-width: 560px;
    }

    .lang-selector-container {
        top: .75rem;
        right: .75rem;
    }
}

/* Larger desktops */
@media (min-width: 1024px) {
    .reels-container {
        max-width: 460px;
    }

    .tabs-navigation {
        width: 180px;
        padding: 1rem .375rem 0;
        gap: 1rem;
    }

    .tab-btn {
        flex-direction: row;
        justify-content: flex-start;
        gap: .625rem;
        padding: .5rem .75rem;
    }

    .tab-btn i {
        font-size: 1.25rem;
    }

    .tab-btn span {
        font-size: .8125rem;
    }

    .tabs-content {
        margin-left: 180px;
    }
}

/* ── Spinner ── */
.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid rgba(255, 255, 255, .1);
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ── Preview Badge ── */
.preview-badge-container {
    position: fixed;
    top: 6px;
    left: .75rem;
    z-index: 1100;
    pointer-events: auto;
}

.preview-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(253, 203, 92, 0.1);
    border: 1px solid rgba(253, 203, 92, 0.25);
    color: var(--warning);
    padding: .3rem .55rem;
    border-radius: var(--radius-sm);
    font-size: .7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    cursor: help;
    transition: background-color .15s, border-color .15s;
}

.preview-badge:hover {
    background: rgba(253, 203, 92, 0.15);
    border-color: rgba(253, 203, 92, 0.4);
}

.badge-dot {
    width: 6px;
    height: 6px;
    background-color: var(--warning);
    border-radius: 50%;
    display: inline-block;
    position: relative;
}

.badge-dot::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: var(--warning);
    animation: badge-pulse 2s infinite ease-in-out;
}

@keyframes badge-pulse {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    100% {
        transform: scale(2.4);
        opacity: 0;
    }
}

@media (min-width: 640px) {
    .preview-badge-container {
        top: .75rem;
        left: 80px;
    }
}

@media (min-width: 1024px) {
    .preview-badge-container {
        top: .75rem;
        left: 196px;
    }
}