/* ========================================================================
LAYOUT
======================================================================== */
.app-main-broker { width: 100%; padding: var(--space-lg) 0; }

/* فقط در وب: فاصله باکس کلی از دو طرف 40px */
/* @media (min-width: 900px) {
.app-main-broker { padding-left: 40px; padding-right: 40px; }
} */

.state-container { text-align: center; padding: var(--space-xl) 0; display: flex; flex-direction: column; gap: var(--space-sm); align-items: center; justify-content: center; }
.spinner { width: 42px; height: 42px; border-radius: 50%; border: 4px solid var(--border-light); border-top-color: var(--color-primary); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ========================================================================
COURSE CARD & HEADER
======================================================================== */
.course-card {
background: var(--color-surface); border-radius: var(--radius-lg); padding: var(--space-lg);
border: 1px solid var(--border-light); margin-bottom: var(--space-lg); box-shadow: var(--shadow-sm);
display: grid; gap: var(--space-lg); grid-template-columns: 1fr; align-items: stretch;
}
.course-header { border-bottom: 1px solid var(--border-light); padding-bottom: var(--space-xs); display: flex; flex-direction: column; gap: var(--space-sm); align-items: center; }

@media (min-width: 900px) {
.course-card { grid-template-columns: minmax(240px, 1fr) minmax(260px, 1fr) minmax(360px, 1.3fr); }
.course-header { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; align-items: center; padding-bottom: var(--space-sm); }
}

.instructor-profile { display: flex; align-items: center; gap: var(--space-sm); width: 100%; min-width: 0; }

/* ========================================================================
AVATAR (PROFESSIONAL & REPLACEABLE)
======================================================================== */
.avatar {
width: 46px; height: 46px; border-radius: 50%;
background: linear-gradient(135deg, #e2e8f0, #f8fafc);
border: 1px solid var(--border-light);
color: var(--color-text-secondary);
display: grid; place-items: center; flex-shrink: 0;
font-weight: 800; font-size: var(--font-sm);
position: relative; overflow: hidden;
}
.avatar img {
width: 100%; height: 100%; object-fit: cover;
display: block;
}
.avatar .avatar-fallback {
position: absolute; inset: 0;
display: grid; place-items: center;
font-weight: 800; font-size: var(--font-sm);
color: #0f172a;
background: linear-gradient(135deg, #e2e8f0, #f1f5f9);
}

.instructor-text { min-width: 0; flex: 1; }
.instructor-main-title { font-size: clamp(14px, 4vw, 17px); font-weight: 800; color: var(--text-primary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.4; }
.instructor-subtitle { font-size: clamp(11px, 3.2vw, 14px); color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.4; }

/* کارت‌های سرفصل (هم‌شکل و هم‌سایز) */
.topic-cards-broker {
display: grid; gap: var(--space-sm);
grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
width: 100%;
}

/* فقط در وب: 6 باکس در یک ردیف */
@media (min-width: 900px) {
.topic-cards-broker { grid-template-columns: repeat(6, minmax(0, 1fr)); }
}

.topic-card-broker {
background: var(--color-surface-muted);
border: 1px solid var(--border-light);
border-radius: var(--radius-md);
display: flex; flex-direction: column; align-items: center; justify-content: center;
padding: 10px; height: 110px; transition: 0.2s;
cursor: pointer; position: relative;
}
.topic-card-broker:hover { background: var(--bg-surface); border-color: var(--border-light); }
.topic-card-broker.active {
border-color: var(--text-primary);
background: var(--bg-surface);
box-shadow: var(--shadow-md);
transform: translateY(-2px);
}
.topic-avatar-broker {
width: 42px; height: 42px; border-radius: 50%;overflow: hidden;
background: var(--bg-surface); border: 1px solid var(--border-light);
display: grid; place-items: center;
font-weight: 800; color: var(--text-primary); font-size: 12px;
margin-bottom: 8px;
}
.topic-card-broker.active .topic-avatar-broker { background: var(--text-primary); color: #fff; border-color: var(--text-primary); }
.topic-title {
font-size: 12px; color: var(--text-secondary);
text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
width: 100%;
}
.topic-card-broker.active .topic-title { color: var(--text-primary); font-weight: 700; }

/* ========================================================================
COLUMN 1 – COURSE META (سایت و ارتباط)
======================================================================== */
.course-meta {
background: var(--bg-surface); border-radius: var(--radius-md); padding: var(--space-md);
display: flex; flex-direction: column; gap: var(--space-sm);
height: auto; min-height: 0; align-self: start; min-width: 0;
overflow-y: auto; position: relative;

/* بردار/مرزبندی برای مشخص‌تر شدن هویت */
border: 1.5px solid var(--border-light);
}
.course-meta::-webkit-scrollbar { width: 6px; }
.course-meta::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

.meta-title {
font-size: 13px;
font-weight: 800;
color: var(--text-primary);
margin-bottom: 4px;
}
.meta-row-broker {
display: grid;
grid-template-columns: 32px 1fr;
gap: 10px; align-items: center;
padding-bottom: 8px; border-bottom: 1px dashed var(--border-light);
}
.meta-row-broker:last-child { border-bottom: none; padding-bottom: 0; }
.meta-icon {
width: 28px; height: 28px;
border-radius: 8px;
background: var(--color-surface);
border: 1px solid var(--border-light);
display: grid; place-items: center; color: var(--color-primary);
}
.meta-icon svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.meta-info { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.meta-label { font-size: var(--font-sm); color: var(--text-secondary); }
.meta-value {
font-size: var(--font-sm);
font-weight: 700;
direction: ltr; text-align: left; word-break: break-all;
}
.meta-value.meta-link { color: #2563eb; }
.meta-value.meta-copy { cursor: pointer; color: var(--text-primary); }
.meta-value.meta-copy:hover { color: var(--color-primary-hover); text-decoration: underline; }

.meta-empty {
font-size: var(--font-sm);
color: var(--text-secondary);
padding: 10px;
border: 1px dashed var(--border-light);
border-radius: var(--radius-md);
}

/* ========================================================================
COLUMN 2 – EPISODES
======================================================================== */
.syllabus-wrapper { position: relative; min-height: 260px; width: 100%; min-width: 0; display: flex; }
.syllabus-container {
display: flex; flex-direction: column; gap: 8px;
position: relative; overflow-y: auto; padding: 4px; scroll-behavior: smooth;
width: 100%;
}
.syllabus-container::-webkit-scrollbar { width: 6px; }
.syllabus-container::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }

.episode-card {
background: var(--color-surface); padding: 8px var(--space-sm); border-radius: var(--radius-md);
border: 1px solid var(--border-light); display: flex; align-items: center; gap: var(--space-sm);
cursor: pointer; transition: 0.25s ease; opacity: 0.7; height: 54px; flex-shrink: 0;
}
.episode-card:hover { opacity: 1; background: var(--color-bg); }
.episode-card.active { opacity: 1; border-color: var(--color-primary); box-shadow: var(--shadow-md); transform: scale(1.01); background: var(--color-bg); }

.ep-file-type {
width: 36px; height: 36px; border-radius: var(--radius-sm); background: var(--border-light);
display: grid; place-items: center; font-weight: bold; color: var(--color-text-secondary);
font-family: monospace; font-size: 11px; flex-shrink: 0;
}
.episode-card.active .ep-file-type { background: var(--color-primary); color: white; }
.ep-title { font-size: 13px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;}
.ep-meta { font-size: 11px; color: var(--color-text-secondary); }
.ep-text-content { min-width: 0; flex: 1; }

/* ========================================================================
COLUMN 3 – VIDEO PLAYER (ADVANCED)
======================================================================== */
.player-wrapper-broker {
background: var(--color-player-bg); border-radius: var(--radius-md); overflow: hidden; position: relative;
aspect-ratio: 16/9; display: flex; width: 100%; flex-direction: column; box-shadow: var(--shadow-md);
user-select: none; height: 100%; min-height: 0; touch-action: none;
direction: ltr; min-width: 0;

/* بردار/مرزبندی برای مشخص‌تر شدن هویت */
border: 1.5px solid var(--border-light);
}
video { width: 100%; height: 100%; object-fit: contain; z-index: 1; transition: opacity 0.3s; cursor: pointer; }

.player-wrapper-broker:fullscreen, .player-wrapper-broker:-webkit-full-screen { aspect-ratio: unset; width: 100vw; height: 100vh; border-radius: 0; }
.player-wrapper-broker:fullscreen video, .player-wrapper-broker:-webkit-full-screen video { object-fit: contain; }

.brightness-overlay { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(0,0,0,0); pointer-events: none; z-index: 2; transition: background 0.1s; }

.gesture-indicator {
position: absolute; top: 20px; left: 50%; transform: translateX(-50%);
background: rgba(0,0,0,0.7); color: white; padding: 8px 16px; border-radius: 30px; font-size: 13px;
font-weight: bold; opacity: 0; transition: opacity 0.2s; z-index: 20; pointer-events: none; backdrop-filter: blur(4px);
display: flex; align-items: center; gap: 8px;
}
.gesture-indicator svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.gesture-indicator.show { opacity: 1; }

/* آیکون های راهنمای کناری */
.side-hint-icon {
position: absolute; top: 50%; transform: translateY(-50%);
background: none; color: rgba(255,255,255,0.7);
width: 32px; height: 32px; display: none;
place-items: center; z-index: 15; pointer-events: none;
opacity: 1; transition: opacity 0.3s ease;
}
.side-hint-icon svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.side-hint-icon.left-hint { left: 1rem; }
.side-hint-icon.right-hint { right: 1rem; }

@media (pointer: coarse) {
.side-hint-icon { display: grid; }
.player-wrapper-broker.playing.idle .side-hint-icon { opacity: 0; }
.player-wrapper-broker.paused .side-hint-icon { opacity: 0; }
}

.audio-equalizer {
position: absolute; top: 0; left: 0; right: 0; bottom: 0;
background: var(--color-player-bg); display: none; align-items: center; justify-content: center;
gap: 6px; z-index: 3; pointer-events: none;
}
.player-wrapper-broker.is-audio .audio-equalizer { display: flex; }
.player-wrapper-broker.is-audio video { opacity: 0; }
.eq-bar {
width: 8px; height: 15px; background: var(--color-success); border-radius: 4px;
animation: eqAnim 1s ease-in-out infinite;
}
.eq-bar:nth-child(2) { animation-delay: 0.2s; }
.eq-bar:nth-child(3) { animation-delay: 0.4s; }
.eq-bar:nth-child(4) { animation-delay: 0.1s; }
.eq-bar:nth-child(5) { animation-delay: 0.3s; }
@keyframes eqAnim { 0%, 100% { height: 15px; } 50% { height: 60px; } }
.player-wrapper-broker.paused .eq-bar { animation-play-state: paused; }

.center-play {
position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
width: 64px; height: 64px; background: rgba(0,0,0,0.6); border-radius: 50%;
display: grid; place-items: center; color: white; cursor: pointer;
backdrop-filter: blur(4px); border: 1px solid rgba(255,255,255,0.2);
transition: all 0.3s ease; z-index: 10;
}
.player-wrapper-broker.playing .center-play { opacity: 0; transform: translate(-50%, -50%) scale(1.3); pointer-events: none;}
.center-play svg { width: 32px; height: 32px; fill: white; stroke: none; margin-left: 4px; }

.custom-controls {
position: absolute; bottom: 0; left: 0; right: 0; padding: 2rem var(--space-md) var(--space-md);
background: linear-gradient(0deg, rgba(0,0,0,0.85) 0%, transparent 100%);
opacity: 1; transition: opacity 0.3s ease; z-index: 10;
}
.player-wrapper-broker.playing.idle .custom-controls { opacity: 0; pointer-events: none;}

.progress-container {
width: 100%; height: 6px; background: rgba(255,255,255,0.3);
border-radius: 5px; margin-bottom: var(--space-sm); cursor: pointer;
position: relative; transition: height 0.2s;
}
.progress-container:hover { height: 8px; }
.progress-filled {
width: 0%; height: 100%; background: var(--color-success); border-radius: 5px; pointer-events: none; position: relative;
}
.progress-filled::after {
content: ''; position: absolute; right: -6px; top: 50%; transform: translateY(-50%);
width: 12px; height: 12px; background: white; border-radius: 50%; opacity: 0; transition: 0.2s;
}
.progress-container:hover .progress-filled::after { opacity: 1; }

.controls-row { display: flex; justify-content: space-between; align-items: center; color: white; }
.controls-group { display: flex; align-items: center; gap: 0.75rem; }

.ctrl-btn { padding: 4px; color: white; display: flex; align-items: center; justify-content: center; transition: 0.2s; }
.ctrl-btn:hover { color: var(--color-success); }
.ctrl-btn svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.ctrl-btn.filled svg { fill: currentColor; stroke: none; }

.time-display { font-size: var(--font-xs); font-variant-numeric: tabular-nums; direction: ltr; margin-left: 0.5rem; }

.volume-group { display: flex; align-items: center; gap: 0.5rem; }
.vol-slider { width: 0; opacity: 0; transition: all 0.3s; cursor: pointer; accent-color: var(--color-success); height: 4px;}
.volume-group:hover .vol-slider { width: 60px; opacity: 1; }

.speed-btn { font-size: var(--font-xs); font-weight: 700; background: rgba(255,255,255,0.2); padding: 2px 6px; border-radius: var(--radius-sm); }

/* ========================================================================
MOBILE RESPONSIVE TWEAKS 
======================================================================== */
@media (max-width: 900px) { .syllabus-wrapper { height: 248px; } }
@media (max-width: 768px) {
.app-main-broker { padding: var(--space-xs); }
.course-card { padding: var(--space-sm); gap: var(--space-md); }
.topic-cards-broker { grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); }
.topic-card-broker { height: 100px; }
}