/* === Reset & Base === */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #4f46e5;
    --primary-hover: #4338ca;
    --danger: #dc2626;
    --success: #16a34a;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.7;
    color: var(--gray-800);
    background: #fff;
}

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

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

/* === Auth Page === */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--gray-50);
}

.auth-container {
    width: 100%;
    max-width: 400px;
    padding: 0 20px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}
.auth-logo h1 {
    font-size: 28px;
    color: var(--primary);
}
.auth-logo p {
    color: var(--gray-500);
    margin-top: 4px;
}

.auth-form {
    background: #fff;
    padding: 32px;
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.auth-link {
    text-align: center;
    margin-top: 16px;
    font-size: 14px;
    color: var(--gray-500);
}

/* === Header === */
.site-header {
    background: #fff;
    border-bottom: 1px solid var(--gray-200);
    padding: 16px 0;
    position: sticky;
    top: 0;
    z-index: 100;
}
.site-header .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.site-logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--gray-900);
}
.site-logo:hover {
    text-decoration: none;
}
.site-nav {
    display: flex;
    align-items: center;
    gap: 16px;
}
.site-nav a {
    font-size: 15px;
    color: var(--gray-600);
}
.site-nav a:hover {
    color: var(--gray-900);
    text-decoration: none;
}
.viewer-name {
    font-size: 14px;
    color: var(--gray-500);
}

/* === Main === */
.site-main {
    padding: 40px 0;
    min-height: calc(100vh - 140px);
}

/* === Footer === */
.site-footer {
    background: var(--gray-50);
    border-top: 1px solid var(--gray-200);
    padding: 24px 0;
    text-align: center;
    font-size: 14px;
    color: var(--gray-400);
}

/* === Page Header === */
.page-header {
    margin-bottom: 32px;
}
.page-header h1 {
    font-size: 28px;
    font-weight: 700;
}

/* === Course Grid === */
.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 24px;
}

.course-card {
    display: block;
    background: #fff;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
    color: inherit;
}
.course-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    transform: translateY(-2px);
    text-decoration: none;
}

.course-card-image img {
    width: 100%;
    height: 200px;
    object-fit: cover;
    display: block;
}
.course-card-placeholder {
    width: 100%;
    height: 200px;
    background: var(--gray-100);
}

.course-card-body {
    padding: 20px;
}
.course-card-body h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
}
.course-card-body p {
    font-size: 14px;
    color: var(--gray-500);
    margin-bottom: 12px;
}
.course-card-price {
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
}

/* === Course Detail === */
.course-detail-header {
    display: flex;
    gap: 32px;
    margin-bottom: 32px;
}
.course-cover {
    width: 400px;
    border-radius: var(--radius);
    object-fit: cover;
    flex-shrink: 0;
}
.course-detail-info {
    flex: 1;
}
.course-detail-info h1 {
    font-size: 32px;
    font-weight: 700;
    margin-bottom: 16px;
}
.course-description {
    color: var(--gray-600);
    margin-bottom: 20px;
}
.course-price-box {
    padding: 16px 24px;
    background: var(--gray-50);
    border-radius: var(--radius);
    display: inline-block;
}
.course-price-box .price {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}
.course-unlocked {
    padding: 12px 20px;
    background: #f0fdf4;
    color: var(--success);
    border-radius: var(--radius);
    font-weight: 600;
    display: inline-block;
    border: 1px solid #bbf7d0;
}

/* === Redeem Box === */
.redeem-box {
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 24px;
}
.redeem-box h2 {
    font-size: 18px;
    margin-bottom: 8px;
}
.redeem-box p {
    color: var(--gray-600);
    margin-bottom: 16px;
}
.redeem-form {
    display: flex;
    gap: 12px;
    align-items: center;
}
.redeem-form input {
    flex: 1;
    max-width: 300px;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 16px;
    font-family: 'SF Mono', 'Fira Code', monospace;
}
.redeem-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* === Video === */
.video-container {
    border-radius: var(--radius);
    overflow: hidden;
    background: #000;
}
.video-container h2 {
    padding: 16px 20px 0;
    font-size: 18px;
    color: #fff;
}
.video-container video {
    width: 100%;
    display: block;
    max-height: 600px;
}

/* === Chapter List (Viewer) === */
.chapter-list-viewer h2 {
    font-size: 20px;
    margin-bottom: 16px;
}
.chapters {
    list-style: none;
    counter-reset: chapter;
}
.chapter-item-viewer {
    counter-increment: chapter;
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    margin-bottom: 8px;
    transition: background 0.15s;
}
.chapter-item-viewer a,
.chapter-item-viewer > div {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    color: inherit;
    text-decoration: none;
}
.chapter-item-viewer a::before,
.chapter-item-viewer > div::before {
    content: counter(chapter) ".";
    font-weight: 600;
    margin-right: 12px;
    color: var(--gray-400);
    min-width: 28px;
}
.chapter-item-viewer.unlocked:hover {
    background: var(--gray-50);
}
.chapter-item-viewer.unlocked a:hover {
    text-decoration: none;
}
.chapter-title {
    font-weight: 600;
    flex: 1;
}
.chapter-desc {
    font-size: 14px;
    color: var(--gray-500);
    margin-left: 12px;
}
.chapter-lock {
    font-size: 13px;
    color: var(--gray-400);
    padding: 2px 10px;
    background: var(--gray-100);
    border-radius: 12px;
}

/* === Chapter Detail === */
.chapter-detail h1 {
    font-size: 28px;
    margin-bottom: 20px;
}
.chapter-description {
    font-size: 16px;
    color: var(--gray-600);
    line-height: 1.8;
}

/* === Attachments === */
.attachment-list {
    list-style: none;
}
.attachment-list li {
    margin-bottom: 8px;
}
.attachment-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--gray-50);
    border: 1px solid var(--gray-200);
    border-radius: 6px;
    color: inherit;
    transition: background 0.15s;
}
.attachment-link:hover {
    background: var(--gray-100);
    text-decoration: none;
}
.attachment-name {
    font-weight: 500;
}
.attachment-size {
    font-size: 13px;
    color: var(--gray-400);
}

/* === Chapter Navigation === */
.chapter-navigation {
    display: flex;
    justify-content: space-between;
    padding-top: 32px;
    border-top: 1px solid var(--gray-200);
    margin-top: 32px;
}

/* === Alerts === */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 14px;
}
.alert-error {
    background: #fef2f2;
    color: var(--danger);
    border: 1px solid #fecaca;
}
.alert-success {
    background: #f0fdf4;
    color: var(--success);
    border: 1px solid #bbf7d0;
}

/* === Forms === */
.form-group {
    margin-bottom: 20px;
}
.form-group label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 6px;
    color: var(--gray-700);
}
.form-group input[type="text"],
.form-group input[type="email"],
.form-group input[type="password"] {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-300);
    border-radius: 6px;
    font-size: 15px;
    font-family: inherit;
}
.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}
.form-hint {
    font-size: 13px;
    color: var(--gray-500);
    margin-top: 4px;
}

/* === Buttons === */
.btn {
    display: inline-block;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    transition: background 0.15s;
    font-family: inherit;
}
.btn:hover {
    text-decoration: none;
}
.btn-primary {
    background: var(--primary);
    color: #fff;
}
.btn-primary:hover {
    background: var(--primary-hover);
}
.btn-secondary {
    background: var(--gray-200);
    color: var(--gray-700);
}
.btn-secondary:hover {
    background: var(--gray-300);
}
.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
}
.btn-block {
    display: block;
    width: 100%;
}

/* === Misc === */
.text-muted {
    color: var(--gray-500);
}
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }

/* === Responsive === */
@media (max-width: 768px) {
    .course-detail-header {
        flex-direction: column;
    }
    .course-cover {
        width: 100%;
        max-height: 300px;
    }
    .course-grid {
        grid-template-columns: 1fr;
    }
    .redeem-form {
        flex-direction: column;
    }
    .redeem-form input {
        max-width: 100%;
    }
    .chapter-navigation {
        flex-direction: column;
        gap: 12px;
    }
}
