/**
 * Channel Detail Page Styles
 * @created 2025-12-03
 */

/* Back Navigation */
.back-navigation {
    margin-bottom: 20px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: #4a5568;
    text-decoration: none;
    font-weight: 500;
    padding: 8px 12px;
    background: #f7fafc;
    border-radius: 6px;
    transition: all 0.2s;
}

.back-link:hover {
    background: #edf2f7;
    color: #2d3748;
}

/* Channel Header */
.channel-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 20px;
    margin-bottom: 25px;
    padding: 20px;
    background: var(--gradient-primary);
    border-radius: 12px;
    color: white;
}

.channel-title-section h1 {
    margin: 0 0 10px 0;
    font-size: 1.8em;
    color: white;
}

.channel-stats {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.stat-badge {
    display: inline-block;
    padding: 4px 10px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    font-size: 0.85em;
}

.stat-badge.imported {
    background: rgba(72, 187, 120, 0.3);
}

.stat-badge.available {
    background: rgba(237, 137, 54, 0.3);
}

.stat-badge.blocked {
    background: rgba(229, 62, 62, 0.3);
}

.cache-info {
    font-size: 0.8em;
    opacity: 0.7;
}

/* Balance Section */
.balance-section {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
}

.balance-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.balance-label {
    font-size: 0.85em;
    opacity: 0.9;
}

.balance-amount {
    font-size: 1.4em;
    font-weight: 700;
}

.topup-btn {
    padding: 6px 14px;
    background: white;
    color: var(--color-primary);
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.topup-btn:hover {
    background: #f0f0f0;
    transform: translateY(-1px);
}

/* Filter Bar */
.filter-bar {
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
    margin-bottom: 20px;
    padding: 15px;
    background: #f7fafc;
    border-radius: 8px;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-weight: 500;
    color: #4a5568;
    font-size: 0.9em;
}

.filter-select {
    padding: 8px 12px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: white;
    font-size: 0.9em;
    min-width: 180px;
}

.refresh-btn {
    padding: 8px 14px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.refresh-btn:hover {
    background: var(--color-primary-dark);
}

/* Stats Summary */
.stats-summary {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.stat-item {
    flex: 1;
    text-align: center;
    padding: 15px;
    background: #f7fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.stat-item.stat-imported {
    background: #f0fff4;
    border-color: #9ae6b4;
}

.stat-item.stat-available {
    background: #fffaf0;
    border-color: #fbd38d;
}

.stat-item.stat-blocked {
    background: #fff5f5;
    border-color: #feb2b2;
}

.stat-number {
    display: block;
    font-size: 1.8em;
    font-weight: 700;
    color: #2d3748;
}

.stat-label {
    font-size: 0.85em;
    color: #718096;
}

/* URL Import Section */
.url-import-section {
    margin-bottom: 20px;
    padding: 16px 20px;
    background: #f0f4ff;
    border: 1px solid #c7d2fe;
    border-radius: 10px;
}

.url-import-header h3 {
    margin: 0 0 4px 0;
    font-size: 1em;
    font-weight: 600;
    color: #2d3748;
}

.url-import-subtitle {
    margin: 0 0 12px 0;
    font-size: 0.85em;
    color: #718096;
}

.url-import-form {
    display: flex;
    gap: 10px;
}

.url-import-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 0.95em;
    background: white;
    transition: border-color 0.2s;
}

.url-import-input:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.1);
}

.url-import-btn {
    padding: 10px 20px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
}

.url-import-btn:hover:not(:disabled) {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
}

.url-import-btn:disabled {
    background: #a0aec0;
    cursor: not-allowed;
    transform: none;
}

.url-import-feedback {
    margin-top: 10px;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.9em;
}

.url-import-feedback.feedback-error {
    background: #fff5f5;
    color: #c53030;
    border: 1px solid #feb2b2;
}

.url-import-feedback.feedback-success {
    background: #f0fff4;
    color: #276749;
    border: 1px solid #9ae6b4;
}

.url-import-feedback.feedback-warning {
    background: #fffaf0;
    color: #744210;
    border: 1px solid #fbd38d;
}

/* Loading State */
.loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #718096;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #e2e8f0;
    border-top-color: var(--color-primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 15px;
}

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

/* Error State */
.error-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    color: #e53e3e;
}

.error-state button {
    margin-top: 15px;
    padding: 10px 20px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

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

.no-videos {
    text-align: center;
    padding: 40px;
    color: #718096;
    background: #f7fafc;
    border-radius: 8px;
}

/* Video Item */
.video-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    transition: all 0.2s;
}

.video-item:hover {
    border-color: #cbd5e0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

.video-item.in-database {
    background: #f0fff4;
    border-color: #9ae6b4;
}

.video-item.disabled {
    opacity: 0.5;
    pointer-events: none;
}

.video-item.blocked {
    background: #fef2f2;
    border-color: #fecaca;
    opacity: 0.7;
}

.video-item.blocked .video-thumbnail img {
    filter: grayscale(60%);
}

.video-item.blocked:hover {
    opacity: 0.85;
}

/* Thumbnail */
.video-thumbnail {
    position: relative;
    flex-shrink: 0;
    width: 120px;
    height: 68px;
    border-radius: 6px;
    overflow: hidden;
}

.video-thumbnail a {
    display: block;
    width: 100%;
    height: 100%;
    position: relative;
}

.video-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: filter 0.2s;
}

.video-thumbnail a:hover img {
    filter: brightness(0.7);
}

.video-thumbnail .yt-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 36px;
    height: 36px;
    background: rgba(255, 0, 0, 0.9);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.2s;
    pointer-events: none;
}

.video-thumbnail a:hover .yt-overlay {
    opacity: 1;
}

.video-duration {
    position: absolute;
    bottom: 4px;
    right: 4px;
    padding: 2px 6px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 0.75em;
    font-weight: 500;
    border-radius: 3px;
}

/* Video Info */
.video-info {
    flex: 1;
    min-width: 0;
}

.video-title {
    margin: 0 0 6px 0;
    font-size: 1em;
    font-weight: 600;
    color: #2d3748;
    line-height: 1.3;
}

.video-meta {
    display: flex;
    gap: 12px;
    font-size: 0.85em;
    color: #718096;
}

/* Video Status */
.video-status {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
    flex-shrink: 0;
}

.status-badge {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8em;
    font-weight: 500;
}

.status-badge.imported {
    background: #c6f6d5;
    color: #22543d;
}

.status-badge.available {
    background: #feebc8;
    color: #744210;
}

.status-badge.blocked {
    background: #fed7d7;
    color: #c53030;
}

.status-badge.blocked .blocked-icon {
    margin-right: 4px;
}

/* Blocked video tooltip */
.blocked-tooltip {
    position: relative;
    cursor: help;
}

.blocked-tooltip .tooltip-text {
    visibility: hidden;
    width: 200px;
    background-color: #2d3748;
    color: #fff;
    text-align: left;
    border-radius: 6px;
    padding: 8px 10px;
    position: absolute;
    z-index: 100;
    bottom: 125%;
    right: 0;
    opacity: 0;
    transition: opacity 0.2s;
    font-size: 0.75em;
    font-weight: 400;
    line-height: 1.4;
}

.blocked-tooltip .tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    right: 20px;
    border-width: 5px;
    border-style: solid;
    border-color: #2d3748 transparent transparent transparent;
}

.blocked-tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

.import-btn {
    padding: 8px 16px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.import-btn:hover:not(:disabled) {
    background: var(--color-primary-dark);
    transform: translateY(-1px);
}

.import-btn:disabled {
    background: #a0aec0;
    cursor: not-allowed;
}

.view-btn {
    padding: 8px 16px;
    background: #48bb78;
    color: white;
    text-decoration: none;
    border-radius: 6px;
    font-weight: 600;
    transition: all 0.2s;
}

.view-btn:hover {
    background: #38a169;
}

/* Modal */
.modal {
    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: 1000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-content.modal-small {
    max-width: 300px;
    text-align: center;
}

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

.modal-header h2 {
    margin: 0;
    font-size: 1.2em;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5em;
    cursor: pointer;
    color: #718096;
    line-height: 1;
}

.modal-close:hover {
    color: #2d3748;
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid #e2e8f0;
}

/* Import Preview */
.import-video-preview {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f7fafc;
    border-radius: 8px;
}

.import-video-preview img {
    width: 120px;
    height: 68px;
    object-fit: cover;
    border-radius: 6px;
}

.preview-info h3 {
    margin: 0 0 8px 0;
    font-size: 1em;
    line-height: 1.3;
}

.preview-info p {
    margin: 0;
    font-size: 0.85em;
    color: #718096;
}

.import-cost-info {
    padding: 15px;
    background: #fffaf0;
    border: 1px solid #fbd38d;
    border-radius: 8px;
    margin-bottom: 15px;
}

.import-cost-info p {
    margin: 5px 0;
}

.import-info {
    font-size: 0.9em;
    color: #718096;
}

/* Modal Buttons */
.btn-cancel {
    padding: 10px 20px;
    background: #e2e8f0;
    color: #4a5568;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

.btn-cancel:hover {
    background: #cbd5e0;
}

.btn-import {
    padding: 10px 20px;
    background: var(--color-primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

.btn-import:hover:not(:disabled) {
    background: var(--color-primary-dark);
}

.btn-import:disabled {
    background: #a0aec0;
    cursor: not-allowed;
}

/* Import Progress */
.import-progress {
    padding: 40px 20px;
}

.import-progress p {
    margin-top: 15px;
    color: #4a5568;
}

/* ============================================================================
   Topup Modal Styles
   ============================================================================ */

.modal-overlay {
    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: 10000;
}

.modal-overlay .modal {
    position: relative;
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.3);
}

/* Topup Options Grid */
.topup-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 15px;
}

.topup-option {
    background: #f8f9fa;
    border: 2px solid #e0e0e0;
    border-radius: 12px;
    padding: 20px 15px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}

.topup-option:hover {
    border-color: var(--color-primary);
    background: #f8f9ff;
}

.topup-option.selected {
    border-color: var(--color-primary);
    background: #f0f4ff;
    box-shadow: 0 0 0 3px rgba(var(--color-primary-rgb), 0.2);
}

.topup-option .price {
    font-size: 1.6em;
    font-weight: 700;
    color: var(--color-primary);
    margin-bottom: 8px;
}

.topup-option .name {
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 4px;
}

.topup-option .description {
    font-size: 0.85em;
    color: #7f8c8d;
}

.topup-option .discount {
    display: inline-block;
    background: #27ae60;
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.75em;
    font-weight: 600;
    margin-top: 10px;
}

/* Modal Buttons for Topup */
.btn-secondary {
    padding: 12px 24px;
    background: #e2e8f0;
    color: #4a5568;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #cbd5e0;
}

.btn-primary {
    padding: 12px 24px;
    background: var(--gradient-primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(var(--color-primary-rgb), 0.4);
}

/* Inactive Videos */
.video-item.inactive-video {
    opacity: 0.5;
    border-left: 4px solid #e53e3e;
    background: #fef2f2;
}

.status-badge.inactive {
    background: #fed7d7;
    color: #c53030;
}

/* Action buttons for imported videos */
.video-action-btns {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}

.toggle-btn {
    padding: 5px 10px;
    border: 1px solid #e2e8f0;
    border-radius: 5px;
    font-size: 0.75em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    background: white;
}

.toggle-btn.toggle-deactivate {
    color: #c53030;
    border-color: #feb2b2;
}

.toggle-btn.toggle-deactivate:hover {
    background: #fff5f5;
}

.toggle-btn.toggle-activate {
    color: #276749;
    border-color: #9ae6b4;
}

.toggle-btn.toggle-activate:hover {
    background: #f0fff4;
}

.toggle-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.refresh-meta-btn {
    padding: 5px 8px;
    border: 1px solid #bee3f8;
    border-radius: 5px;
    background: white;
    color: #2b6cb0;
    font-size: 0.9em;
    cursor: pointer;
    transition: all 0.15s;
    line-height: 1;
}

.refresh-meta-btn:hover {
    background: #ebf8ff;
}

.refresh-meta-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ============================================================================
   Student Video Slots
   ============================================================================ */

.student-slots-section {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 12px 16px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    min-width: 160px;
}

.slots-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.slots-label {
    font-size: 0.85em;
    opacity: 0.9;
}

.slots-counter {
    font-size: 1.1em;
    font-weight: 700;
}

.slots-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
    overflow: hidden;
}

.slots-bar-fill {
    height: 100%;
    background: #48bb78;
    border-radius: 3px;
    transition: width 0.3s;
}

.slots-bar-fill.slots-full {
    background: #e53e3e;
}

/* ============================================================================
   Student Activate Button
   ============================================================================ */

.student-activate-btn {
    padding: 5px 10px;
    border: 1px solid var(--color-primary);
    border-radius: 5px;
    font-size: 0.75em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    background: white;
    color: var(--color-primary);
}

.student-activate-btn:hover:not(:disabled) {
    background: #f0f4ff;
}

.student-activate-btn.activated {
    background: var(--color-primary);
    color: white;
    border-color: var(--color-primary);
}

.student-activate-btn.activated:hover {
    background: var(--color-primary-dark);
}

.student-activate-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* ============================================================================
   Class Assignment Button + Modal
   ============================================================================ */

.class-assign-btn {
    padding: 5px 10px;
    border: 1px solid #9f7aea;
    border-radius: 5px;
    font-size: 0.75em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    background: white;
    color: #9f7aea;
}

.class-assign-btn:hover {
    background: #faf5ff;
}

.assign-video-preview {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    padding: 15px;
    background: #f7fafc;
    border-radius: 8px;
}

.assign-video-preview img {
    width: 120px;
    height: 68px;
    object-fit: cover;
    border-radius: 6px;
}

.class-checklist {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 300px;
    overflow-y: auto;
}

.class-check-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
}

.class-check-item:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.class-check-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: #9f7aea;
}

.class-check-name {
    flex: 1;
    font-weight: 500;
    color: #2d3748;
}

.class-check-count {
    font-size: 0.85em;
    color: #718096;
}

/* Responsive */
@media (max-width: 768px) {
    .channel-header {
        flex-direction: column;
    }

    .balance-section {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
    }

    .filter-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        width: 100%;
    }

    .filter-select {
        flex: 1;
    }

    .stats-summary {
        flex-direction: column;
        gap: 10px;
    }

    .video-item {
        flex-direction: column;
        align-items: flex-start;
    }

    .video-thumbnail {
        width: 100%;
        height: auto;
        aspect-ratio: 16/9;
    }

    .video-status {
        width: 100%;
        flex-direction: row;
        justify-content: space-between;
    }

    .url-import-form {
        flex-direction: column;
    }
}
