/* Proxdigi.com Design System */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&family=Outfit:wght@500;600;700;800&display=swap');

:root {
    --font-head: 'Outfit', sans-serif;
    --font-body: 'Inter', sans-serif;

    /* Dark Mode Theme Tokens (Default) */
    --bg-base: #090d16;
    --bg-surface: #111726;
    --bg-surface-elevated: #1a2338;
    --border-color: #1f2a45;
    --bg-header: rgba(17, 23, 38, 0.85);
    
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.35);
    --secondary: #8b5cf6;
    
    --text-main: #f3f4f6;
    --text-muted: #9ca3af;
    --text-dim: #6b7280;
    
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    
    --sidebar-width: 240px;
    --sidebar-collapsed-width: 72px;
    --header-height: 70px;
    --shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.4);
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="light"] {
    /* Light Mode Theme Tokens */
    --bg-base: #f9fafb;
    --bg-surface: #ffffff;
    --bg-surface-elevated: #f3f4f6;
    --border-color: #e5e7eb;
    --bg-header: rgba(255, 255, 255, 0.85);
    
    --text-main: #111827;
    --text-muted: #4b5563;
    --text-dim: #9ca3af;
    
    --shadow: 0 4px 20px -2px rgba(0, 0, 0, 0.08);
}

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

body {
    background-color: var(--bg-base);
    color: var(--text-main);
    font-family: var(--font-body);
    overflow-x: hidden;
    line-height: 1.5;
    transition: background-color 0.3s;
}

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

button, input, select, textarea {
    font-family: inherit;
}

/* Master Layout Grid */
.layout-wrapper {
    display: flex;
    min-height: 100vh;
    flex-direction: column;
}

/* Header */
.top-header {
    height: var(--header-height);
    background-color: var(--bg-header);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: var(--shadow);
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
    font-family: var(--font-head);
    font-size: 22px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    cursor: pointer;
}

.logo-section svg {
    fill: var(--primary);
    width: 32px;
    height: 32px;
}

.search-section {
    flex: 0 1 500px;
    position: relative;
}

.search-section input {
    width: 100%;
    padding: 10px 16px 10px 42px;
    border-radius: 30px;
    border: 1px solid var(--border-color);
    background-color: var(--bg-base);
    color: var(--text-main);
    font-size: 14px;
    transition: var(--transition);
}

.search-section input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.search-section svg {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    fill: var(--text-muted);
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background-color: var(--bg-surface-elevated);
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    transition: var(--transition);
}

.icon-btn:hover {
    background-color: var(--primary);
    color: white;
}

.avatar-menu {
    position: relative;
    cursor: pointer;
}

.avatar-img {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    object-fit: cover;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    position: fixed;
    top: var(--header-height);
    bottom: 0;
    left: 0;
    z-index: 90;
    overflow-y: auto;
    padding: 15px 10px;
    transition: var(--transition);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.nav-list {
    list-style: none;
}

.nav-item a {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    border-radius: 10px;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 14px;
    margin-bottom: 5px;
}

.nav-item a svg {
    width: 20px;
    height: 20px;
    margin-right: 15px;
    fill: currentColor;
    flex-shrink: 0;
}

.sidebar.collapsed .nav-item a span {
    display: none;
}

.sidebar.collapsed .nav-item a svg {
    margin-right: 0;
}

.nav-item.active a, .nav-item a:hover {
    background-color: var(--bg-surface-elevated);
    color: var(--primary);
}

/* Main Content Wrapper */
.main-content {
    margin-top: var(--header-height);
    margin-left: var(--sidebar-width);
    padding: 30px;
    min-height: calc(100vh - var(--header-height));
    transition: var(--transition);
}

.main-content.expanded {
    margin-left: var(--sidebar-collapsed-width);
}

/* Card Grids */
.video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
    margin-top: 20px;
}

.video-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    overflow: hidden;
    transition: var(--transition);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

.video-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4);
    border-color: var(--primary);
}

.thumbnail-wrapper {
    position: relative;
    aspect-ratio: 16 / 9;
    background-color: #000;
    overflow: hidden;
}

.thumbnail-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.duration-badge {
    position: absolute;
    bottom: 8px;
    right: 8px;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 11px;
    padding: 3px 6px;
    border-radius: 4px;
    font-weight: 600;
}

.card-details {
    padding: 15px;
    display: flex;
    gap: 12px;
}

.channel-avatar-small {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
}

.card-text {
    flex: 1;
}

.video-title {
    font-family: var(--font-head);
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 6px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 44px;
}

.channel-name {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.verified-badge {
    fill: var(--primary);
    width: 14px;
    height: 14px;
}

.video-meta {
    font-size: 12px;
    color: var(--text-dim);
}

/* Typography elements */
h2.section-title {
    font-family: var(--font-head);
    font-weight: 700;
    font-size: 24px;
    margin-bottom: 15px;
    letter-spacing: -0.5px;
}

/* Premium Custom Button */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 14px;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 4px 15px var(--primary-glow);
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-secondary {
    background-color: var(--bg-surface-elevated);
    color: var(--text-main);
    border: 1px solid var(--border-color);
}

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

/* Floating Alerts / Toast styling */
.toast-msg {
    position: fixed;
    bottom: 25px;
    right: 25px;
    background-color: var(--bg-surface-elevated);
    border-left: 4px solid var(--primary);
    color: var(--text-main);
    padding: 15px 25px;
    border-radius: 8px;
    box-shadow: var(--shadow);
    z-index: 1000;
    font-size: 14px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Responsive queries */
/* Responsive Breakpoints & Queries */

/* 1. Large Screen / Desktop (1440px) */
@media (min-width: 1440px) {
    .video-grid {
        grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
        gap: 24px;
    }
}

/* 2. Standard Laptop / Desktop (1280px) */
@media (max-width: 1439px) and (min-width: 1280px) {
    .video-grid {
        grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
        gap: 20px;
    }
}

/* 3. Small Desktop / Large Tablet (992px) */
@media (max-width: 1279px) and (min-width: 992px) {
    .video-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        gap: 20px;
    }
}

@media (max-width: 992px) {
    .sidebar {
        transform: translateX(-100%);
        box-shadow: 0 0 30px rgba(0, 0, 0, 0.6);
        z-index: 1001; /* Above mobile overlay */
    }
    .sidebar.mobile-show {
        transform: translateX(0);
        width: var(--sidebar-width);
    }
    .main-content {
        margin-left: 0;
        padding: 15px;
        padding-bottom: 80px; /* Space for mobile bottom nav */
    }
    .top-header {
        padding: 0 15px;
    }
    .search-section {
        display: none;
    }
    
    /* Mobile Overlay Backdrop */
    .mobile-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background-color: rgba(0, 0, 0, 0.6);
        backdrop-filter: blur(4px);
        z-index: 1000;
        display: none;
    }
    .mobile-overlay.show {
        display: block;
    }
    
    /* Body freeze when sidebar or overlay active */
    body.sidebar-open {
        overflow: hidden;
    }
    
    /* Mobile Bottom Navigation */
    .mobile-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        height: 64px;
        background-color: var(--bg-surface);
        border-top: 1px solid var(--border-color);
        display: flex;
        align-items: center;
        justify-content: space-around;
        z-index: 999;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.3);
    }
    
    .mobile-nav-item {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        color: var(--text-muted);
        font-size: 11px;
        font-weight: 500;
        gap: 4px;
        flex: 1;
        height: 100%;
    }
    
    .mobile-nav-item svg {
        width: 20px;
        height: 20px;
        fill: currentColor;
    }
    
    .mobile-nav-item.active {
        color: var(--primary);
    }

    /* Mobile Search Drawer */
    .mobile-search-drawer {
        position: fixed;
        top: var(--header-height);
        left: 0;
        right: 0;
        background-color: var(--bg-surface);
        border-bottom: 1px solid var(--border-color);
        padding: 12px 16px;
        z-index: 99;
        box-shadow: var(--shadow);
        transform: translateY(-120%);
        opacity: 0;
        transition: var(--transition);
        pointer-events: none;
    }
    .mobile-search-drawer.show {
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }

    .mobile-only-search-btn {
        display: flex !important;
    }
}

/* 4. Medium Tablet (768px) */
@media (max-width: 991px) and (min-width: 768px) {
    .video-grid {
        grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
        gap: 16px;
    }
}

@media (min-width: 993px) {
    .mobile-bottom-nav, .mobile-overlay, .mobile-only-search-btn, .mobile-search-drawer {
        display: none !important;
    }
}

@media (max-width: 768px) {
    /* Style Upload Badge as circular icon button on mobile */
    .upload-badge {
        padding: 0;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        justify-content: center;
        background: var(--bg-surface-elevated);
        color: var(--text-main);
        border: 1px solid var(--border-color);
        box-shadow: none;
    }
    .upload-badge:hover {
        background-color: var(--primary);
        color: white;
        border-color: var(--primary);
    }
    .upload-badge .upload-text {
        display: none;
    }
    .upload-badge .upload-icon {
        display: flex;
        align-items: center;
        justify-content: center;
    }
    .upload-badge svg {
        width: 20px;
        height: 20px;
        fill: currentColor;
    }
}

/* 5. Mobile Viewport (600px) */
@media (max-width: 767px) and (min-width: 600px) {
    .video-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 16px;
    }
}

/* 6. Mobile Small Viewports (480px, 375px, 320px) */
@media (max-width: 599px) {
    .video-grid {
        grid-template-columns: 1fr;
        gap: 16px;
    }
    .video-card {
        border-radius: 0;
        border-left: none;
        border-right: none;
        box-shadow: none;
    }
}

@media (max-width: 480px) {
    .icon-btn {
        width: 34px;
        height: 34px;
    }
    .icon-btn svg {
        width: 16px;
        height: 16px;
    }
    .upload-badge {
        width: 34px !important;
        height: 34px !important;
    }
    .upload-badge svg {
        width: 16px !important;
        height: 16px !important;
    }
    .avatar-img {
        width: 32px;
        height: 32px;
    }
    .top-header {
        padding: 0 10px;
        gap: 8px;
    }
    .user-actions {
        gap: 8px;
    }
    .logo-img {
        max-height: 32px;
    }
}

@media (max-width: 375px) {
    .logo-section span {
        display: none; /* Hide brand name text on narrow screen widths to fit buttons */
    }
    .logo-img {
        max-width: 100px;
    }
}

@media (max-width: 320px) {
    .top-header {
        padding: 0 6px;
        gap: 6px;
    }
    .user-actions {
        gap: 6px;
    }
}

/* Premium Auth Form Styling Rules */
.auth-form {
    display: flex;
    flex-direction: column;
}

.password-input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.password-toggle-btn {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: var(--text-dim);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    z-index: 10;
}

.password-toggle-btn:hover {
    color: var(--text-muted);
}

.password-toggle-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
    pointer-events: none;
}

.btn-submit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    border-radius: 8px !important;
    padding: 12px 20px;
    font-weight: 600;
    transition: var(--transition);
    box-sizing: border-box;
    height: 48px;
}

.btn-submit.loading {
    pointer-events: none;
    opacity: 0.8;
}

/* Global Mobile Form & Card Helper Layouts */
@media (max-width: 599px) {
    /* Stack form action button blocks */
    form div[style*="display:flex"], form div[style*="display: flex"], div[style*="justify-content:flex-end"] {
        flex-direction: column !important;
        width: 100% !important;
        gap: 10px !important;
    }
    form .btn:not(.password-toggle-btn),
    form button:not(.password-toggle-btn),
    .panel button[type="submit"] {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    .password-input-wrapper .password-toggle-btn {
        position: absolute !important;
        top: 50%;
        right: 8px;
        width: 36px !important;
        min-width: 36px;
        height: 36px;
        margin: 0 !important;
        padding: 4px !important;
        transform: translateY(-50%);
        display: inline-flex !important;
        flex: 0 0 auto;
    }

    .password-input-wrapper input {
        padding-right: 52px !important;
    }
}

/* YouTube Search Import Card Mobile Squeezing Overrides */
@media (max-width: 480px) {
    .search-card {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
        padding: 16px !important;
    }
    .search-card > div:first-child {
        align-self: flex-start;
    }
    .search-card > div[style*="width: 140px"], .search-card > div[style*="width:140px"] {
        width: 100% !important;
        max-width: 100% !important;
        aspect-ratio: 16 / 9;
    }
}

/* Mobile Sidebar Overlay styles */
.mobile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    transition: opacity 0.3s ease;
}
.mobile-overlay.show {
    display: block;
}

/* Admin Responsive Search Bar and Pagination Styling */
.admin-search-wrapper {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
    padding: 10px 0;
}
.admin-search-form {
    display: flex;
    align-items: center;
    width: 100%;
    max-width: 400px;
    position: relative;
}
.admin-search-input {
    width: 100%;
    padding: 10px 16px;
    padding-right: 45px;
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-main);
    font-size: 14px;
    transition: var(--transition);
}
.admin-search-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px var(--primary-glow);
}
.admin-search-btn {
    position: absolute;
    right: 5px;
    background: none;
    border: none;
    padding: 8px;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}
.admin-search-btn:hover {
    color: var(--primary);
}
.admin-search-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Pagination controls */
.pagination-wrapper {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
    margin-top: 20px;
    flex-wrap: wrap;
    gap: 15px;
}
.pagination-info {
    font-size: 13px;
    color: var(--text-muted);
}
.pagination-links {
    display: flex;
    gap: 6px;
}
.pagination-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    font-size: 13px;
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition);
}
.pagination-link:hover {
    background-color: var(--primary-glow);
    border-color: var(--primary);
    color: var(--primary);
}
.pagination-link.active {
    background-color: var(--primary);
    border-color: var(--primary);
    color: #fff;
    pointer-events: none;
}
.pagination-link.disabled {
    opacity: 0.5;
    pointer-events: none;
    cursor: not-allowed;
}

/* Mobile adjustments for forms and controls */
@media (max-width: 768px) {
    .admin-search-form {
        max-width: 100%;
    }
    .pagination-wrapper {
        flex-direction: column;
        align-items: center;
        text-align: center;
    }
}

/* Responsive Table Wrapper styling */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 20px;
}

/* Final responsive layout hardening: protects every page from horizontal overflow. */
html,
body {
    width: 100%;
    max-width: 100%;
    overflow-x: hidden;
}

img,
video,
iframe,
canvas,
embed,
object {
    max-width: 100%;
}

img,
video {
    height: auto;
}

.layout-wrapper,
.layout-wrapper > div,
.top-header > div,
.main-content,
.admin-main,
.sidebar,
.admin-sidebar,
.panel,
.panel-header,
.content-header,
.card-details,
.card-text,
.user-actions,
.search-section,
.avatar-menu {
    min-width: 0;
}

.main-content,
.admin-main {
    width: auto;
    max-width: 100%;
}

.logo-section {
    min-width: 0;
}

.logo-section span,
.admin-menu-item a,
.nav-item a,
.video-title,
.panel-title {
    overflow-wrap: anywhere;
}

.table-wrapper {
    max-width: 100%;
}

.pagination-links,
.tab-nav {
    max-width: 100%;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 991px) {
    .main-content,
    .admin-main {
        width: 100%;
        max-width: 100%;
    }

    .top-header > div:first-child {
        min-width: 0;
        gap: 10px !important;
    }

    .top-header .logo-section {
        min-width: 0;
    }
}

@media (max-width: 767px) {
    .main-content,
    .admin-main {
        padding: 14px;
    }

    .panel {
        padding: 16px;
        border-radius: 12px;
    }

    .panel-header,
    .content-header,
    .admin-search-wrapper {
        flex-wrap: wrap;
        gap: 12px;
    }

    .admin-search-wrapper {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .panel-header > *,
    .content-header > *,
    .admin-search-wrapper > * {
        min-width: 0;
    }

    .pagination-links {
        width: 100%;
        justify-content: flex-start;
        overflow-x: auto;
        padding-bottom: 4px;
    }

    [style*="grid-template-columns: 2fr 1fr"],
    [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    [style*="min-width:250px"],
    [style*="min-width: 250px"],
    [style*="min-width:200px"],
    [style*="min-width: 200px"] {
        min-width: 0 !important;
    }

    [style*="max-width:250px"],
    [style*="max-width: 250px"],
    [style*="max-width:200px"],
    [style*="max-width: 200px"] {
        max-width: 100% !important;
    }

    .tab-link {
        white-space: nowrap;
        flex: 0 0 auto;
    }
}

@media (max-width: 480px) {
    .top-header {
        gap: 6px;
        padding-left: 8px;
        padding-right: 8px;
    }

    .top-header > div:first-child {
        gap: 6px !important;
        flex: 1 1 auto;
        overflow: hidden;
    }

    .top-header .logo-section {
        max-width: 112px;
        overflow: hidden;
    }

    .top-header .logo-section span {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .user-actions {
        flex: 0 0 auto;
        gap: 6px;
    }

    .user-actions .btn {
        white-space: nowrap;
        padding-left: 9px;
        padding-right: 9px;
    }

    .main-content,
    .admin-main {
        padding: 10px;
    }

    .panel {
        padding: 14px;
    }

    .toast-msg {
        left: 12px;
        right: 12px;
        bottom: 76px;
        width: auto;
        overflow-wrap: anywhere;
    }
}
