:root {
  --primary: #007bff;
  --primary-hover: #0056b3;
  --secondary: #e94560;
  --special: #17a2b8;
  --bg-dark: #e0d8e8;
  --bg-med: #f4f0f8;
  --bg-light: #ffffff;
  --border-color: #ddd;
  --text-light: #333;
  --text-dark: #ffffff;
  --shadow-color: rgba(0, 123, 255, 0.25);
  --radius: 8px;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: #f0f2f5;
  margin: 0;
  padding: 20px;
  padding-top: 0;
  -webkit-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

.no-scroll {
  overflow: hidden;
}

.header-wrapper {
  margin-bottom: 20px;
  background-color: white;
  padding: 15px 15px 20px 15px;
  border-bottom-left-radius: 25px;
  border-bottom-right-radius: 25px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
  position: relative; 
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end; 
  padding: 0 15px;
  margin-bottom: 0; 
}

.header {
  display: flex;
  flex-direction: row;
  align-items: flex-end; 
  justify-content: space-between;
  gap: 15px;
  padding-top: 15px; 
}

.header-buttons-container {
  display: flex;
  justify-content: center;
  flex-wrap: nowrap;
  gap: 8px;
}

.settings-container {
  position: relative;
}

#current-time {
  font-size: 18px;
  font-weight: bold;
  color: #555;
  background-color: #fff;
  padding: 8px 15px;
  border-radius: 20px;
  border: 1px solid #ddd;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}

.settings-icon {
  cursor: pointer;
  width: 42px;
  height: 42px;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #fff;
  border-radius: 50%;
  border: 1px solid #ddd;
  transition: all 0.2s ease;
  position: relative; /* <--- AÑADE ESTA LÍNEA SI NO ESTÁ */
}
/* Aumentar área de clic (Aura invisible) */
.settings-icon::after {
    content: '';
    position: absolute;
    top: -15px;    /* Extiende el área 15px hacia arriba */
    bottom: -15px; /* Extiende el área 15px hacia abajo */
    left: -15px;   /* Extiende el área 15px a la izquierda */
    right: -15px;  /* Extiende el área 15px a la derecha */
    border-radius: 50%;
    z-index: 10;   /* Se asegura de estar por encima */
    cursor: pointer;
}
.settings-icon:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--shadow-color);
}

.settings-icon svg {
  width: 22px;
  height: 22px;
  stroke: #555;
  stroke-width: 2;
}

.settings-menu {
  display: none;
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  background-color: var(--bg-light);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  z-index: 1010;
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
  min-width: 180px;
}

.settings-menu-item {
  padding: 12px 15px;
  color: var(--text-light);
  cursor: pointer;
  transition: all 0.2s ease-in-out;
  font-weight: 500;
}

.settings-menu-item:hover {
  background-color: var(--primary);
  color: var(--text-dark);
}

h1 {
  margin: 0;
  color: #333;
}

#channel-select-btn, #online-search-btn, #global-search-btn {
  padding: 12px 24px;
  font-size: 16px;
  font-weight: bold;
  color: white;
  background-color: #007bff;
  border: none;
  border-radius: 25px;
  cursor: pointer;
  transition: background-color 0.2s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  vertical-align: middle;
}

#global-search-btn {
  padding: 12px 14px;
}

#channel-select-btn:hover, #online-search-btn:hover, #global-search-btn:hover { background-color: #0056b3; }

.controls-container {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 0;
}

.filter-container {
  position: relative;
  display: inline-block;
}

.filter-btn {
  padding: 8px 20px;
  font-size: 14px;
  font-weight: bold;
  color: #333;
  background-color: #fff;
  border: 1px solid var(--primary); 
  border-radius: 20px;
  cursor: pointer;
  transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease;
  min-width: 120px;
}

.filter-btn:hover {
  border-color: #007bff;
}

.filter-dropdown {
  display: none;
  position: absolute;
  background-color: #ffffff;
  min-width: 160px;
  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
  z-index: 10;
  border-radius: var(--radius);
  padding: 5px 0;
  max-height: 280px;
  overflow-y: auto;
  text-align: left;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 5px;
}

.filter-dropdown .filter-option-item {
  color: black;
  padding: 10px 15px;
  text-decoration: none;
  display: block;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap; 
}

.filter-dropdown .filter-option-item:hover {
  background-color: #f1f1f1;
}

.filter-dropdown .filter-option-item.selected {
  background-color: var(--primary);
  color: var(--text-dark);
  font-weight: bold;
}

.filter-dropdown .filter-option-item.disabled {
  background-color: #f8f9fa;
  color: #adb5bd;
  cursor: not-allowed;
  pointer-events: none;
}

.filter-container.show .filter-dropdown {
  display: block;
}

.epg-container { display: flex; flex-direction: column; }

.epg-day-grid {
  display: none;
  flex-direction: column;
  gap: 10px;
  max-height: calc(100vh - 250px);;
  overflow-y: auto;
  position: relative;
  padding-bottom: 60px;
  overscroll-behavior-y: contain;
}

.epg-day-grid.active {
  display: flex;
}

.channel-row {
  display: flex; align-items: center; background-color: #fff; padding: 10px;
  border-radius: 8px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); min-height: 100px;
  touch-action: pan-y;
  transition: transform 0.2s ease-out;
}

.channel-info {
  flex-shrink: 0; width: 114px; text-align: center; padding-right: 15px;
  border-right: 1px solid #ddd; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  cursor: pointer; 
}

.channel-info img {
  max-width: 80px;
  max-height: 50px;
  object-fit: contain;
  margin-bottom: 5px;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5));
}

.channel-info span { font-weight: bold; font-size: 14px; }

.programs-container {
  display: flex; overflow-x: auto; white-space: nowrap;
  flex-grow: 1; padding-left: 10px; scroll-behavior: smooth;
  overscroll-behavior-x: contain;
}

.program {
  flex: 0 0 auto;
  width: 200px;
  height: 80px;
  border: 1px solid #ddd;
  padding: 8px 10px;
  margin-right: 10px;
  border-radius: 5px;
  cursor: pointer;
  background-color: #f9f9ff;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  transition: background-color 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
  position: relative;
  overflow: hidden;
}

.program-past {
  opacity: 0.6;
}

.program.is-live {
  border-color: #888;
  border-width: 1.5px;
}

.program:hover {
  background-color: #e9e9e9; /* Sin !important */
}

.program-time { font-weight: bold; font-size: 14px; color: #555; }

.program-title {
  font-size: 16px;
  white-space: normal;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.2;
}

.live-progress-container {
  position: absolute; bottom: 0; left: 0; width: 100%; height: 4px;
  background-color: #e0e0e0;
}

.live-progress-bar {
  height: 100%; background-color: #ffc107; width: 0%;
  transition: width 0.5s ease-out;
}

.modal {
  display: none; position: fixed; z-index: 1000; left: 0; top: 0;
  width: 100%; height: 100%; overflow: auto; background-color: rgba(0,0,0,0.6);
  align-items: center; 
  justify-content: center;
  padding: 15px; 
  box-sizing: border-box;
}

#programModal { z-index: 1050; }

.modal-backdrop {
  display: none; position: fixed; z-index: 1200; left: 0; top: 0;
  width: 100%; height: 100%; background-color: rgba(0,0,0,0.6);
  backdrop-filter: blur(5px);
  animation: fadeIn 0.3s;
  align-items: center;
  justify-content: center;
}

#trailerModal {
  align-items: center; padding: 15px;
  z-index: 1100;
}

.modal-content {
  background-color: #f4f0f8; border-radius: 12px;
  width: 100%; max-width: 500px; max-height: 80vh;
  display: flex; flex-direction: column; box-shadow: 0 5px 15px rgba(0,0,0,0.3);
  animation: fadeIn 0.3s;
}

#globalSearchModal .modal-content { 
  max-width: 700px; 
  max-height: 90vh; 
}

#alertModal .modal-content, #confirmModal .modal-content {
  background-color: var(--bg-light);
  animation: fadeIn 0.3s;
  padding: 0;
}

#trailerModal .modal-content {
  background-color: #000; max-width: 800px; max-height: 90vh;
}

.modal-header {
  padding: 15px 20px; display: flex; justify-content: space-between;
  align-items: center; border-bottom: 1px solid #ddd; flex-shrink: 0;
}

#trailerModal .modal-header { border-bottom: 1px solid #333; }

#trailerModal .modal-header h2 { color: #fff; }

.modal-header h2 { font-size: 19px; margin: 0; line-height: 1.4; color: var(--text-light); }

.modal-header .close-btn, .modal-footer .action-btn, #online-search-body .action-btn, .modal-body .action-btn, #global-search-run-btn {
  background-color: #007bff;
  color: white; border: none; padding: 8px 20px;
  border-radius: 20px; font-weight: bold; cursor: pointer; font-size: 14px; flex-shrink: 0;
  transition: background-color 0.2s ease; text-decoration: none;
}

#confirmModal .button-group { display: flex; justify-content: flex-end; gap: 10px; margin-top: 20px; }
#confirmModal .btn { padding: 8px 20px; border-radius: 20px; font-weight: bold; cursor: pointer; border: none; }
#confirmModal .btn-secondary { background-color: #6c757d; color: white; }
.btn-danger { background-color: var(--secondary); color: white;}
.btn-primary { background-color: var(--primary); color: white;}

.modal-header .close-btn:hover, .modal-footer .action-btn:hover, #online-search-body .action-btn:hover, .modal-body .action-btn:hover, #global-search-run-btn:hover {
  background-color: #0056b3;
}

.modal-body { padding: 20px; overflow-y: auto; color: var(--text-light); }

.modal-poster { width: 100%; height: auto; border-radius: 8px; margin-bottom: 20px; display: block; }

.modal-poster-placeholder {
  width: 100%; min-height: 200px; border-radius: 8px; margin-bottom: 20px;
  background-color: #e0d8e8; display: flex; align-items: center; justify-content: center;
}

.modal-channel-logo { max-width: 200px; max-height: 100px; object-fit: contain; filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.25)); }

.plot { line-height: 1.5; color: #333; white-space: pre-wrap; }

.loader {
  text-align: center;
  padding: 50px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 15px;
  font-size: 18px;
  color: #555;
  font-weight: bold;
}

.modal-section-title {
  margin-top: 15px; margin-bottom: 10px; font-size: 18px;
  font-weight: bold; color: #333; border-bottom: 1px solid #ccc; padding-bottom: 5px;
}

.modal-section-title:first-child { margin-top: 0; }

.channel-actions-container {
  display: flex;
  gap: 10px;
  margin-bottom: 15px;
}

.channel-action-btn {
  padding: 6px 14px;
  font-size: 13px;
  color: white;
  border-radius: 15px;
  cursor: pointer;
  border: none;
  font-weight: 500;
}

#uncheck-all-channels-btn {
  background-color: var(--primary);
}

#open-channel-order-btn {
  background-color: var(--primary);
}

.video-container {
  position: relative; padding-bottom: 56.25%; height: 0;
  overflow: hidden; width: 100%; background-color: #000;
}

.video-container iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

#category-highlight-container { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 20px; }

.category-item { display: flex; align-items: center; cursor: pointer; }
.category-item input[type="checkbox"] { display: none; }
.category-item .custom-checkbox { width: 20px; height: 20px; border: 1px solid #aaa; border-radius: 4px; margin-right: 8px; display: inline-block; transition: background-color 0.2s; position: relative; }
.category-item input[type="checkbox"]:checked + .custom-checkbox::after { content: '✔'; color: #333; position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); font-size: 14px; }

#channel-list-container { display: flex; flex-direction: column; gap: 10px; }

.channel-list-item { display: flex; align-items: center; cursor: pointer; }
.channel-list-item input { margin-right: 10px; width: 18px; height: 18px; }

.modal-footer { padding: 15px 20px; border-top: 1px solid #ddd; text-align: right; flex-shrink: 0; }

.modal-warning-message {
  background-color: #fff3cd;
  color: #856404;
  border: 1px solid #ffeeba;
  border-radius: var(--radius);
  padding: 10px 15px;
  margin-bottom: 15px;
  font-size: 14px;
  text-align: center;
}

#channel-order-list-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.channel-order-item {
  display: flex;
  align-items: center;
  background-color: #fff;
  padding: 8px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  transition: transform 0.3s ease-in-out, box-shadow 0.2s;
}

.channel-order-item:hover {
  box-shadow: 0 0 0 2px var(--shadow-color);
}

.channel-order-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-grow: 1;
}

.channel-order-info img {
  width: 60px;
  height: 40px;
  object-fit: contain;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5));
}

.channel-order-info span {
  font-weight: 600;
}

.channel-order-controls {
  display: flex;
  gap: 5px;
}

.channel-order-controls button {
  background-color: #f0f2f5;
  border: 1px solid #ccc;
  color: #333;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  transition: background-color 0.2s, border-color 0.2s;
}

.channel-order-controls button:hover {
  background-color: #e2e6ea;
  border-color: #aaa;
}

.channel-order-controls button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background-color: #f0f2f5;
  border-color: #ccc;
}

.details-summary {display: flex; flex-wrap: wrap; gap: 5px 15px; padding: 10px; background-color: rgba(0,0,0,0.05); border-radius: 8px; margin-bottom: 15px; font-size: 14px;}
.summary-item { display: inline-flex; align-items: center; }
.details-synopsis { margin-bottom: 8px; line-height: 1.6; font-style: italic; padding-bottom: 15px; border-bottom: 1px solid #dcdcdc;}
.details-list > div {padding-bottom: 8px; margin-bottom: 8px; border-bottom: 1px solid #dcdcdc; font-size: 14px;}
.details-list > div:last-child { border-bottom: none; }
.details-list strong { color: #333; }
.details-list span { color: #555; }

.loader-overlay {position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: #f0f2f5; z-index: 2000; display: flex; flex-direction: column; align-items: center; justify-content: center;}
.loader-spinner {border: 8px solid #f3f3f3; border-top: 8px solid #007bff; border-radius: 50%; width: 60px; height: 60px; animation: spin 1s linear infinite;}
.loader-overlay p { margin-top: 20px; font-size: 19px; color: #555; font-weight: bold; }

#confirmModalInput {
  padding: 10px; border: 1px solid #ccc; border-radius: 20px; width: 100%;
  box-sizing: border-box; font-size: 16px; margin-top: 10px;
  padding-right: 40px !important; 
}

#confirmModalInputWrapper.hidden { 
  display: none; 
}

.btn-danger { background-color: var(--secondary); }
.btn-danger:hover { background-color: #d43d51; }

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes fadeIn { from {opacity: 0; transform: scale(0.9);} to {opacity: 1; transform: scale(1);} }

#search-form-container { display: flex; gap: 8px; align-items: center; }
#tmdb-search-input { 
  padding: 10px; border: 1px solid #ccc; border-radius: 20px; 
  padding-right: 40px !important; 
}

#tmdb-results-container .result-item { display: flex; align-items: flex-start; padding: 10px; border-bottom: 1px solid #ddd; cursor: pointer; transition: background-color 0.2s; }
#tmdb-results-container .result-item:hover { background-color: #e9e9e9; }
#tmdb-results-container .result-item:last-child { border-bottom: none; }
#tmdb-results-container .result-item img { width: 70px; height: 105px; object-fit: cover; border-radius: 4px; margin-right: 15px; background-color: #eee; flex-shrink: 0; }
#tmdb-results-container .result-info h4 { margin: 0 0 5px 0; }
#tmdb-results-container .result-info p { margin: 0; font-size: 14px; color: #555; }
#tmdb-results-container .result-info .overview { font-size: 13px; color: #333; margin-top: 8px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.4; }

#tmdb-detailed-view .poster { max-width: 200px; float: left; margin-right: 20px; margin-bottom: 10px; border-radius: 8px; }
#tmdb-detailed-view h3 { margin-top: 0; }
#tmdb-detailed-view p { margin-top: 0; margin-bottom: 10px; }
#tmdb-detailed-view .actors-list { list-style: none; padding: 0; font-size: 14px; column-count: 2; }
#tmdb-detailed-view::after { content: ""; display: table; clear: both; }

.filter-option { display: flex; align-items: center; cursor: pointer; }
#search-type-filter { display: flex; gap: 15px; justify-content: center; margin: 15px 0 5px 0; }
.filter-option input[type="checkbox"], .filter-option input[type="radio"] { display: none; }
.filter-option .custom-stick { width: 18px; height: 18px; border: 2px solid #aaa; border-radius: 50%; margin-right: 8px; display: inline-block; transition: all 0.2s; position: relative; }
.filter-option input[type="checkbox"]:checked + .custom-stick, .filter-option input[type="radio"]:checked + .custom-stick { background-color: #007bff; border-color: #007bff; }
.filter-option input[type="checkbox"]:checked + .custom-stick::after, .filter-option input[type="radio"]:checked + .custom-stick::after { content: ''; position: absolute; top: 50%; left: 50%; width: 6px; height: 6px; border-radius: 50%; background-color: white; transform: translate(-50%, -50%); }

#global-search-input { 
  padding: 10px; border: 1px solid #ccc; border-radius: 20px; font-size: 16px; 
  padding-right: 40px !important; 
}

.search-controls-wrapper { 
  display: flex; 
  gap: 20px; 
  margin-top: 8px; 
  margin-bottom: 10px; 
  padding-bottom: 20px; 
  border-bottom: 1px solid #ddd; 
}

.search-scope-group { 
  display: flex; 
  flex-direction: column; 
  flex: 1; 
  min-width: 0; 
}

.search-scope-group h4 { 
  margin: 0 0 5px 0; 
  font-size: 16px; 
  color: #333; 
}
.search-scope-group .filter-container {
  margin-top: 5px;
}
.search-scope-group h4 + .filter-option {
  margin-top: 5px;
}
.search-scope-group .filter-option + .filter-option {
  margin-top: 10px;
}
.search-scope-group .filter-container + h4 {
  margin-top: 15px;
}

#global-search-results-container { display: flex; flex-direction: column; gap: 10px; }

.global-search-result-item {
  display: flex;
  background-color: #fff;
  padding: 10px;
  border-radius: 8px;
  border: 1px solid #ddd;
  gap: 15px;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}

.global-search-result-item:hover { background-color: #f0f2f5; border-color: var(--primary); }

.gs-channel-logo { flex-shrink: 0; width: 80px; display: flex; align-items: center; justify-content: center; }
.gs-channel-logo img {
    width: 100%;
    height: 100%;        /* Forzamos a que ocupe toda la altura del contenedor */
    object-fit: cover;   /* Recorta la imagen para rellenar sin deformar */
    border-radius: 4px;
    display: block;      /* Evita espacios extra en algunos navegadores */
}

.gs-program-info { display: flex; flex-direction: column; flex-grow: 1; }
.gs-program-info h5 { margin: 0 0 5px 0; font-size: 18px; color: var(--primary); }
.gs-program-info .time-info { font-weight: bold; font-size: 14px; margin-bottom: 8px; color: #555; }
.gs-program-info .desc-info { font-size: 14px; color: #333; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.gs-program-info .gs-channel-name {
  font-size: 14px;
  font-weight: 600;
  color: #555;
  margin-bottom: 8px;
}

.action-btn:disabled {
  background-color: #9db2bf;
  cursor: not-allowed;
  opacity: 0.6;
}

.action-btn:disabled:hover {
  background-color: #9db2bf;
}

@media (max-width: 768px) {
  body {
    padding: 10px;
    padding-top: 0;
  }
  .header-wrapper {
    flex-direction: column;
    position: sticky;
    top: 0;
    z-index: 100;
    padding: 54px 10px 15px 10px; 
    margin-bottom: 10px; 
  }
  .top-bar { 
    order: 1; 
    width: 100%; 
    padding: 0 5px;
    flex-wrap: wrap; 
  }
  .header { 
    order: 2; 
    width: 100%;
    text-align: center;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
  }
.header-buttons-container {
    gap: 4px; /* Reducimos el espacio entre botones (antes era 5px o más) */
    width: 100%;
    overflow: hidden; /* Evita que el contenedor genere scroll horizontal */
  }
#channel-select-btn, #online-search-btn, #global-search-btn {
    flex: 1 1 0; /* El '0' final es CRUCIAL: permite al botón ser más pequeño que su texto */
    min-width: 0; /* Refuerzo para permitir que el botón encoja */
    padding: 10px 2px; /* Reducimos el relleno lateral drásticamente */
    font-size: 12.5px !important; /* Forzamos un tamaño fijo que sabemos que cabe, ignorando config del sistema */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; /* Si aun así no cabe, muestra "..." */
    display: flex;
    align-items: center;
    justify-content: center;
  }
#channel-select-btn svg, #online-search-btn svg, #global-search-btn svg {
    width: 16px;
    height: 16px;
    margin-right: 4px; /* Margen reducido entre icono y texto */
    flex-shrink: 0; /* Garantiza que el icono siempre se vea completo */
  }
  h1 { 
    font-size: 24px; 
    margin-bottom: 15px;
  }
  .controls-container {
    margin-top: 0;
    margin-bottom: 15px;
  }
  .channel-info { width: 67px; padding-right: 8px; }
  .channel-info span { font-size: 13px; word-break: break-word; }
  .channel-info img { max-width: 50px; max-height: 40px; }
  .programs-container { padding-left: 5px; -ms-overflow-style: none; scrollbar-width: none; }
  .program {
    width: 135px;
    height: 75px;
    padding: 6px 8px;
  }
  .program-time { font-size: 13px; }
  .program-title {
    font-size: 14px;
    line-height: 1.25;
  }
}

@media (orientation: landscape) and (max-height: 500px) {
  .header-wrapper {
    display: none;
  }
  .header {
    display: none;
  }
  .top-bar {
    width: 100%;
    padding: 0;
    margin-bottom: 0;
  }
  #current-time {
    font-size: 15px;
    padding: 5px 10px;
  }
  .settings-icon {
    width: 34px;
    height: 34px;
  }
  .settings-icon svg {
    width: 18px;
    height: 18px;
  }
  .epg-day-grid {
    max-height: calc(100vh - 10px);
  }
}

.reload-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 0;
  cursor: pointer;
  background-color: #fff;
  border: 1px solid var(--primary);
  border-radius: 50%;
  transition: all 0.2s ease;
}

.reload-btn:hover {
  border-color: var(--primary-hover);
  box-shadow: 0 0 0 3px var(--shadow-color);
}

.reload-btn svg {
  stroke: var(--primary);
}

#helpModal .modal-body h3 {
  color: var(--primary);
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 8px;
  margin-top: 20px;
  margin-bottom: 15px;
}

#helpModal .modal-body h3:first-child {
  margin-top: 0;
}

#helpModal .modal-body p {
  line-height: 1.6;
  margin-bottom: 10px;
}

#helpModal .modal-body ul {
  list-style-position: inside;
  padding-left: 10px;
  margin-bottom: 15px;
}

#helpModal .modal-body li {
  margin-bottom: 8px;
  line-height: 1.5;
}

.video-container {
  position: relative;
  padding-bottom: 56.25%; 
  height: 0;
  overflow: hidden; 
  width: 100%; 
  background-color: #000;
}
.video-container #youtube-player {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: 0;
}

#video-overlay-top,
#video-overlay-bottom {
  position: absolute;
  width: 100%;
  z-index: 1; 
  pointer-events: auto; 
}

#video-overlay-top {
  top: 0;
  height: calc(50% - 40px); 
}

#video-overlay-bottom {
  bottom: 0;
  height: calc(50% - 40px);
}

#video-play-button-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 80px;
  height: 80px;
  background-color: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2; 
  pointer-events: none; 
  transition: opacity 0.3s ease;
}

#video-play-button-overlay svg {
  width: 40px;
  height: 40px;
  fill: #ffffff;
  margin-left: 5px;
}

.video-is-playing #video-play-button-overlay {
  opacity: 0;
}

#globalSearchModal .search-scope-group .filter-dropdown {
  left: 0;
  transform: none;
  max-height: 180px; 
}

.trailer-button-container {
  text-align: center;
  margin: 20px 0 8px 0;
  padding-bottom: 20px;
  border-bottom: 1px solid #dcdcdc;
}

.switch {
  position: relative;
  display: inline-block;
  width: 60px;
  height: 34px;
}

.switch input { 
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #ccc;
  -webkit-transition: .4s;
  transition: .4s;
}

.slider:before {
  position: absolute;
  content: "";
  height: 26px;
  width: 26px;
  left: 4px;
  bottom: 4px;
  background-color: white;
  -webkit-transition: .4s;
  transition: .4s;
}

input:checked + .slider {
  background-color: var(--primary);
}

input:focus + .slider {
  box-shadow: 0 0 1px var(--primary);
}

input:checked + .slider:before {
  -webkit-transform: translateX(26px);
  -ms-transform: translateX(26px);
  transform: translateX(26px);
}

.slider.round {
  border-radius: 34px;
}

.slider.round:before {
  border-radius: 50%;
}

.hidden {
  display: none;
}

#channel-search-wrapper {
  padding: 10px 0;
  border-bottom: 1px solid #ddd;
  margin-bottom: 20px;
}

#channel-search-input {
  width: 100%;
  padding: 10px; 
  border: 1px solid #ccc;
  border-radius: 20px;
  font-size: 16px;
  padding-right: 40px !important; 
}

#channel-search-results-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 15px;
  max-height: 250px;
  overflow-y: auto;
  justify-content: flex-start; 
}

.channel-search-result-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 90px;
  height: 90px;
  background-color: #fff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.channel-search-result-item:hover, .channel-search-result-item.selected {
  border-color: var(--primary);
  background-color: #f0f2f5;
  box-shadow: 0 0 0 2px var(--shadow-color);
}

.channel-search-result-item img {
  max-width: 50px;
  max-height: 40px;
  object-fit: contain;
  margin-bottom: 5px;
  filter: drop-shadow(0 1px 3px rgba(0, 0, 0, 0.5));
}

.channel-search-result-item span {
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  color: #333;
  word-break: break-word;
  line-height: 1.2;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

#channel-filter-wrapper {
  padding: 0; 
  margin-bottom: 10px; 
}

#channel-filter-input {
  width: 100%;
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 20px;
  font-size: 16px;
  padding-right: 40px !important; 
}

.input-wrapper {
  position: relative;
  width: 100%;
  display: flex; 
  flex-grow: 1; 
  min-width: 0; 
}

.input-wrapper input[type="text"] {
  padding-right: 40px !important; 
  width: 100%; 
  box-sizing: border-box; 
  flex-grow: 1; 
  min-width: 0; 
}

.clear-input-btn {
  position: absolute;
  right: 8px; 
  top: 50%;
  transform: translateY(-50%);
  background: #aaa;
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 20px;
  line-height: 24px;
  text-align: center;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2; 
  flex-shrink: 0; 
}

.clear-input-btn:hover {
  opacity: 1;
}

.clear-input-btn.hidden {
  display: none;
}

#search-form-container .input-wrapper {
  flex-grow: 1; 
}

#tmdb-search-input,
#global-search-input {
  flex-grow: 0; 
}

.scroll-nav-btn {
  position: fixed;
  top: 50%; 
  transform: translateY(-50%);
  z-index: 900;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background-color: rgba(0, 123, 255, 0.7); 
  border: none;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 10px rgba(0,0,0,0.3);
  transition: all 0.2s ease-in-out;
}

.scroll-nav-btn.hidden {
  display: none;
}

.scroll-nav-btn:hover {
  background-color: var(--primary); 
}

#scroll-nav-prev {
  left: 15px;
}

#scroll-nav-next {
  right: 15px;
}

.scroll-nav-btn.disabled {
  background-color: rgba(108, 117, 125, 0.7); 
  color: #f0f0f0;
  cursor: not-allowed;
  box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.scroll-nav-btn.disabled:hover {
  background-color: rgba(108, 117, 125, 0.7); 
}

@media (min-width: 769px) and (min-height: 501px) {
  .epg-day-grid {
    max-height: calc(100vh - 160px); 
    padding-bottom: 5px; 
    padding-right: 15px; /* CAMBIO  Separa las tarjetas de la barra de scroll */
  }
}

#logo-container {
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}

#app-logo {
  max-height: 55px; 
  width: auto; 
  transition: max-height 0.2s ease-in-out;
}

#logo-container h1 {
  margin: 0;
  color: #333;
}

@media (max-width: 768px) {
  #logo-container {
    justify-content: center;
    margin-bottom: 15px; 
    width: 100%; 
    order: 2; 
  }
  #logo-container h1 {
    font-size: 24px;
  }
}

#day-change-indicator {
  position: fixed;
  top: 50%; 
  left: 50%;
  transform: translate(-50%, -50%); 
  z-index: 950; 
  background-color: rgba(0, 123, 255, 0.7); 
  color: white;
  padding: 12px 25px;
  border-radius: 25px;
  font-size: 18px;
  font-weight: bold;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease-out, visibility 0.3s ease-out, top 0.2s ease-out;
  pointer-events: none; 
  white-space: nowrap; 
}

#day-change-indicator.show {
  opacity: 1;
  visibility: visible;
}

.search-helper-text {
  font-size: 14px;
  color: var(--primary-hover); 
  font-style: italic;
  font-weight: 500;
  text-align: left; 
  margin-top: 9px; 
  margin-bottom: 15px; 
  padding: 0 10px;
  line-height: 1.3;
}

.fullscreen-toggle {
  display: none;
}

@media (min-width: 769px) {
  #logo-container {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 20px; 
    flex-direction: column; 
    gap: 15px; 
    align-items: center; 
  }
  .fullscreen-toggle {
    display: flex; 
    align-items: center;
    justify-content: center;
    width: 38px; 
    height: 38px; 
    padding: 0; 
    cursor: pointer;
    background-color: #fff;
    border: 1px solid var(--primary); 
    border-radius: 50%; 
    transition: all 0.2s ease;
  }
  .fullscreen-toggle svg {
    width: 18px; 
    height: 18px; 
    stroke: var(--primary); 
    stroke-width: 2.5; 
    transition: stroke 0.2s ease;
  }
  .fullscreen-toggle .fs-icon-exit {
    display: none;
  }
  .fullscreen-toggle .fs-icon-enter {
    display: block;
  }
  .fullscreen-toggle.is-fullscreen .fs-icon-enter {
    display: none;
  }
  .fullscreen-toggle.is-fullscreen .fs-icon-exit {
    display: block;
  }
  .fullscreen-toggle:hover {
    border-color: var(--primary-hover);
    box-shadow: 0 0 0 3px var(--shadow-color);
  }
}

.channel-order-item.dragging {
  opacity: 0.9;
  background-color: #e3f2fd;
  border: 2px dashed var(--primary);
  transform: scale(1.02);
  box-shadow: 0 8px 16px rgba(0,0,0,0.2);
  z-index: 1000;
  position: relative; /* Ayuda a que se visualice por encima */
}

.channel-order-item {
    /* Permitimos el scroll vertical por defecto */
    touch-action: pan-y; 
    transition: background-color 0.2s, transform 0.2s;
}

/* --- ESTILOS GUÍA FÚTBOL (TEMA CLARO ÚNICO) --- */

#football-modal-body {
    background-color: #f4f0f8; /* Gris claro app */
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
}

/* Pestañas */
.quick-guide-nav {
    display: flex;
    gap: 10px;
    padding: 10px 5px; 
    overflow-x: auto;
    white-space: nowrap;
    margin-bottom: 5px;
    scrollbar-width: none;
    flex-shrink: 0;
}
.quick-guide-nav::-webkit-scrollbar { display: none; }

.quick-guide-tab {
    background-color: #fff;
    border: 1px solid #ccc;
    padding: 8px 16px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 14px;
    color: #555;
    cursor: pointer;
    transition: all 0.2s ease;
}
.quick-guide-tab.active {
    background-color: var(--primary);
    border-color: var(--primary);
    color: white;
}

/* Cabecera Fecha */
.quick-guide-date-header {
    background-color: var(--primary);
    color: white;
    padding: 6px 15px;
    margin-top: 15px;
    margin-bottom: 10px;
    font-weight: bold;
    font-size: 14px;
    border-radius: 20px;
    text-transform: capitalize;
    text-align: center;
    align-self: center;
    display: inline-block;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Tarjeta Partido (Light Theme) */
.scraped-match-card {
    background-color: #ffffff;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    padding: 12px; 
    margin-bottom: 10px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.scraped-match-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 5px; 
}

.scraped-time {
    font-size: 14px;
    font-weight: 700;
    color: #000000;             /* Negro puro 100% */
    background-color: #e9ecef;  /* Gris muy claro */
    padding: 6px 12px;
    border-radius: 20px;        /* Pastilla completa */
    border: 1px solid #dee2e6;  /* Borde sutil */
    min-width: 70px;
    text-align: center;
    display: inline-block;
    align-self: center;
    box-shadow: none;
    line-height: 1.1;
}
/* Escudos */
.scraped-teams-box {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}
.team-shield-large {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

/* Canales */
.scraped-channels-box {
    background-color: #f9f9f9; 
    border-radius: 8px;
    padding: 8px; 
    display: flex;
    flex-wrap: wrap; 
    align-items: center;
    gap: 6px; 
    border-top: 1px solid #eee;
    margin-top: 8px;
}
.channel-pill {
    display: inline-block;
    background-color: #e3f2fd; /* Azul muy claro */
    border: 1px solid #bbdefb; 
    color: #1565c0; /* Azul oscuro */
    font-size: 12px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 12px;
    white-space: normal;
    text-align: center;
}

/* Filtro de Equipos */
.quick-guide-filter-container {
    margin-bottom: 0.5rem; 
    margin-top: 0;
    width: 100%;
    box-sizing: border-box;
    display: block;
    flex-shrink: 0;
}

.quick-guide-list {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

/* --- ESTILO BOTÓN FÚTBOL (Solo Icono) --- */
#football-guide-btn {
    width: 42px !important;
    height: 42px !important;
    padding: 0 !important;
    border-radius: 50%;
    flex: 0 0 42px !important; /* Tamaño fijo e inamovible */
    
    /* AÑADIDO: Recuperamos el color azul y quitamos bordes por defecto */
    background-color: #007bff; 
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1); /* Sutil sombra para que destaque */
}

#football-guide-btn:hover {
    background-color: #0056b3;
}

/* Ajuste Responsive para móvil */
@media (max-width: 768px) {
    #football-guide-btn {
        width: 44px !important;      /* Forzamos ancho exacto */
        height: 44px !important;     /* Forzamos alto exacto */
        padding: 0 !important;       /* Sin relleno */
        border-radius: 50%;
        flex: 0 0 44px !important;   /* ESTA ES LA CLAVE: Impide que flexbox lo estire */
    }
}
/* Estilo para la segunda línea de detalles en la búsqueda global */
.gs-extra-meta {
  display: block;       /* Fuerza el salto de línea */
  margin-top: 4px;      /* Un poco de espacio arriba */
  color: #666;          /* Color gris suave, similar al diseño actual */
  font-size: 13px;      /* Tamaño legible pero secundario */
  font-weight: 500;
}
.seasons-container {
  margin-top: 20px;
  border-top: 1px solid #eee;
  padding-top: 10px;
}

.seasons-title-header {
  font-size: 16px;
  font-weight: bold;
  color: #333;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.season-accordion-item {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  margin-bottom: 8px;
  background-color: #fff;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.05);
  transition: box-shadow 0.2s;
}

.season-header-btn {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 15px;
  background-color: #f9f9f9;
  border: none;
  border-bottom: 1px solid transparent; /* Invisible por defecto */
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  color: #444;
  transition: background-color 0.2s;
  text-align: left;
}

.season-header-btn:hover {
  background-color: #f0f2f5;
  color: var(--primary);
}

.season-accordion-item.open .season-header-btn {
  background-color: #fff;
  border-bottom: 1px solid #e0e0e0;
  color: var(--primary);
}

.season-meta-info {
  font-size: 13px;
  font-weight: normal;
  color: #888;
}

.accordion-icon {
  transition: transform 0.3s ease;
  color: #aaa;
}

.season-accordion-item.open .accordion-icon {
  transform: rotate(180deg);
  color: var(--primary);
}

/* Contenedor de episodios (oculto por defecto) */
.season-episodes-list {
  display: none;
  background-color: #fff;
  padding: 0;
  margin: 0;
  list-style: none;
}

.season-accordion-item.open .season-episodes-list {
  display: block;
  animation: slideDown 0.3s ease-out;
}

.episode-item {
  display: flex;
  align-items: flex-start; /* Alineación superior por si el título es largo */
  padding: 10px 15px;
  border-bottom: 1px solid #f0f0f0;
  font-size: 14px;
  color: #555;
  line-height: 1.4;
}

.episode-item:last-child {
  border-bottom: none;
}

.episode-number {
  font-weight: bold;
  color: var(--primary);
  min-width: 35px; /* Espacio fijo para "E01" */
  margin-right: 10px;
  flex-shrink: 0;
}

.episode-name {
  color: #333;
}

/* Pequeña animación de desplegado */
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Spinner pequeño específico para cargar episodios */
.episodes-loader {
  padding: 15px;
  text-align: center;
  color: #777;
  font-size: 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}
.mini-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #ccc;
  border-top: 2px solid var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
/* --- RESERVA DE ESPACIO PARA PÓSTER --- */
/* --- RESERVA DE ESPACIO PARA IMAGEN (FORMATO HORIZONTAL) --- */
#modal-poster-wrapper {
  width: 100%;
  /* Eliminamos alturas forzadas para permitir crecimiento vertical natural */
  height: auto; 
  min-height: 100px; 
  background-color: transparent; 
  box-shadow: none;
  
  /* Eliminamos max-height para cumplir con "todo lo que sea necesario" */
  max-height: none; 
  
  border-radius: 8px;
  margin-bottom: 0px; /* Base para horizontales */
  
  display: block; /* Cambiamos a block para asegurar que ocupe el ancho del contenedor */
  overflow: hidden;
  position: relative;
  transition: margin-bottom 0.3s ease;
}

/* Ajuste dinámico para posters verticales (Portrait) */
#modal-poster-wrapper.poster-portrait {
  margin-bottom: 0px !important;
}

#modal-poster-wrapper .modal-poster {
  /* Forzamos que la imagen ocupe el 100% del ancho del modal-body */
  width: 100% !important; 
  /* La altura se calcula automáticamente según la proporción original */
  height: auto !important; 
  /* Evitamos cualquier recorte, mostrando la imagen completa */
  object-fit: contain; 
  display: block;
  border-radius: 8px;
}
/* Cambiamos a contain en verticales para evitar el recorte de cabezas/pies */
#modal-poster-wrapper.poster-portrait .modal-poster {
  object-fit: contain;
  height: auto;
  width: auto;
  max-width: 100%;
}
/* Aseguramos que el logo del canal, si aparece, no se estire */
#modal-poster-wrapper .modal-channel-logo {
  display: block;
  margin: 0 auto;
  max-width: 50%;
  height: auto;
  padding: 20px 0;
}
