
/* ===== AgentR Mandatory Baseline CSS ===== */
*,*::before,*::after{box-sizing:border-box}
html,body{margin:0;padding:0;min-height:100vh;font-family:'Inter','Plus Jakarta Sans',system-ui,sans-serif}
img{max-width:100%;height:auto}
a{text-decoration:none;color:inherit}
button,input,select,textarea{font-family:inherit}

/* ===== DARK BACKGROUND AUTO-CONTRAST =====
   When body has a dark inline background (#0xx, #1xx, #2xx or rgb low values),
   force white text on all content so labels/subtitles are never invisible on dark cards. */
body[style*="background:#0"],body[style*="background: #0"],body[style*="background-color:#0"],
body[style*="background:#1"],body[style*="background: #1"],body[style*="background-color:#1"],
body[style*="background:#2"],body[style*="background: #2"],body[style*="background-color:#2"]{color:#f1f5f9}
body[style*="background:#0"] .auth-card,body[style*="background:#1"] .auth-card,body[style*="background:#2"] .auth-card,
body[style*="background: #0"] .auth-card,body[style*="background: #1"] .auth-card,body[style*="background: #2"] .auth-card{background:rgba(255,255,255,0.06);border:1px solid rgba(255,255,255,0.1);color:#f1f5f9}
body[style*="background:#0"] .form-control,body[style*="background:#1"] .form-control,body[style*="background:#2"] .form-control,
body[style*="background: #0"] .form-control,body[style*="background: #1"] .form-control,body[style*="background: #2"] .form-control{background:rgba(255,255,255,0.07);border-color:rgba(255,255,255,0.18);color:#f1f5f9}
body[style*="background:#0"] .form-control::placeholder,body[style*="background:#1"] .form-control::placeholder,body[style*="background:#2"] .form-control::placeholder,
body[style*="background: #0"] .form-control::placeholder,body[style*="background: #1"] .form-control::placeholder,body[style*="background: #2"] .form-control::placeholder{color:rgba(241,245,249,0.4)}
body[style*="background:#0"] .sidebar,body[style*="background:#1"] .sidebar,body[style*="background:#2"] .sidebar,
body[style*="background: #0"] .sidebar,body[style*="background: #1"] .sidebar,body[style*="background: #2"] .sidebar{border-right-color:rgba(255,255,255,0.08)}
body[style*="background:#0"] .card,body[style*="background:#1"] .card,body[style*="background:#2"] .card,
body[style*="background: #0"] .card,body[style*="background: #1"] .card,body[style*="background: #2"] .card{border-color:rgba(255,255,255,0.08)}

/* ===== LIGHT BACKGROUND AUTO-CONTRAST =====
   When body has a light inline background (#d, #e, #f, white, #fff),
   force dark text so labels/subtitles are never invisible on light pages. */
body[style*="background:#f"],body[style*="background: #f"],body[style*="background-color:#f"],
body[style*="background:#e"],body[style*="background: #e"],body[style*="background-color:#e"],
body[style*="background:#d"],body[style*="background: #d"],body[style*="background-color:#d"],
body[style*="background:white"],body[style*="background: white"],body[style*="background:#fff"],body[style*="background: #fff"],
body[style*="background-color:white"],body[style*="background-color:#fff"]{color:#1a1a2e}
body[style*="background:#f"] .auth-card,body[style*="background:#e"] .auth-card,body[style*="background:#d"] .auth-card,
body[style*="background: #f"] .auth-card,body[style*="background: #e"] .auth-card,body[style*="background: #d"] .auth-card,
body[style*="background:white"] .auth-card,body[style*="background:#fff"] .auth-card{background:#ffffff;border:1px solid #e2e8f0;color:#1a1a2e}
body[style*="background:#f"] .form-control,body[style*="background:#e"] .form-control,body[style*="background:#d"] .form-control,
body[style*="background: #f"] .form-control,body[style*="background: #e"] .form-control,body[style*="background: #d"] .form-control,
body[style*="background:white"] .form-control,body[style*="background:#fff"] .form-control{background:#ffffff;border-color:#e2e8f0;color:#1a1a2e}
body[style*="background:#f"] .form-control::placeholder,body[style*="background:#e"] .form-control::placeholder,body[style*="background:#d"] .form-control::placeholder,
body[style*="background: #f"] .form-control::placeholder,body[style*="background: #e"] .form-control::placeholder,body[style*="background: #d"] .form-control::placeholder{color:#94a3b8}
body[style*="background:#f"] .form-group label,body[style*="background:#e"] .form-group label,body[style*="background:#d"] .form-group label,
body[style*="background: #f"] .form-group label,body[style*="background: #e"] .form-group label,body[style*="background: #d"] .form-group label{color:#374151;opacity:1}
body[style*="background:#f"] .auth-card h1,body[style*="background:#f"] .auth-card h2,body[style*="background:#e"] .auth-card h1,body[style*="background:#e"] .auth-card h2,
body[style*="background: #f"] .auth-card h1,body[style*="background: #f"] .auth-card h2,body[style*="background: #e"] .auth-card h1,body[style*="background: #e"] .auth-card h2{color:#0f172a}
body[style*="background:#f"] .auth-card .subtitle,body[style*="background:#f"] .auth-link,body[style*="background:#e"] .auth-card .subtitle,body[style*="background:#e"] .auth-link,
body[style*="background: #f"] .auth-card .subtitle,body[style*="background: #f"] .auth-link,body[style*="background: #e"] .auth-card .subtitle,body[style*="background: #e"] .auth-link{color:#64748b;opacity:1}
body[style*="background:#f"] .card,body[style*="background:#e"] .card,body[style*="background:#d"] .card,
body[style*="background: #f"] .card,body[style*="background: #e"] .card,body[style*="background: #d"] .card,
body[style*="background:white"] .card,body[style*="background:#fff"] .card{background:#ffffff;border-color:#e2e8f0;color:#1a1a2e}

/* Auth pages */
.auth-wrapper{min-height:100vh;display:flex;align-items:center;justify-content:center;padding:20px}
.auth-card{width:100%;max-width:420px;border-radius:20px;padding:40px;box-shadow:0 20px 60px rgba(0,0,0,0.15)}
.auth-logo{display:flex;align-items:center;justify-content:center;gap:10px;margin-bottom:28px}
.auth-logo span{font-size:22px;font-weight:800;letter-spacing:-0.5px}
.auth-card h1,.auth-card h2{font-size:26px;font-weight:800;margin:0 0 6px;letter-spacing:-0.5px}
.auth-card .subtitle{font-size:14px;opacity:0.6;margin-bottom:28px}
.form-group{margin-bottom:18px}
.form-group label{display:block;font-size:13px;font-weight:600;margin-bottom:7px;opacity:0.8}
.form-group input,.form-control{width:100%;padding:13px 16px;border-radius:12px;font-size:15px;outline:none;transition:border-color .2s,box-shadow .2s;border-width:1.5px;border-style:solid}
.form-group input:focus,.form-control:focus{box-shadow:0 0 0 4px rgba(99,102,241,.15)}
.btn,.button,button[type=submit]{display:inline-flex;align-items:center;justify-content:center;gap:8px;padding:13px 24px;border-radius:12px;font-size:15px;font-weight:700;cursor:pointer;border:none;transition:transform .2s,box-shadow .2s;width:auto}
.btn-primary,button[type=submit]{background:linear-gradient(135deg,#6366f1,#8b5cf6);color:#fff;box-shadow:0 4px 15px rgba(99,102,241,.35)}
.btn-primary:hover,button[type=submit]:hover{transform:translateY(-2px);box-shadow:0 8px 25px rgba(99,102,241,.45)}
.btn-full{width:100%}
.auth-link{text-align:center;margin-top:20px;font-size:14px;opacity:0.7}
.auth-link a{font-weight:600;opacity:1}
.alert{padding:12px 16px;border-radius:10px;font-size:14px;margin-bottom:18px;border-width:1px;border-style:solid}
.alert-danger{background:rgba(239,68,68,.1);border-color:rgba(239,68,68,.3);color:#ef4444}
.alert-success{background:rgba(16,185,129,.1);border-color:rgba(16,185,129,.3);color:#10b981}

/* Layout */
.container{width:100%;max-width:1200px;margin:0 auto;padding:0 20px}
.layout{display:flex;min-height:100vh}
.sidebar{width:260px;padding:24px 16px;flex-shrink:0;border-right-width:1px;border-right-style:solid}
.main-content{flex:1;padding:32px;min-width:0}
.card{border-radius:16px;padding:24px;margin-bottom:20px;border-width:1px;border-style:solid}
.grid-auto{display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:20px}
.flex{display:flex}.flex-col{flex-direction:column}.items-center{align-items:center}.justify-between{justify-content:space-between}.gap-2{gap:8px}.gap-3{gap:12px}.gap-4{gap:16px}
.flex-1{flex:1;min-width:0}.w-full{width:100%}
.w-8{width:32px;height:32px;flex-shrink:0}.w-10{width:40px;height:40px;flex-shrink:0}.w-12{width:48px;height:48px;flex-shrink:0}
img.rounded-full,.avatar{border-radius:50%;object-fit:cover;flex-shrink:0}
.rounded-full{border-radius:50%}
.text-sm{font-size:13px}.text-xs{font-size:11px}.font-bold{font-weight:700}.font-semibold{font-weight:600}

/* Mobile */
@media(max-width:768px){.sidebar{display:none}.main-content{padding:16px}.grid-auto{grid-template-columns:1fr}.auth-card{padding:28px 20px}}
/* ===== End Baseline ===== */

/* ===== AgentR Dark Theme — Auto-Injected ===== */
:root{--bg:#0f0f0f;--surface:#111111;--surface2:#181818;--border:rgba(255,255,255,0.07);--text:#e8e8e8;--muted:#888;--primary:#6366f1;--primary-light:rgba(99,102,241,0.15)}
body{background:var(--bg);color:var(--text);margin:0;padding:0;min-height:100vh;font-family:'Inter','Plus Jakarta Sans',system-ui,sans-serif}

/* Layout */
.layout{display:flex;min-height:100vh}

/* Sidebar */
.sidebar{width:240px;background:var(--surface);border-right:1px solid var(--border);padding:0;flex-shrink:0;display:flex;flex-direction:column;position:sticky;top:0;height:100vh;overflow-y:auto;scrollbar-width:none}
.sidebar::-webkit-scrollbar{display:none}
.sidebar-logo{display:flex;align-items:center;gap:10px;padding:20px 20px 16px;font-size:18px;font-weight:800;letter-spacing:-0.5px;color:#fff;border-bottom:1px solid var(--border);margin-bottom:8px}
.sidebar-logo .logo-icon{color:var(--primary);flex-shrink:0}
.sidebar-nav{display:flex;flex-direction:column;padding:8px 12px;gap:2px;flex:1}
.nav-item{display:flex;align-items:center;gap:12px;padding:10px 12px;border-radius:10px;font-size:14px;font-weight:500;color:var(--muted);transition:background .15s,color .15s;text-decoration:none}
.nav-item:hover{background:rgba(255,255,255,0.07);color:#fff}
.nav-item.active{background:var(--primary-light);color:#a5b4fc;font-weight:600}
.nav-item svg{flex-shrink:0;opacity:.8;display:block;min-width:20px}
.nav-item.active svg{opacity:1}
.sidebar-section-title{font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.08em;color:#444;padding:16px 12px 6px}

/* Main Content */
.main-content{flex:1;min-width:0;display:flex;flex-direction:column;background:var(--bg);overflow-y:auto}

/* Top Navbar (mobile-header used as sticky topbar on all viewports) */
.mobile-header{display:flex;align-items:center;gap:12px;padding:0 24px;height:60px;background:rgba(15,15,15,0.95);border-bottom:1px solid rgba(255,255,255,0.07);position:sticky;top:0;z-index:100;backdrop-filter:blur(12px);-webkit-backdrop-filter:blur(12px)}
.mobile-header .sidebar-logo{padding:0;border:none;margin:0;font-size:16px}
.header-actions{display:flex;align-items:center;gap:10px;margin-left:auto}
.mobile-menu-btn{display:none;background:none;border:none;color:var(--muted);cursor:pointer;padding:6px;border-radius:8px;flex-shrink:0;transition:color .15s}
.mobile-menu-btn:hover{color:#fff}

/* Search */
.search-form{display:flex;align-items:center;background:rgba(255,255,255,0.06);border:1px solid rgba(255,255,255,0.1);border-radius:24px;overflow:hidden;transition:border-color .2s}
.search-form:focus-within{border-color:rgba(99,102,241,0.5)}
.search-input{background:none;border:none;outline:none;color:var(--text);font-size:14px;padding:8px 16px;width:220px;box-shadow:none!important}
.search-input::placeholder{color:#555}
.search-form .btn-icon{width:40px;height:36px;border-radius:0;background:rgba(99,102,241,.7);border:none;color:#fff;border-left:1px solid rgba(99,102,241,.3);display:inline-flex;align-items:center;justify-content:center;cursor:pointer}
.search-form .btn-icon:hover{background:rgba(99,102,241,.9)}

/* Buttons */
.btn-icon{display:inline-flex;align-items:center;justify-content:center;width:36px;height:36px;border-radius:50%;background:rgba(255,255,255,0.06);border:1px solid rgba(255,255,255,0.08);color:var(--muted);cursor:pointer;transition:background .15s,color .15s;flex-shrink:0;padding:0}
.btn-icon:hover{background:rgba(255,255,255,0.12);color:#fff}
.btn-secondary{padding:7px 18px;border-radius:20px;background:transparent;border:1px solid rgba(255,255,255,0.18);color:var(--text);font-size:13px;font-weight:600;cursor:pointer;transition:background .15s,border-color .15s;white-space:nowrap}
.btn-secondary:hover{background:rgba(255,255,255,0.08);border-color:rgba(255,255,255,0.3)}

/* Avatar */
.avatar{border-radius:50%;object-fit:cover;flex-shrink:0}
.avatar-link{display:flex;align-items:center}
.avatar-link .avatar{width:32px;height:32px}
.avatar-sm{width:36px;height:36px}

/* Cards */
.card{background:var(--surface2);border:1px solid var(--border);border-radius:16px;padding:24px;margin-bottom:20px;transition:transform .2s,box-shadow .2s,border-color .2s}
.card:hover{transform:translateY(-3px);box-shadow:0 12px 40px rgba(0,0,0,0.4);border-color:rgba(99,102,241,0.25)}

/* Page content */
.page-header{padding:28px 28px 8px}
.page-header h1{font-size:22px;font-weight:700;letter-spacing:-.3px;margin:0;color:#fff}
.section{padding:8px 28px 28px}
.section-title{font-size:16px;font-weight:700;color:var(--text);margin:0 0 16px;letter-spacing:-.2px}

/* Content grid */
.grid-auto{display:grid;grid-template-columns:repeat(auto-fill,minmax(260px,1fr));gap:20px}

/* Video / content cards */
.video-card{background:var(--surface2);border-radius:14px;overflow:hidden;border:1px solid var(--border);transition:transform .2s,box-shadow .2s,border-color .2s;cursor:pointer}
.video-card:hover{transform:translateY(-3px);box-shadow:0 12px 40px rgba(0,0,0,0.5);border-color:rgba(99,102,241,0.25)}
.video-thumbnail-link{display:block;position:relative;aspect-ratio:16/9;overflow:hidden;background:#252525}
.video-thumbnail{width:100%;height:100%;object-fit:cover;transition:transform .3s;display:block}
.video-card:hover .video-thumbnail{transform:scale(1.04)}
.video-info{display:flex;gap:10px;padding:12px}
.video-details{display:flex;flex-direction:column;gap:3px;min-width:0}
.video-title{font-size:14px;font-weight:600;color:var(--text);line-height:1.4;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;transition:color .15s}
.video-title:hover{color:#a5b4fc}
.channel-name{font-size:12px;color:var(--muted);transition:color .15s;font-weight:500}
.channel-name:hover{color:#bbb}
.video-meta{font-size:12px;color:#555}

/* Empty state */
.empty-state{display:flex;flex-direction:column;align-items:center;justify-content:center;padding:60px 20px;text-align:center;color:#555;gap:12px}
.empty-state h3{font-size:18px;font-weight:700;color:#888;margin:0}
.empty-state p{font-size:14px;margin:0;color:#555}
.empty-state .btn-primary{margin-top:8px;width:auto;padding:10px 24px}

/* Toast */
#toast-container{position:fixed;bottom:24px;right:24px;display:flex;flex-direction:column;gap:10px;z-index:9999}
.toast{padding:12px 20px;border-radius:12px;font-size:14px;font-weight:600;color:#fff;opacity:0;transform:translateY(10px);transition:opacity .25s,transform .25s;background:#1e1e2e;border:1px solid rgba(255,255,255,0.1)}
.toast.show{opacity:1;transform:none}
.toast-success{background:rgba(16,185,129,0.15);border-color:rgba(16,185,129,0.35);color:#34d399}
.toast-error{background:rgba(239,68,68,0.15);border-color:rgba(239,68,68,0.35);color:#f87171}

/* Badges */
.badge{display:inline-flex;align-items:center;padding:4px 12px;border-radius:20px;font-size:11px;font-weight:700;text-transform:uppercase;letter-spacing:.06em}
.badge-success{background:rgba(16,185,129,.15);color:#34d399;border:1px solid rgba(16,185,129,.3)}
.badge-warning{background:rgba(245,158,11,.15);color:#fbbf24;border:1px solid rgba(245,158,11,.3)}
.badge-danger{background:rgba(239,68,68,.15);color:#f87171;border:1px solid rgba(239,68,68,.3)}
.badge-info{background:rgba(99,102,241,.15);color:#a5b4fc;border:1px solid rgba(99,102,241,.3)}

/* Animations */
@keyframes fadeIn{from{opacity:0;transform:translateY(12px)}to{opacity:1;transform:none}}
.fade-in{animation:fadeIn .4s ease both}
.fade-in-delay-1{animation:fadeIn .4s ease .08s both}
.fade-in-delay-2{animation:fadeIn .4s ease .16s both}
.fade-in-delay-3{animation:fadeIn .4s ease .24s both}

/* Utilities */
.mt-4{margin-top:16px}.hide-mobile{display:block}
@media(max-width:768px){.hide-mobile{display:none!important}}

/* Responsive */
@media(max-width:900px){.sidebar{width:200px}.grid-auto{grid-template-columns:repeat(auto-fill,minmax(200px,1fr));gap:14px}}
@media(max-width:768px){
  .sidebar{position:fixed;left:-260px;top:0;height:100vh;width:260px;z-index:200;transition:left .25s ease;box-shadow:4px 0 30px rgba(0,0,0,0.5)}
  .sidebar.open{left:0}
  .mobile-menu-btn{display:flex}
  .page-header{padding:16px 16px 8px}
  .section{padding:8px 16px 20px}
  .grid-auto{grid-template-columns:repeat(auto-fill,minmax(160px,1fr));gap:12px}
  .search-input{width:140px}
}
@media(max-width:480px){.grid-auto{grid-template-columns:1fr 1fr;gap:10px}.video-info{padding:8px;gap:8px}.mobile-header{padding:0 14px}}

/* Stats/Metrics grid — always 4 columns on desktop, responsive below */
.stats-grid{display:grid;grid-template-columns:repeat(4,1fr);gap:20px}
.stat-card{background:var(--surface2);border:1px solid var(--border);border-radius:16px;padding:20px 24px;display:flex;flex-direction:column;gap:6px;transition:transform .2s,box-shadow .2s}
.stat-card:hover{transform:translateY(-3px);box-shadow:0 12px 40px rgba(0,0,0,0.4)}
.stat-card .stat-icon{width:40px;height:40px;border-radius:10px;display:flex;align-items:center;justify-content:center;background:var(--primary-light);color:var(--primary);margin-bottom:4px}
.stat-card .stat-value{font-size:28px;font-weight:800;color:#fff;letter-spacing:-1px;line-height:1}
.stat-card .stat-label{font-size:13px;color:var(--muted);font-weight:500}
@media(max-width:900px){.stats-grid{grid-template-columns:repeat(2,1fr)}}
@media(max-width:480px){.stats-grid{grid-template-columns:1fr 1fr;gap:12px}.stat-card{padding:16px}}

/* User dropdown in header — proper positioned menu, not inline text */
.user-menu{position:relative;display:flex;align-items:center;gap:8px;cursor:pointer}
.user-menu .avatar{width:34px;height:34px;border-radius:50%;object-fit:cover;border:2px solid var(--border)}
.user-menu-toggle{display:flex;align-items:center;gap:8px;background:none;border:none;cursor:pointer;color:var(--text);font-size:14px;font-weight:600;padding:6px 10px;border-radius:10px;transition:background .15s}
.user-menu-toggle:hover{background:rgba(255,255,255,0.06)}
.user-dropdown{position:absolute;right:0;top:calc(100% + 8px);min-width:160px;background:var(--surface2);border:1px solid var(--border);border-radius:12px;padding:6px;z-index:500;box-shadow:0 8px 32px rgba(0,0,0,0.5);display:none}
.user-dropdown.show{display:block}
.user-dropdown a,.user-dropdown button{display:flex;align-items:center;gap:10px;width:100%;padding:9px 12px;border-radius:8px;font-size:14px;font-weight:500;color:var(--text);background:none;border:none;cursor:pointer;text-decoration:none;transition:background .12s,color .12s}
.user-dropdown a:hover,.user-dropdown button:hover{background:rgba(255,255,255,0.07);color:#fff}
.user-dropdown .dropdown-divider{height:1px;background:var(--border);margin:4px 0}
.user-dropdown .logout-item,.user-dropdown a[href*="logout"]{color:#f87171}
.user-dropdown .logout-item:hover,.user-dropdown a[href*="logout"]:hover{background:rgba(239,68,68,0.1)}

/* ===== AgentR Universal Fixes (prevents common AI generation bugs) ===== */
/* FIX 1: Remove browser-default underline on ALL links — prevents underlines on nav links and buttons */
a{text-decoration:none}
a:hover{text-decoration:none}

/* FIX 2: Universal navbar layout fallback — prevents stacked/unstyled nav when AI CSS is missing */
/* Applies to any element that looks like a navbar */
nav,header,.navbar,.nav-bar,.topbar,.top-bar,.site-header,.page-header-nav,.header-nav,.main-header,.app-header{display:flex;align-items:center}
/* Nav link lists should always be horizontal */
nav ul,.navbar ul,.nav-links,.nav-items,.nav-menu,.header-links,.header-nav-links,.menu-links{display:flex;align-items:center;list-style:none;margin:0;padding:0;gap:0}
nav ul li,.navbar ul li,.nav-links li,.nav-items li,.nav-menu li{list-style:none;margin:0;padding:0}
/* All links inside navbars/headers should never be underlined and inherit color */
nav a,header a,.navbar a,.nav-bar a,.topbar a,.top-bar a,.site-header a,.header a,.nav-links a,.nav-menu a,.nav-items a{text-decoration:none;color:inherit}
/* Buttons/CTAs that are <a> tags should never have underlines */
a.btn,a.button,a.btn-primary,a.btn-secondary,a.cta-btn,a.cta-button,a.nav-btn,a.header-btn,a.get-started,.btn>a,.button>a{text-decoration:none;display:inline-flex;align-items:center;justify-content:center}
/* ===== End AgentR Dark Theme ===== */