/* style.css - Premium Glassmorphism Dark Theme */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&family=Sarabun:wght@300;400;500;600;700&display=swap');

:root {
    --bg-main: #060919;
    --bg-card: rgba(255, 255, 255, 0.04);
    --border-card: rgba(255, 255, 255, 0.08);
    --text-primary: #f5f6fa;
    --text-secondary: #a4b0be;
    --primary-grad: #0284c7;
    --accent-color: #00d2d3;
    --danger-color: #ff7675;
    --success-color: #1dd1a1;
    --font-heading: 'Outfit', 'Sarabun', sans-serif;
    --font-body: 'Sarabun', sans-serif;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background-color: var(--bg-main);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(108, 92, 231, 0.15) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(165, 94, 234, 0.15) 0%, transparent 40%);
    background-attachment: fixed;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Glassmorphism utility */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 16px;
    padding: 24px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.glass-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px 0 var(--theme-color-rgba);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Navigation Bar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 32px;
    height: 60px;
    background: rgba(6, 9, 25, 0.7);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-card);
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
}

.nav-brand {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--primary-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.nav-links {
    display: flex;
    gap: 20px;
    list-style: none;
    align-items: center;
}

.nav-links a {
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: color 0.3s ease;
}

.nav-links a:hover {
    color: #a55eea;
}

/* Dropdown Menu */
.user-dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-trigger {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-card);
    padding: 8px 16px;
    border-radius: 20px;
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
}

.dropdown-trigger img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
}

.dropdown-menu {
    display: none;
    position: absolute;
    right: 0;
    top: calc(100% - 2px);
    background: rgba(15, 20, 45, 0.98);
    border: 1px solid var(--border-card);
    border-radius: 12px;
    min-width: 180px;
    box-shadow: 0 8px 24px rgba(0,0,0,0.5);
    z-index: 1000;
    overflow: hidden;
}

.user-dropdown:hover .dropdown-menu {
    display: block;
}

.dropdown-menu a {
    display: block;
    padding: 12px 16px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 14px;
    transition: background 0.3s;
}

.dropdown-menu a:hover {
    background: rgba(255,255,255,0.08);
}

/* Layout Containers */
.app-container {
    margin-top: 60px;
    padding: 32px 36px;
    min-height: calc(100vh - 60px);
}

/* Dashboard Sidebar Layout */
.dashboard-layout {
    display: flex;
    margin-top: 60px;
    min-height: calc(100vh - 60px);
}

.sidebar {
    width: 260px;
    background: rgba(10, 14, 39, 0.5);
    border-right: 1px solid var(--border-card);
    backdrop-filter: blur(20px);
    padding: 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    position: sticky;
    top: 60px;
    height: calc(100vh - 60px);
    overflow-y: auto;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.sidebar-link i {
    font-size: 18px;
}

.sidebar-link:hover, .sidebar-link.active {
    color: var(--text-primary);
    background: rgba(255,255,255,0.05);
    border-left: 3px solid #6c5ce7;
}

.dashboard-content {
    flex-grow: 1;
    padding: 40px;
    overflow-y: auto;
}

/* Forms & Inputs */
.form-group {
    margin-bottom: 20px;
}

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

.form-control {
    width: 100%;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-card);
    border-radius: 8px;
    padding: 12px 16px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 15px;
    transition: all 0.3s;
}

.form-control:focus {
    outline: none;
    border-color: #6c5ce7;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: 0 0 8px rgba(108, 92, 231, 0.4);
}

.form-select {
    width: 100%;
    background-color: #0f142d !important;
    border: 1px solid var(--border-card);
    border-radius: 8px;
    padding: 12px 16px;
    color: #ffffff !important;
    font-family: var(--font-body);
    font-size: 15px;
    font-weight: 400;
    transition: all 0.3s;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23ffffff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 16px;
}

.form-select:focus {
    outline: none;
    border-color: #6c5ce7;
    background-color: #141b3d !important;
    box-shadow: 0 0 8px rgba(108, 92, 231, 0.4);
}

.form-select option {
    background-color: #0f142d !important;
    color: #ffffff !important;
    padding: 12px;
    font-size: 15px;
}

.form-select option:hover,
.form-select option:focus,
.form-select option:checked {
    background-color: #1e274e !important;
    color: var(--accent-color) !important;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary-grad);
    color: var(--text-primary);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(108, 92, 231, 0.5);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
    border: 1px solid var(--border-card);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.15);
}

.btn-danger {
    background: var(--danger-color);
    color: var(--text-primary);
}

.btn-danger:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(255, 118, 117, 0.5);
}

/* Auth Cards */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 160px);
}

.auth-card {
    width: 100%;
    max-width: 450px;
}

.auth-header {
    text-align: center;
    margin-bottom: 24px;
}

.auth-header h2 {
    font-size: 28px;
    margin-bottom: 8px;
}

.auth-footer {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-footer a {
    color: #a55eea;
    text-decoration: none;
}

/* Library Grid */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 30px;
    margin-top: 30px;
}

.video-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    cursor: pointer;
    overflow: hidden;
    padding: 0;
}

.video-thumb {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 Aspect Ratio */
    background: var(--theme-color-light, rgba(2, 132, 199, 0.08));
}

.video-thumb img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.video-thumb .play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transition: opacity 0.3s;
}

.video-card:hover .play-overlay {
    opacity: 1;
}

.play-overlay i {
    font-size: 40px;
    color: var(--text-primary);
}

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

.video-info {
    padding: 16px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.video-title {
    font-size: 18px;
    margin-bottom: 8px;
    line-height: 1.4;
}

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

.video-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--text-secondary);
}

.badge {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.badge-public {
    background: rgba(29, 209, 161, 0.2);
    color: var(--success-color);
}

.badge-private {
    background: rgba(255, 118, 117, 0.2);
    color: var(--danger-color);
}

.badge-admin {
    background: rgba(108, 92, 231, 0.2);
    color: #a55eea;
}

/* Custom HLS Player Container */
.player-container {
    width: 100%;
    max-width: 960px;
    margin: 0 auto;
}

.video-wrapper {
    position: relative;
    width: 100%;
    padding-top: 56.25%;
    border-radius: 16px;
    overflow: hidden;
    border: 1px solid var(--border-card);
    box-shadow: 0 20px 50px rgba(0,0,0,0.6);
}

.video-wrapper video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000;
}

/* Watermark */
.video-watermark {
    position: absolute;
    top: 30px;
    left: 30px;
    color: rgba(255, 255, 255, 0.12);
    font-size: 16px;
    pointer-events: none;
    z-index: 10;
    user-select: none;
    font-weight: bold;
}

/* Custom player overlay for inspection blocking */
.video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5;
    pointer-events: none;
}

/* Stats Dashboard */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 24px;
    margin-bottom: 40px;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 20px;
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    background: rgba(108, 92, 231, 0.15);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 24px;
    color: #a55eea;
}

.stat-info h3 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-info p {
    font-size: 28px;
    font-weight: 700;
}

/* Tables */
.table-container {
    width: 100%;
    overflow-x: auto;
    margin-top: 20px;
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.table th, .table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-card);
    word-break: break-word;
    overflow-wrap: break-word;
}

.table th {
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 14px;
}

.table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

/* Custom CSS Toggle Switch */
.switch {
    position: relative;
    display: inline-block;
    width: 48px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.1);
    transition: .4s;
    border-radius: 24px;
    border: 1px solid var(--border-card);
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background: var(--primary-grad);
}

input:checked + .slider:before {
    transform: translateX(24px);
}

/* Drag & Drop Upload Zone */
.upload-zone {
    border: 2px dashed var(--border-card);
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    cursor: pointer;
    background: rgba(255, 255, 255, 0.02);
    transition: all 0.3s;
    margin-bottom: 20px;
}

.upload-zone:hover {
    border-color: #6c5ce7;
    background: rgba(108, 92, 231, 0.05);
}

.upload-zone i {
    font-size: 48px;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.upload-zone p {
    font-size: 14px;
    color: var(--text-secondary);
}

/* Toasts Container */
#toast-container {
    position: fixed;
    top: 130px;
    right: 24px;
    z-index: 999;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: rgba(15, 20, 45, 0.95);
    border: 1px solid var(--border-card);
    color: var(--text-primary);
    padding: 16px 24px;
    border-radius: 10px;
    backdrop-filter: blur(12px);
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 280px;
    transform: translateX(120%);
    transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.toast.show {
    transform: translateX(0);
}

.toast-success {
    border-left: 4px solid var(--success-color);
}

.toast-error {
    border-left: 4px solid var(--danger-color);
}

.toast-info {
    border-left: 4px solid var(--accent-color);
}

/* Responsive elements */
.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    transition: color 0.3s;
}

.menu-toggle:hover {
    color: var(--theme-color);
}

@media (max-width: 768px) {
    .navbar {
        padding: 16px 20px;
    }
    
    .menu-toggle {
        display: block !important;
    }

    .nav-links {
        display: none;
        flex-direction: column;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background: rgba(10, 14, 39, 0.98);
        border-bottom: 1px solid var(--border-card);
        padding: 20px;
        gap: 12px;
        align-items: stretch;
        box-shadow: 0 10px 20px rgba(0,0,0,0.5);
        z-index: 999;
    }

    .nav-links.active {
        display: flex;
    }

    .nav-links li {
        width: 100%;
    }

    .nav-links li a {
        display: block;
        padding: 10px 0;
        width: 100%;
        border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    }
    
    .nav-links li style {
        margin-right: 0 !important;
        margin-bottom: 8px;
    }

    .user-dropdown .dropdown-menu {
        position: static;
        width: 100%;
        box-shadow: none;
        background: rgba(255, 255, 255, 0.02);
        margin-top: 8px;
        border-radius: 8px;
        display: none;
    }

    .user-dropdown.active .dropdown-menu {
        display: block;
    }

    .dropdown-trigger {
        width: 100%;
        justify-content: space-between;
    }

    .dashboard-layout {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        position: relative;
        top: 0;
        border-right: none;
        border-bottom: 1px solid var(--border-card);
        padding: 10px 14px;
        flex-direction: row;
        overflow-x: auto;
        gap: 8px;
        -webkit-overflow-scrolling: touch;
    }

    .sidebar-link {
        white-space: nowrap;
        padding: 8px 14px;
        font-size: 13px;
    }

    .dashboard-content {
        padding: 16px;
    }

    .app-container {
        padding: 16px;
    }
    
    .playlist-sidebar {
        max-width: 100% !important;
    }
}

@media (max-width: 500px) {
    .app-container, .dashboard-content {
        padding: 12px;
    }
    .glass-card {
        padding: 16px;
    }
    .btn {
        padding: 10px 16px;
        font-size: 14px;
    }
    .nav-brand {
        font-size: 20px;
    }
}

/* ==========================================================================
   Table Cell Text Truncation & Hover Reveal Component (Task #2)
   ========================================================================== */
.twh-truncate-wrapper {
    display: inline-flex;
    align-items: center;
    max-width: 100%;
    cursor: pointer;
    position: relative;
    border-radius: 4px;
    padding: 1px 3px;
    margin: -1px -3px;
    transition: background 0.15s ease, color 0.15s ease;
    vertical-align: middle;
}

.twh-truncate-wrapper:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--accent-color);
}

.twh-truncate-text {
    max-width: 320px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: middle;
    font-size: inherit;
}

/* Global Floating Glassmorphism Tooltip for Table Truncation */
#twh-global-tooltip {
    position: fixed;
    z-index: 999999;
    background: rgba(15, 23, 42, 0.96);
    color: #f8fafc;
    border: 1px solid rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: 8px;
    padding: 8px 12px;
    font-size: 13px;
    line-height: 1.45;
    max-width: 460px;
    min-width: 140px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.35);
    pointer-events: none;
    opacity: 0;
    transform: translateY(4px) scale(0.98);
    transition: opacity 0.12s ease, transform 0.12s ease;
    word-break: break-all;
    white-space: normal;
    user-select: none;
}

#twh-global-tooltip.active {
    opacity: 1;
    transform: translateY(0) scale(1);
}

#twh-global-tooltip .tooltip-content {
    color: #ffffff;
    font-weight: 500;
    font-family: inherit;
    line-height: 1.4;
}

#twh-global-tooltip .tooltip-footer {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 6px;
    padding-top: 4px;
    border-top: 1px dashed rgba(255, 255, 255, 0.15);
    font-size: 10px;
    color: #38bdf8;
    opacity: 0.9;
}

