/* ============================================
   ChildTube - Stylesheet Utama
   Desain mirip YouTube (merah-hitam-putih)
   ============================================ */

/* === IMPORT FONT === */
@import url('https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500;700&display=swap');

/* === CSS VARIABLES === */
:root {
    --yt-red: #FF0000;
    --yt-red-hover: #CC0000;
    --yt-red-dark: #990000;
    --bg: #0F0F0F;
    --bg-secondary: #181818;
    --surface: #212121;
    --surface-hover: #373737;
    --surface-light: #3E3E3E;
    --text: #FFFFFF;
    --text-secondary: #AAAAAA;
    --text-muted: #717171;
    --border: #303030;
    --success: #2E7D32;
    --error: #D32F2F;
    --warning: #F57C00;
    --navbar-height: 56px;
    --sidebar-width: 240px;
    --sidebar-collapsed: 72px;
    --card-radius: 12px;
    --transition: 0.2s ease;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Roboto', 'YouTube Sans', Arial, sans-serif;
    background-color: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
    overflow-x: hidden;
}

a {
    text-decoration: none;
    color: inherit;
    transition: color var(--transition);
}

img {
    max-width: 100%;
    display: block;
}

/* === SCROLLBAR CUSTOM === */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg);
}

::-webkit-scrollbar-thumb {
    background: var(--surface-light);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================
   NAVBAR (Header Atas)
   ============================================ */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-height);
    background-color: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 1000;
    border-bottom: 1px solid var(--border);
}

.navbar-left {
    display: flex;
    align-items: center;
    gap: 16px;
}

.navbar-logo {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.5px;
}

.navbar-logo .logo-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 22px;
    background: var(--yt-red);
    border-radius: 4px;
    font-size: 0.85rem;
    color: white;
    margin-right: 2px;
}

.navbar-logo span {
    color: var(--text);
}

.menu-toggle {
    background: none;
    border: none;
    color: var(--text);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background var(--transition);
}

.menu-toggle:hover {
    background: var(--surface);
}

.navbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.navbar-user {
    display: flex;
    align-items: center;
    gap: 10px;
}

.navbar-user .user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--yt-red);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.85rem;
    color: white;
    text-transform: uppercase;
}

.navbar-user .user-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
}

.navbar-user .user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
    background: var(--surface);
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: capitalize;
}

.btn-logout {
    background: transparent;
    border: 1px solid var(--surface-light);
    color: var(--text);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    font-family: 'Roboto', sans-serif;
}

.btn-logout:hover {
    background: var(--surface);
    border-color: var(--text-muted);
}

/* ============================================
   SIDEBAR (Menu Kiri)
   ============================================ */
.sidebar {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border);
    padding: 12px 0;
    overflow-y: auto;
    z-index: 999;
    transition: transform 0.3s ease, width 0.3s ease;
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar-nav {
    list-style: none;
    padding: 0 8px;
}

.sidebar-nav li {
    margin-bottom: 2px;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 24px;
    padding: 10px 12px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text);
    transition: background var(--transition);
}

.sidebar-nav a:hover {
    background: var(--surface);
}

.sidebar-nav a.active {
    background: var(--surface);
    font-weight: 500;
}

.sidebar-nav .nav-icon {
    font-size: 1.3rem;
    width: 24px;
    text-align: center;
    flex-shrink: 0;
}

.sidebar-divider {
    height: 1px;
    background: var(--border);
    margin: 12px 16px;
}

.sidebar-section-title {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    padding: 8px 20px 4px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
   MAIN CONTENT AREA
   ============================================ */
.main-content {
    margin-top: var(--navbar-height);
    margin-left: var(--sidebar-width);
    padding: 24px;
    min-height: calc(100vh - var(--navbar-height));
    transition: margin-left 0.3s ease;
}

.main-content.sidebar-collapsed {
    margin-left: 0;
}

/* === Page Title === */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-title {
    font-size: 1.4rem;
    font-weight: 600;
    color: var(--text);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    font-family: 'Roboto', sans-serif;
    text-decoration: none;
}

.btn-primary {
    background: var(--yt-red);
    color: white;
}

.btn-primary:hover {
    background: var(--yt-red-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(255, 0, 0, 0.3);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
}

.btn-secondary:hover {
    background: var(--surface-hover);
}

.btn-danger {
    background: transparent;
    color: var(--error);
    border: 1px solid var(--error);
}

.btn-danger:hover {
    background: var(--error);
    color: white;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 0.8rem;
}

.btn-icon {
    padding: 8px;
    border-radius: 50%;
    background: transparent;
    color: var(--text);
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: background var(--transition);
}

.btn-icon:hover {
    background: var(--surface);
}

/* ============================================
   VIDEO GRID (Grid Thumbnail)
   ============================================ */
.video-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

.video-card {
    background: transparent;
    border-radius: var(--card-radius);
    overflow: hidden;
    transition: transform var(--transition);
    cursor: pointer;
}

.video-card:hover {
    transform: scale(1.03);
}

.video-card:hover .video-thumbnail img {
    transform: scale(1.05);
}

.video-thumbnail {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* Rasio 16:9 */
    overflow: hidden;
    border-radius: var(--card-radius);
    background: var(--surface);
}

.video-thumbnail img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.video-info {
    padding: 10px 4px;
}

.video-title {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text);
    line-height: 1.4;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}

.video-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================
   PLAYLIST GRID (Grid Card Playlist)
   ============================================ */
.playlist-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.playlist-card {
    background: var(--surface);
    border-radius: var(--card-radius);
    padding: 24px;
    transition: all var(--transition);
    border: 1px solid var(--border);
}

.playlist-card:hover {
    border-color: var(--surface-light);
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
}

.playlist-card-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 12px;
}

.playlist-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--yt-red), var(--yt-red-dark));
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
}

.playlist-card-actions {
    display: flex;
    gap: 4px;
}

.playlist-name {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 6px;
    color: var(--text);
}

.playlist-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
    line-height: 1.5;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.playlist-stats {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.playlist-card-footer {
    display: flex;
    gap: 8px;
}

/* ============================================
   WATCH PAGE (Halaman Tonton Video)
   ============================================ */
.watch-container {
    display: grid;
    grid-template-columns: 1fr 400px;
    gap: 24px;
    max-width: 1600px;
}

.watch-player {
    width: 100%;
}

.watch-player .player-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
    background: #000;
    border-radius: var(--card-radius);
    overflow: hidden;
}

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

.watch-info {
    padding: 16px 0;
}

.watch-title {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.4;
    margin-bottom: 8px;
}

.watch-meta {
    font-size: 0.85rem;
    color: var(--text-muted);
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border);
}

/* Sidebar Video Terkait */
.watch-sidebar {
    max-height: calc(100vh - var(--navbar-height) - 48px);
    overflow-y: auto;
}

.watch-sidebar-title {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.sidebar-video-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sidebar-video-item {
    display: flex;
    gap: 8px;
    padding: 4px;
    border-radius: 8px;
    transition: background var(--transition);
}

.sidebar-video-item:hover {
    background: var(--surface);
}

.sidebar-video-item.active {
    background: var(--surface);
    border-left: 3px solid var(--yt-red);
}

.sidebar-video-thumb {
    width: 168px;
    min-width: 168px;
    height: 94px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--surface);
}

.sidebar-video-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sidebar-video-info {
    flex: 1;
    padding: 4px 0;
}

.sidebar-video-title {
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 4px;
}

.sidebar-video-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* ============================================
   FORMS (Login, Register, Playlist, Video)
   ============================================ */
.form-container {
    max-width: 480px;
    margin: 0 auto;
}

.form-card {
    background: var(--surface);
    border-radius: var(--card-radius);
    padding: 40px;
    border: 1px solid var(--border);
}

.form-card-wide {
    max-width: 600px;
    margin: 0 auto;
}

.form-title {
    font-size: 1.5rem;
    font-weight: 600;
    text-align: center;
    margin-bottom: 8px;
}

.form-subtitle {
    font-size: 0.9rem;
    color: var(--text-secondary);
    text-align: center;
    margin-bottom: 32px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 0.9rem;
    font-family: 'Roboto', sans-serif;
    transition: border-color var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--yt-red);
    box-shadow: 0 0 0 2px rgba(255, 0, 0, 0.15);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-group select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M6 8L1 3h10z' fill='%23AAAAAA'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 40px;
    cursor: pointer;
}

.form-group select option {
    background: var(--surface);
    color: var(--text);
}

.form-actions {
    margin-top: 28px;
}

.form-actions .btn {
    width: 100%;
    justify-content: center;
    padding: 12px;
    font-size: 0.95rem;
}

.form-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.form-footer a {
    color: var(--yt-red);
    font-weight: 500;
}

.form-footer a:hover {
    text-decoration: underline;
}

/* ============================================
   ALERTS & MESSAGES
   ============================================ */
.alert {
    padding: 12px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: rgba(46, 125, 50, 0.15);
    border: 1px solid var(--success);
    color: #66BB6A;
}

.alert-error {
    background: rgba(211, 47, 47, 0.15);
    border: 1px solid var(--error);
    color: #EF5350;
}

.alert-warning {
    background: rgba(245, 124, 0, 0.15);
    border: 1px solid var(--warning);
    color: #FFA726;
}

/* ============================================
   AUTH PAGES (Login / Register)
   ============================================ */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg);
}

.auth-page .form-card {
    width: 100%;
    max-width: 440px;
}

.auth-logo {
    text-align: center;
    margin-bottom: 32px;
}

.auth-logo .navbar-logo {
    justify-content: center;
    font-size: 1.6rem;
}

/* ============================================
   EMPTY STATE
   ============================================ */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

.empty-state-title {
    font-size: 1.2rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.empty-state-desc {
    font-size: 0.9rem;
    margin-bottom: 24px;
}

/* ============================================
   VIDEO LIST (Table-like in playlist detail)
   ============================================ */
.video-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.video-list-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px;
    background: var(--surface);
    border-radius: var(--card-radius);
    border: 1px solid var(--border);
    transition: all var(--transition);
}

.video-list-item:hover {
    border-color: var(--surface-light);
    background: var(--surface-hover);
}

.video-list-thumb {
    width: 160px;
    min-width: 160px;
    height: 90px;
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg);
}

.video-list-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-list-info {
    flex: 1;
}

.video-list-title {
    font-size: 0.95rem;
    font-weight: 500;
    margin-bottom: 4px;
}

.video-list-url {
    font-size: 0.8rem;
    color: var(--text-muted);
    word-break: break-all;
}

.video-list-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

/* ============================================
   MODAL KONFIRMASI
   ============================================ */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background: var(--surface);
    border-radius: var(--card-radius);
    padding: 32px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    border: 1px solid var(--border);
    animation: modalIn 0.2s ease;
}

@keyframes modalIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 12px;
}

.modal-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin-bottom: 24px;
}

.modal-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

/* ============================================
   FOOTER
   ============================================ */
.footer {
    text-align: center;
    padding: 24px;
    margin-top: 40px;
    border-top: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Tablet (max-width: 1024px) */
@media (max-width: 1024px) {
    .video-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .watch-container {
        grid-template-columns: 1fr;
    }

    .watch-sidebar {
        max-height: none;
    }

    .sidebar-video-item {
        flex-direction: row;
    }
}

/* Tablet kecil (max-width: 768px) */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.mobile-open {
        transform: translateX(0);
        box-shadow: 4px 0 20px rgba(0, 0, 0, 0.5);
    }

    .main-content {
        margin-left: 0;
        padding: 16px;
    }

    .video-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 12px;
    }

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

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .form-card {
        padding: 24px;
    }

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

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

    .sidebar-video-thumb {
        width: 120px;
        min-width: 120px;
        height: 68px;
    }

    .navbar-user .user-name {
        display: none;
    }
}

/* Mobile (max-width: 480px) */
@media (max-width: 480px) {
    .video-grid {
        grid-template-columns: 1fr;
    }

    .navbar-logo span {
        display: none;
    }

    .watch-container {
        gap: 16px;
    }

    .sidebar-video-item {
        flex-direction: column;
    }

    .sidebar-video-thumb {
        width: 100%;
        min-width: unset;
        height: auto;
        aspect-ratio: 16/9;
    }
}

/* ============================================
   ANIMASI HELPER
   ============================================ */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-in {
    animation: fadeInUp 0.4s ease forwards;
}

/* Stagger animation untuk grid items */
.video-card:nth-child(1) { animation-delay: 0.05s; }
.video-card:nth-child(2) { animation-delay: 0.1s; }
.video-card:nth-child(3) { animation-delay: 0.15s; }
.video-card:nth-child(4) { animation-delay: 0.2s; }
.video-card:nth-child(5) { animation-delay: 0.25s; }
.video-card:nth-child(6) { animation-delay: 0.3s; }
.video-card:nth-child(7) { animation-delay: 0.35s; }
.video-card:nth-child(8) { animation-delay: 0.4s; }

/* ============================================
   CHILD-SPECIFIC STYLES (role anak)
   ============================================ */
.child-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: linear-gradient(135deg, #FF6B6B, #FF0000);
    color: white;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
}

/* ============================================
   MOBILE SIDEBAR OVERLAY
   ============================================ */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
}

.sidebar-overlay.active {
    display: block;
}
