* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: 'Inter', system-ui, sans-serif; background: #0b1120; color: #e2e8f0; min-height: 100vh; }

/* Layout */
.app-layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 260px; background: #111827; padding: 1.5rem; position: fixed; top: 0; left: 0; bottom: 0;
  z-index: 20; transform: translateX(-100%); transition: transform 0.3s; border-right: 1px solid #1e293b;
}
#sidebar-toggle:checked ~ .app-layout .sidebar { transform: translateX(0); }
.sidebar-close { display: block; text-align: right; font-size: 1.5rem; cursor: pointer; margin-bottom: 1rem; }
.sidebar h3 { color: #94a3b8; margin-bottom: 1rem; }
.sidebar ul { list-style: none; }
.sidebar li { padding: 0.6rem 1rem; border-radius: 8px; margin-bottom: 0.2rem; cursor: pointer; color: #cbd5e1; transition: background 0.2s; }
.sidebar li.active, .sidebar li:hover { background: #1e293b; color: white; }

.main-content { flex: 1; padding: 1.5rem; width: 100%; transition: margin-left 0.3s; }
@media (min-width: 1024px) {
  .sidebar { transform: translateX(0); position: relative; width: 260px; }
  .sidebar-close { display: none; }
  .main-content { width: calc(100% - 260px); }
}

/* Topbar */
.topbar { display: flex; align-items: center; gap: 1rem; margin-bottom: 2rem; flex-wrap: wrap; }
.menu-btn { font-size: 1.5rem; cursor: pointer; }
@media (min-width: 1024px) { .menu-btn { display: none; } }
.search-box { flex: 1; min-width: 200px; padding: 0.6rem 1rem; border-radius: 8px; border: 1px solid #334155; background: #1e293b; color: white; font-size: 1rem; }

/* EPG */
.epg-section h2, .channels-section h2 { margin-bottom: 0.8rem; color: #94a3b8; font-size: 1.2rem; }
#epg-container { display: flex; gap: 1rem; overflow-x: auto; padding: 0.5rem 0 1rem; }
.epg-item { min-width: 200px; background: #1e293b; padding: 0.8rem; border-radius: 8px; font-size: 0.9rem; }

/* Grid */
.channels-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.channel-card { background: #1e293b; border-radius: 12px; overflow: hidden; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; animation: fadeIn 0.3s; }
.channel-card:hover { transform: translateY(-3px); box-shadow: 0 8px 16px rgba(0,0,0,0.4); }
.card-img-wrapper { background: #000; height: 100px; display: flex; align-items: center; justify-content: center; padding: 0.5rem; }
.card-img-wrapper img { max-width: 100%; max-height: 100%; object-fit: contain; }
.channel-card p { padding: 0.6rem; font-size: 0.85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: center; }

/* Advanced Player */
.player-overlay { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; animation: fadeIn 0.2s; }
.player-overlay.hidden { display: none; }
.player-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.8); backdrop-filter: blur(8px); }
.player-container { position: relative; width: 95%; max-width: 1100px; background: #000; border-radius: 16px; overflow: hidden; box-shadow: 0 30px 60px rgba(0,0,0,0.8); display: flex; flex-direction: column; max-height: 90vh; }
.player-loading, .player-error { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; background: rgba(0,0,0,0.7); z-index: 5; color: white; }
.player-loading.hidden, .player-error.hidden { display: none; }
.spinner { width: 50px; height: 50px; border: 4px solid rgba(255,255,255,0.2); border-top-color: #6366f1; border-radius: 50%; animation: spin 0.8s linear infinite; margin-bottom: 1rem; }
@keyframes spin { to { transform: rotate(360deg); } }
.player-info { display: flex; align-items: center; gap: 0.75rem; padding: 0.6rem 1rem; background: linear-gradient(to bottom, rgba(0,0,0,0.8), transparent); z-index: 3; }
.player-logo { width: 36px; height: 36px; object-fit: contain; border-radius: 4px; background: #1e293b; }
.player-meta { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.player-meta span:first-child { font-weight: 600; }
.epg-now { font-size: 0.8rem; color: #94a3b8; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player-close-btn { background: rgba(255,255,255,0.1); border: none; color: white; font-size: 1.2rem; width: 32px; height: 32px; border-radius: 50%; cursor: pointer; }
.player-close-btn:hover { background: rgba(255,255,255,0.2); }
#video-player { width: 100%; max-height: 70vh; background: black; }
.player-controls { display: flex; align-items: center; gap: 0.8rem; padding: 0.5rem 1rem; background: #1e293b; flex-wrap: wrap; }
.player-controls button { background: none; border: none; color: white; font-size: 1.2rem; cursor: pointer; padding: 0.3rem 0.5rem; border-radius: 4px; }
.player-controls button:hover { background: #334155; }
.volume-wrapper { display: flex; align-items: center; gap: 0.3rem; }
#volume-slider { width: 80px; }
.quality-selector { background: #0f172a; color: white; border: 1px solid #334155; padding: 0.3rem 0.5rem; border-radius: 4px; }

/* Admin */
.admin-container { max-width: 700px; margin: 2rem auto; padding: 0 1rem; }
.panel { background: #1e293b; border-radius: 12px; padding: 1.5rem; margin-bottom: 2rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; margin-bottom: 0.3rem; color: #94a3b8; }
.form-group input, .form-group textarea { width: 100%; padding: 0.6rem; border-radius: 6px; border: 1px solid #334155; background: #0f172a; color: white; font-size: 1rem; }
button { padding: 0.7rem 1.2rem; background: #6366f1; color: white; border: none; border-radius: 6px; font-size: 1rem; cursor: pointer; transition: background 0.2s; }
button:hover { background: #4f46e5; }
.back-link { display: inline-block; margin-top: 1rem; color: #94a3b8; text-decoration: underline; }

@media (max-width: 640px) {
  .channels-grid { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); }
  .player-container { width: 100%; border-radius: 0; }
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

/* Loading progress bar */
.progress-container {
  width: 200px;
  height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  margin: 0.8rem auto 0.3rem;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #6366f1, #818cf8);
  border-radius: 2px;
  transition: width 0.2s linear;
}
#progress-text {
  font-size: 0.8rem;
  color: #94a3b8;
}

/* Loading progress bar */
.progress-container {
  width: 200px;
  height: 4px;
  background: rgba(255,255,255,0.15);
  border-radius: 2px;
  margin: 0.8rem auto 0.3rem;
  overflow: hidden;
}
.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #6366f1, #818cf8);
  border-radius: 2px;
  transition: width 0.2s linear;
}
#progress-text {
  font-size: 0.8rem;
  color: #94a3b8;
}

/* Channel table */
.channel-table { width:100%; border-collapse:collapse; margin:1rem 0; }
.channel-table th, .channel-table td { padding:0.5rem; text-align:left; border-bottom:1px solid #334155; }
.channel-table th { background:#1e293b; color:#94a3b8; }
.stream-url-cell { max-width:200px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.modal { position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.7); display:flex; align-items:center; justify-content:center; z-index:100; }
.modal.hidden { display:none; }
.modal-content { background:#1e293b; padding:1.5rem; border-radius:12px; width:90%; max-width:500px; position:relative; }
.modal .close { position:absolute; top:0.5rem; right:0.8rem; font-size:1.5rem; cursor:pointer; color:white; }

/* Admin Table */
.channel-table { width:100%; border-collapse:collapse; margin:1rem 0; }
.channel-table th, .channel-table td { padding:0.5rem; text-align:left; border-bottom:1px solid #334155; }
.channel-table th { background:#1e293b; color:#94a3b8; }
.stream-url-cell { max-width:200px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }

/* Modal */
.modal { position:fixed; top:0; left:0; width:100%; height:100%; background:rgba(0,0,0,0.7); display:flex; align-items:center; justify-content:center; z-index:100; }
.modal.hidden { display:none; }
.modal-content { background:#1e293b; padding:1.5rem; border-radius:12px; width:90%; max-width:500px; position:relative; }
.modal .close { position:absolute; top:0.5rem; right:0.8rem; font-size:1.5rem; cursor:pointer; color:white; }

/* Mini Player */
.mini-player {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 320px;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 25px rgba(0,0,0,0.7);
  z-index: 200;
  resize: both;
  min-width: 200px;
  min-height: 150px;
}
.mini-player.hidden { display: none; }
.mini-player-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0.5rem;
  background: #1e293b;
  cursor: move;
  color: white;
  font-size: 0.8rem;
}
.mini-player-actions button {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 1rem;
  margin-left: 0.3rem;
}
#mini-video {
  width: 100%;
  display: block;
  background: black;
}

.mini-player {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 320px;
  background: #000;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 10px 25px rgba(0,0,0,0.7);
  z-index: 200;
  resize: both;
  min-width: 200px;
  min-height: 150px;
}
.mini-player.hidden { display: none; }
.mini-player-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.3rem 0.5rem;
  background: #1e293b;
  cursor: move;
  color: white;
  font-size: 0.8rem;
}
.mini-player-actions button {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  font-size: 1rem;
  margin-left: 0.3rem;
}
#mini-video {
  width: 100%;
  display: block;
  background: black;
}
