/* YouTube Studio Dark Theme & Professional Design System */
:root {
    --bg: #0f0f0f;
    --card: #1f1f1f;
    --card-hover: #262626;
    --tx: #f1f1f1;
    --mu: #aaaaaa;
    --bd: #2f2f2f;
    --bd-light: #3d3d3d;
    --pr: #ff0000;
    --yt-red: #ff0000;
    --yt-blue: #3ea6ff;
    --yt-purple: #7950f2;
    --ok: #2ba640;
    --bad: #ff4e45;
    --amber: #f59e0b;
    --gold: #eab308;
}

@media (prefers-color-scheme: light) {
    :root {
        --bg: #f9f9f9;
        --card: #ffffff;
        --card-hover: #f1f5f9;
        --tx: #0f0f0f;
        --mu: #606060;
        --bd: #e5e5e5;
        --bd-light: #d1d5db;
        --pr: #cc0000;
        --yt-blue: #065fd4;
        --yt-purple: #6741d9;
        --ok: #15803d;
        --bad: #dc2626;
    }
}

* { box-sizing: border-box; }
body {
    margin: 0;
    background: var(--bg);
    color: var(--tx);
    font-family: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.7;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

/* Studio Header & Topbar */
.studio-topbar {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
    justify-content: space-between;
    padding: 10px 24px;
    background: var(--card);
    border-bottom: 1px solid var(--bd);
    position: sticky;
    top: 0;
    z-index: 100;
}
.brand-area {
    display: flex;
    align-items: center;
    gap: 10px;
}
.yt-logo-icon {
    display: block;
}
.logo-text {
    font-size: 1.15rem;
    letter-spacing: -0.3px;
}
.logo-text b {
    color: var(--yt-blue);
    font-weight: 700;
}
.channel-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--bd);
    padding: 3px 10px;
    border-radius: 99px;
    font-size: 0.82rem;
    color: var(--tx);
}

.studio-nav {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}
.studio-nav a {
    color: var(--mu);
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 0.9rem;
    transition: all 0.15s ease;
}
.studio-nav a:hover {
    color: var(--tx);
    background: rgba(255, 255, 255, 0.06);
}
.studio-nav a.on {
    color: var(--tx);
    background: rgba(255, 255, 255, 0.1);
    font-weight: 600;
}
.studio-nav a.nav-agent {
    color: #eab308;
    background: rgba(234, 179, 8, 0.1);
    border: 1px solid rgba(234, 179, 8, 0.25);
}
.studio-nav a.nav-agent.on {
    background: rgba(234, 179, 8, 0.2);
    border-color: #eab308;
}
.studio-nav a.nav-logout {
    color: var(--bad);
}

/* Page Container */
main {
    max-width: 1360px;
    margin: 24px auto;
    padding: 0 20px;
}
h1 { font-size: 1.4rem; margin: 0 0 10px; }
h2 { font-size: 1.15rem; margin: 0 0 12px; }
h3 { font-size: 1rem; margin: 0 0 8px; }

/* Studio Header */
.studio-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 20px;
}
.studio-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}
.studio-subtitle {
    margin: 4px 0 0;
    color: var(--mu);
    font-size: 0.92rem;
}
.studio-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/* Cards */
.card {
    background: var(--card);
    border: 1px solid var(--bd);
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 18px;
    transition: border-color 0.2s;
}

/* Grid & KPI */
.grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
    gap: 14px;
}
.kpi {
    padding: 16px;
}
.kpi small {
    color: var(--mu);
    font-size: 0.85rem;
    display: block;
}
.kpi b {
    display: block;
    font-size: 1.6rem;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    margin: 4px 0;
}

/* Tabs */
.studio-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 14px;
    border-bottom: 1px solid var(--bd);
    padding-bottom: 8px;
    overflow-x: auto;
}
.studio-tab {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: 8px;
    color: var(--mu);
    text-decoration: none;
    font-size: 0.92rem;
    font-weight: 500;
    white-space: nowrap;
    transition: all 0.15s ease;
}
.studio-tab:hover {
    color: var(--tx);
    background: rgba(255, 255, 255, 0.05);
}
.studio-tab.active {
    color: var(--tx);
    background: rgba(255, 255, 255, 0.12);
    font-weight: 600;
}
.tab-count {
    background: rgba(255, 255, 255, 0.1);
    font-size: 0.78rem;
    padding: 1px 7px;
    border-radius: 99px;
}
.tab-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}
.dot-green { background: var(--ok); }
.dot-blue { background: var(--yt-blue); }
.dot-gray { background: var(--mu); }

/* YouTube Studio Video Table */
.studio-table-card {
    padding: 0;
    overflow-x: auto;
}
.studio-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.studio-table th {
    padding: 12px 16px;
    border-bottom: 1px solid var(--bd);
    text-align: right;
    color: var(--mu);
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    background: rgba(0, 0, 0, 0.15);
}
.studio-table td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--bd);
    vertical-align: top;
}
.studio-table tbody tr:hover {
    background: var(--card-hover);
}

/* Video Cell */
.video-cell-flex {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}
.thumb-container {
    position: relative;
    width: 140px;
    min-width: 140px;
    aspect-ratio: 16 / 9;
    border-radius: 6px;
    overflow: hidden;
    background: #000;
}
.video-thumb {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.video-duration {
    position: absolute;
    bottom: 4px;
    left: 4px;
    background: rgba(0, 0, 0, 0.85);
    color: #fff;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    direction: ltr;
}
.video-info {
    flex: 1;
    min-width: 0;
}
.video-title {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--tx);
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.45;
    margin-bottom: 4px;
}
.video-title:hover {
    color: var(--yt-blue);
}
.video-desc-snippet {
    font-size: 0.82rem;
    color: var(--mu);
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
    margin-bottom: 8px;
}
.video-quick-actions {
    display: flex;
    gap: 6px;
    align-items: center;
    flex-wrap: wrap;
}
.action-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.78rem;
    padding: 3px 8px;
    border-radius: 6px;
    border: 1px solid var(--bd);
    background: rgba(255, 255, 255, 0.04);
    color: var(--tx);
    text-decoration: none;
    cursor: pointer;
    font-family: inherit;
    transition: all 0.15s ease;
}
.action-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}
.action-btn.btn-search {
    background: rgba(121, 80, 242, 0.15);
    border-color: rgba(121, 80, 242, 0.4);
    color: #b197fc;
    font-weight: 600;
}
.action-btn.btn-search:hover {
    background: rgba(121, 80, 242, 0.28);
}
.action-btn.btn-plan {
    background: rgba(234, 179, 8, 0.15);
    border-color: rgba(234, 179, 8, 0.4);
    color: #facc15;
    font-weight: 600;
}
.vid-pill {
    font-size: 0.72rem;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    color: var(--mu);
    font-family: monospace;
    direction: ltr;
}
.score-pill {
    background: var(--pr);
    color: #fff;
    padding: 0 5px;
    border-radius: 99px;
    font-size: 0.7rem;
    margin-right: 4px;
}

/* Visibility Badges */
.badge-public, .badge-scheduled, .badge-unlisted, .badge-private {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}
.badge-public { color: var(--ok); }
.badge-scheduled { color: var(--yt-blue); }
.badge-unlisted { color: var(--mu); }
.badge-private { color: var(--mu); }
.sched-date-sub {
    font-size: 0.78rem;
    color: var(--mu);
    margin-top: 3px;
    direction: ltr;
    text-align: right;
}
.monetization-status {
    font-size: 0.78rem;
    color: var(--ok);
    margin-top: 4px;
}
.monetized-icon {
    font-weight: 800;
}

/* Table Text Formats */
.rev-text {
    color: #2ba640;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
}
.rpm-text {
    color: var(--yt-blue);
    font-weight: 600;
    font-family: 'Inter', sans-serif;
}

/* Buttons */
button, .btn {
    background: var(--pr);
    color: #fff;
    border: 0;
    border-radius: 8px;
    padding: 8px 16px;
    font: inherit;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: background 0.15s;
}
button:hover, .btn:hover { opacity: 0.92; }
button.sec, .btn.sec {
    background: transparent;
    color: var(--tx);
    border: 1px solid var(--bd);
}
button.sec:hover, .btn.sec:hover {
    background: rgba(255, 255, 255, 0.06);
}
.btn-purple {
    background: var(--yt-purple);
}
.btn-gold {
    background: #d97706;
    color: #fff;
}

/* Forms & Inputs */
input, select, textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--bd);
    border-radius: 8px;
    background: var(--bg);
    color: var(--tx);
    font: inherit;
    outline: none;
    transition: border-color 0.15s;
}
input:focus, select:focus, textarea:focus {
    border-color: var(--yt-blue);
}
label {
    display: block;
    margin: 10px 0 4px;
    color: var(--mu);
    font-size: 0.88rem;
    font-weight: 500;
}

/* Flash Messages */
.flash {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 14px;
    font-size: 0.92rem;
}
.flash.ok {
    background: rgba(43, 166, 64, 0.15);
    border: 1px solid var(--ok);
    color: #4ade80;
}
.flash.err {
    background: rgba(255, 78, 69, 0.15);
    border: 1px solid var(--bad);
    color: #f87171;
}

/* Standalone Google Search Box */
.yt-search-card {
    background: linear-gradient(135deg, rgba(121, 80, 242, 0.08), rgba(62, 166, 255, 0.05));
    border: 1px solid rgba(121, 80, 242, 0.3);
}
.yt-search-flex {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}
.yt-search-icon {
    font-size: 2rem;
    line-height: 1;
}
.yt-search-body {
    flex: 1;
}
.yt-search-body b {
    font-size: 1.05rem;
    color: var(--tx);
}
.yt-search-body p {
    margin: 4px 0 0;
    color: var(--mu);
    font-size: 0.88rem;
}

/* Modal */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.modal-box {
    background: var(--card);
    border: 1px solid var(--bd-light);
    border-radius: 14px;
    width: 100%;
    max-width: 860px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--bd);
    position: sticky;
    top: 0;
    background: var(--card);
    z-index: 10;
}
.modal-close {
    background: transparent;
    border: 0;
    font-size: 1.6rem;
    color: var(--mu);
    cursor: pointer;
    line-height: 1;
}
.modal-body {
    padding: 20px;
}

/* Outranking Titles */
.outranking-item {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--bd);
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 8px;
}
.title-text {
    font-size: 0.95rem;
    color: var(--tx);
}

/* Competitor Grid */
.competitor-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 12px;
    margin-top: 10px;
}
.competitor-card {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--bd);
    border-radius: 8px;
    overflow: hidden;
}
.competitor-thumb {
    width: 100%;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    display: block;
}
.competitor-details {
    padding: 10px;
}
.comp-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--tx);
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.4;
    margin-bottom: 6px;
}
.comp-meta {
    font-size: 0.78rem;
    color: var(--mu);
}

/* Keywords Pills */
.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.keyword-pill {
    background: rgba(62, 166, 255, 0.1);
    border: 1px solid rgba(62, 166, 255, 0.25);
    color: var(--yt-blue);
    padding: 4px 10px;
    border-radius: 99px;
    font-size: 0.82rem;
}

/* Scheduled List in Agent */
.scheduled-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.scheduled-card {
    display: flex;
    gap: 14px;
    align-items: center;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--bd);
    padding: 12px;
    border-radius: 8px;
}
.sched-thumb {
    width: 110px;
    aspect-ratio: 16 / 9;
    object-fit: cover;
    border-radius: 6px;
}
.sched-details {
    flex: 1;
}
.sched-meta {
    font-size: 0.82rem;
    color: var(--mu);
    margin-top: 4px;
}

/* Chat */
#chatlog .m {
    padding: 12px 16px;
    border-radius: 12px;
    margin: 10px 0;
    white-space: pre-wrap;
    line-height: 1.8;
}
#chatlog .m.u {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--bd);
    margin-right: 40px;
}
#chatlog .m.a {
    background: rgba(121, 80, 242, 0.1);
    border: 1px solid rgba(121, 80, 242, 0.3);
    margin-left: 40px;
}

/* Spinner */
.spinner {
    width: 38px;
    height: 38px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: var(--yt-purple);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Footer */
.studio-footer {
    border-top: 1px solid var(--bd);
    padding: 24px 20px;
    text-align: center;
    color: var(--mu);
    margin-top: 40px;
}
.footer-inner {
    max-width: 1360px;
    margin: 0 auto;
}

/* Verdict Badges */
.v {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 99px;
    font-size: 0.82rem;
    font-weight: 600;
}
.v.keep { background: rgba(43, 166, 64, 0.15); color: var(--ok); }
.v.seo { background: rgba(245, 158, 11, 0.15); color: var(--amber); }
.v.rpm { background: rgba(255, 78, 69, 0.15); color: var(--bad); }
.v.wait { background: rgba(255, 255, 255, 0.08); color: var(--mu); }
.v.sched { background: rgba(62, 166, 255, 0.18); color: var(--yt-blue); }

.row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}
code {
    direction: ltr;
    display: inline-block;
    background: rgba(255, 255, 255, 0.06);
    padding: 2px 6px;
    border-radius: 6px;
    font-family: monospace;
}
