/* ===== MISIÓN SCHINDLER — Styles ===== */

/* --- Font Face --- */
@font-face {
    font-family: 'Frutiger';
    src: url('../fonts/Frutiger Light.ttf') format('truetype');
    font-weight: 300;
    font-style: normal;
}

@font-face {
    font-family: 'Frutiger';
    src: url('../fonts/Frutiger.woff2') format('woff2'),
         url('../fonts/Frutiger.woff') format('woff'),
         url('../fonts/Frutiger.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'Frutiger';
    src: url('../fonts/Frutiger_bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
}

/* --- Variables --- */
:root {
  --red: #DC0000;
  --red-dark: #B80000;
  --red-light: #FF2222;
  --grey-dark: #70726F;
  --grey: #BFC1BD;
  --grey-light: #F0F0F0;
  --white: #FFFFFF;
  --black: #1A1A1A;
  --shadow: 0 2px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 4px 24px rgba(0,0,0,0.15);
  --radius: 12px;
  --radius_mobile: 30px;
  --radius-sm: 8px;
  --transition: all 0.2s ease;
  --font: 'Frutiger';
}

/* --- Reset & Base --- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  /* padding: 0; */
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
  color-scheme: light;
}

body {
  font-family: var(--font);
  background: var(--grey-light);
  color: var(--black);
  min-height: 100vh;
  /*line-height: 1.5;*/
  -webkit-font-smoothing: antialiased;
}

/* --- Language Selector --- */
#lang-selector {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 1000;
  display: flex;
  gap: 4px;
  background: var(--white);
  border-radius: 20px;
  padding: 3px;
  box-shadow: var(--shadow);
  transition: top 0.3s ease;
}

/* Move lang selector below room header when in room view */
body.in-room #lang-selector {
  top: 56px;
}

/* Move lang selector below admin header */
.admin-page #lang-selector {
  top: 70px;
}

.lang-btn {
  border: none;
  background: transparent;
  color: var(--grey-dark);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 16px;
  cursor: pointer;
  transition: var(--transition);
}

.lang-btn.active {
  background: var(--red);
  color: var(--white);
}

.lang-btn:hover:not(.active) {
  background: var(--grey-light);
}

/* --- Views --- */
.view {
  display: none;
  min-height: 100vh;
}

.view.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.container {
  /* width: 100%; */
  max-width: 500px;
  padding: 24px 20px;
  text-align: center;
}

/* --- Images --- */
#backgroundEdificios_desktop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  object-fit: cover;
  z-index: -1;
}

#backgroundEdificios_mobile {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100vh;
  object-fit: cover;
  z-index: -1;
}

#imgLogo_desktop {
  position: absolute;
  bottom: 20px;
  right: 20px;
  width: 120px;
  opacity: 0.8;
}

#imgLogo_mobile {
  display: none;
  position:relative;
  width: 140px;
  opacity: 0.8;
}

#imgLogo_mobile2 {
  display: none;
  position: absolute; 
  bottom: 20px;
  right: 20px;
  width: 75px;
  opacity: 0.8;
}

#logo-card {
  width: 20%;
  margin-bottom: 70px;
}

/* --- Logo & Title --- */
.logo-area {
  margin-bottom: 40px;
}

.app-title {
  font-size: 3.9rem;
  font-family: var(--font);
  color: var(--red);
}

.schindler-line {
  width: 60px;
  height: 4px;
  background: var(--red);
  border-radius: 2px;
  margin: 0 auto;
}

/* --- Form Elements --- */
.form-group {
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.input-main {
  width: 100%;
  padding: 7px 18px;
  margin-bottom: 20px;
  font-size: 1.35rem;
  font-weight: normal;
  font-family: var(--font);
  text-align: center;
  border: 2px solid var(--grey);
  border-radius: var(--radius);
  outline: none;
  transition: var(--transition);
  background: var(--white);
  color: var(--black);
}

.input-main:focus {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(220, 0, 0, 0.1);
}

.input-main::placeholder {
  color: var(--grey-dark);
  opacity: 0.7;
}

.input-code {
  text-align: center;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: 4px;
  text-transform: uppercase;
}

/* --- Buttons --- */
.btn-primary {
  width: 100%;
  padding: 7px 24px;
  font-size: 1.35rem;
  font-weight: normal;
  font-family: var(--font);
  color: var(--white);
  background: var(--red);
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
  /* text-transform: uppercase; */
  letter-spacing: 1px;
}

.btn-primary:hover {
  background: var(--red-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  width: 100%;
  padding: 5px 24px;
  font-size: 1.35rem;
  font-weight: 700;
  font-family: var(--font);
  color: var(--grey-dark);
  background: var(--white);
  border: 2px solid var(--grey);
  border-radius: var(--radius);
  cursor: pointer;
  transition: var(--transition);
}

.btn-secondary:hover {
  border-color: var(--grey-dark);
  transform: translateY(-1px);
}

.btn-large {
  padding: 7px 24px;
}

.btn-small {
  padding: 8px 16px;
  font-size: 0.85rem;
}

.btn-tiny {
  padding: 4px 10px;
  font-size: 0.75rem;
  border: 1px solid var(--grey);
  background: var(--white);
  border-radius: 6px;
  cursor: pointer;
  transition: var(--transition);
  font-family: var(--font);
}

.btn-tiny:hover {
  background: var(--grey-light);
}

.btn-danger {
  color: var(--red);
  border-color: var(--red);
}

.btn-danger:hover {
  background: var(--red);
  color: var(--white);
}

.link-btn {
  background: none;
  border: none;
  color: var(--grey-dark);
  font-size: 0.85rem;
  font-weight: normal;
  cursor: pointer;
  text-decoration: none;
  padding: 8px;
  font-family: var(--font);
  opacity: 0.7;
  transition: var(--transition);
}

.link-btn:hover {
  opacity: 1;
  color: var(--red);
}

/* --- Lobby --- */
.container_welcomeText {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  margin-bottom: 30px;
}

.welcome-text {
  font-size: 1.2rem;
  color: var(--grey-dark);
}

.welcome-text2 {
  margin-bottom: 1px;
}

.lobby-name {
  font-size: 1.2rem;
  color: var(--grey-dark);
  margin-bottom: 30px;
}

.lobby-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

/* --- Room View --- */
.room-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: var(--white);
  box-shadow: var(--shadow);
  z-index: 100;
}

.room-code-display {
  font-size: 0.9rem;
  color: var(--grey-dark);
}

.room-code-display strong {
  font-size: 1.1rem;
  color: var(--red);
  letter-spacing: 2px;
}

.room-team-display {
  font-size: 0.85rem;
  color: var(--grey-dark);
}

#view-room .container {
  padding-top: 20px;
}

#view-room {
  justify-content: flex-start;
  padding-top: 160px;
}

.card-input-area {
  margin-bottom: 20px;
}

/* --- Messages --- */
.error-msg {
  color: var(--red);
  font-size: 0.9rem;
  margin-top: 8px;
  padding: 8px;
}

.room-message {
  padding: 16px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  margin-bottom: 24px;
  animation: fadeIn 0.3s ease;
}

.msg-success {
  background: #E8F5E9;
  color: #2E7D32;
  border: 1px solid #C8E6C9;
}

.msg-warning {
  background: #FFF8E1;
  color: #F57F17;
  border: 1px solid #FFECB3;
}

.msg-error {
  background: #FFEBEE;
  color: #C62828;
  border: 1px solid #FFCDD2;
}

/* --- Score Display --- */
.score-display {
  background: var(--white);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.score-display h3 {
  font-size: 1rem;
  color: var(--grey-dark);
  margin-bottom: 16px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.score-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.score-item {
  display: flex;
  flex-direction: column;
  padding: 10px;
  background: var(--grey-light);
  border-radius: var(--radius-sm);
}

.score-label {
  font-size: 0.75rem;
  color: var(--grey-dark);
  margin-bottom: 4px;
}

.score-value {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--red);
}

.score-total {
  grid-column: 1 / -1;
  background: var(--red);
  color: var(--white);
}

.score-total .score-label {
  color: rgba(255,255,255,0.8);
}

.score-total .score-value {
  color: var(--white);
  font-size: 1.8rem;
}

/* --- Hidden --- */
.hidden {
  display: none !important;
}

/* ===== RANKING PAGE ===== */
.ranking-page {
  background: #ffffff;
  color: var(--grey-dark);
  font-family: var(--font), Arial, sans-serif;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.ranking-bg {
  position: fixed;
  inset: 0;
  background: url('/img/Elementos_Schindler_Bg_Ranking-25.png') no-repeat center center;
  background-size: cover;
  z-index: 0;
  pointer-events: none;
}

.ranking-page #lang-selector {
  background: rgba(255, 255, 255, 0.6);
  z-index: 10;
}

.ranking-page .lang-btn {
  color: var(--grey-dark);
}

.ranking-page .lang-btn.active {
  background: var(--red);
  color: var(--white);
}

.ranking-container {
    position: relative;
    z-index: 1;
    /* max-width: 1400px; */
    /* margin: 0 auto; */
    padding: 10px 50px;
    align-items: center;
}

.ranking-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 20px;
  margin-bottom: 10px;
  position: relative;
}

.ranking-titles {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.ranking-logo {
  height: 90px;
  width: auto;
  flex-shrink: 0;
}

.ranking-title {
  font-family: var(--font), Arial, sans-serif;
  font-size: 3.2rem;
  font-weight: 700;
  color: var(--red);
  line-height: 0.95;
  margin: 0;
  letter-spacing: -1px;
}

.ranking-subtitle {
  font-family: var(--font), Arial, sans-serif;
  font-size: 1.65rem;
  font-weight: 400;
  color: var(--black);
  margin: 6px 0 0 0;
  line-height: 1.1;
}

.live-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 16px;
  background: rgba(220, 0, 0, 0.1);
  border: 1px solid var(--red);
  border-radius: 20px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--red);
}

.live-dot {
  width: 8px;
  height: 8px;
  background: var(--red);
  border-radius: 50%;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-5px); }
  to { opacity: 1; transform: translateY(0); }
}

.ranking-table-wrapper {
  position: relative;
  z-index: 1;
  overflow-x: auto;
}

.ranking-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 10px;
  font-family: var(--font), Arial, sans-serif;
  font-size: 1.65rem;
  font-weight: 700;
  background: transparent;
}

.ranking-table thead th {
  padding: 12px 18px;
  text-align: center;
  font-weight: 400;
  font-size: 1.25rem;
  color: var(--white);
  background: var(--red);
  border: none;
  letter-spacing: 0.2px;
}

.ranking-table thead th.th-team {
  text-align: left;
  padding-left: 14px;
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
}

.ranking-table thead th:last-child {
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
}

.ranking-table tbody tr {
  background: transparent;
}

.ranking-table tbody td {
  padding: 0 18px;
  color: var(--black);
  text-align: center;
  font-size: 1.35rem;
  background: #ffffffbf;
  border: none;
  vertical-align: middle;
}

.ranking-table tbody td.pos-cell {
  background: transparent;
  box-shadow: none;
  width: 70px;
  text-align: center;
  padding: 0 6px;
}

.ranking-table tbody td.icon-cell {
  background: transparent;
  box-shadow: none;
  width: 90px;
  padding: 0 8px;
  text-align: center;
}

.ranking-table tbody td.team-cell {
  text-align: left;
  padding-left: 24px;
  font-family: var(--font), Arial, sans-serif;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--black) !important;
  border-top-left-radius: 4px;
  border-bottom-left-radius: 4px;
}

.ranking-table tbody td:last-child {
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
}

.pos-number {
  display: inline-block;
  font-family: var(--font), Arial, sans-serif;
  font-weight: 700;
  font-size: 2.6rem;
  color: var(--red);
  line-height: 1;
}

.rank-icon {
  display: block;
  width: 70px;
  height: 70px;
  margin: 0 auto;
  object-fit: contain;
}

.podium-1 .pos-number,
.podium-2 .pos-number,
.podium-3 .pos-number {
  color: var(--red);
}

.penalty-cell {
  color: var(--red) !important;
  font-weight: 700;
  /* When total is hidden, penalty is last — round right corners */
  border-top-right-radius: 4px;
  border-bottom-right-radius: 4px;
}

/* When total column is visible, remove right rounding from penalty */
.ranking-table.total-visible td.col-penalty {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.col-total {
  font-weight: 700;
  color: var(--grey-dark);
}

.btn-toggle-total {
  margin-left: auto;
  border-color: var(--red);
  color: var(--red);
}

.btn-toggle-total.active {
  background: var(--red);
  color: var(--white);
}

.ranking-empty {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 60px 20px;
  color: var(--grey-dark);
  font-size: 1.1rem;
  background: rgba(255,255,255,0.7);
  border-radius: 8px;
}

/* ===== ADMIN PAGE ===== */
.admin-page {
  background: var(--grey-light);
}

.admin-page .view.active {
  min-height: 100vh;
}

.admin-page #admin-login.active {
  display: flex;
  align-items: center;
  justify-content: center;
}

.admin-page #admin-dashboard.active {
  display: block;
}

.admin-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 24px;
  background: var(--white);
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

#btn-admin-logout {
  width: auto;
  flex-shrink: 0;
  white-space: nowrap;
}

.admin-header h1 {
  font-size: 1.3rem;
  color: var(--red);
}

.admin-content {
  max-width: 1000px;
  margin: 0 auto;
  padding: 20px;
}

.admin-filters {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.admin-view-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 12px;
  border-bottom: 2px solid var(--grey);
  padding-bottom: 0;
}

.view-tab {
  padding: 8px 20px;
  font-size: 0.95rem;
  font-family: var(--font);
  font-weight: 700;
  border: none;
  background: transparent;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  cursor: pointer;
  color: var(--grey-dark);
  transition: var(--transition);
}

.view-tab.active {
  color: var(--red);
  border-bottom-color: var(--red);
}

/* Score success toast */
.score-toast {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.45);
  animation: toastFadeIn 0.25s ease;
}
.score-toast::before {
  display: none;
}
.score-toast.hidden { display: none; }
.score-toast-card {
  position: relative;
  width: 560px;
  max-width: 90vw;
}
.score-toast-card img {
  width: 100%;
  display: block;
}
.score-toast-text {
  position: absolute;
  top: 50%;
  left: 10%;
  transform: translateY(-50%);
  color: #fff;
  font-family: var(--font);
  font-weight: 700;
  font-size: 1.65rem;
  line-height: 1.2;
  width: 54%;
  text-align: left;
  pointer-events: none;
}
@media (max-width: 480px) {
  .score-toast-text { font-size: 1.1rem; }
}
@keyframes toastFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.admin-teams {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-teams-toolbar {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 8px;
}

.admin-team-card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.btn-delete-all {
  border-color: #c00 !important;
  color: #c00 !important;
}

.btn-delete-all:hover {
  background: #c00 !important;
  color: white !important;
}

.filter-btn {
  padding: 8px 16px;
  font-size: 0.85rem;
  font-family: var(--font);
  border: 1px solid var(--grey);
  background: var(--white);
  border-radius: 20px;
  cursor: pointer;
  transition: var(--transition);
}

.filter-btn.active {
  background: var(--red);
  color: var(--white);
  border-color: var(--red);
}

.admin-rooms {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.admin-room {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.admin-room-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: var(--grey-light);
  flex-wrap: wrap;
}

.admin-room-header strong {
  color: var(--red);
  letter-spacing: 2px;
}

.admin-room-date {
  font-size: 0.8rem;
  color: var(--grey-dark);
  margin-left: auto;
}

.admin-room.room-closed {
  opacity: 0.6;
}

.admin-room-teams {
  padding: 14px 18px;
}

.admin-team {
  padding: 12px 0;
  border-bottom: 1px solid var(--grey-light);
}

.admin-team:last-child {
  border-bottom: none;
}

.admin-team-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
  flex-wrap: wrap;
}

.admin-team-name {
  font-weight: 700;
  font-size: 1rem;
}

.admin-team-total {
  font-size: 0.9rem;
  color: var(--red);
}

.admin-scores {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.admin-score-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  background: var(--grey-light);
  padding: 4px 10px;
  border-radius: 6px;
}

.admin-empty {
  text-align: center;
  padding: 40px;
  color: var(--grey-dark);
}

/* --- Modal --- */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal.hidden {
  display: none !important;
}

.modal-content {
  background: var(--white);
  border-radius: var(--radius);
  padding: 24px;
  width: 90%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.modal-content h3 {
  margin-bottom: 16px;
  color: var(--red);
}

.modal-body {
  margin-bottom: 20px;
}

.modal-body label {
  display: block;
  font-size: 0.9rem;
  color: var(--grey-dark);
  margin-bottom: 8px;
}

.modal-actions {
  display: flex;
  gap: 8px;
}

.modal-actions .btn-primary,
.modal-actions .btn-secondary {
  flex: 1;
}

/* ===== RESPONSIVE ===== */

/* Mobile (default) */
@media (max-width: 480px) {
  .container { max-width: 500px; margin-bottom: 50px;}
  .app-title { font-size: 2rem; }
  .ranking-header h1, .ranking-title { font-size: 2.2rem; }
  .ranking-subtitle { font-size: 1rem; }
  .ranking-logo { height: 50px; }
  .ranking-container { padding: 20px 14px; }
  .ranking-table { font-size: 0.78rem; }
  .ranking-table thead th { padding: 8px 6px; font-size: 0.7rem; }
  .ranking-table tbody td { padding: 8px 6px; font-size: 0.85rem; }
  .ranking-table tbody td.pos-cell { width: 36px; padding: 0 2px; }
  .ranking-table tbody td.icon-cell { width: 48px; padding: 2px; }
  .ranking-table tbody td.team-cell { padding-left: 10px; }
  .pos-number { font-size: 1.4rem; }
  .rank-icon { width: 40px; max-height: 46px; }
  .admin-room-header { flex-direction: column; align-items: flex-start; gap: 8px; }
  .admin-room-date { margin-left: 0; }
  .admin-team-header { flex-direction: column; align-items: flex-start; }
  .logo-area { margin-bottom: 30px; }
  .lobby-buttons { width: calc(100% + 48px); margin-left: -24px; }
  .btn-primary {width: 100%; padding: 15px 15px; font-size: 1.25rem;}
  .btn-secondary { width: 100%; padding: 15px 15px; font-size: 1.25rem; } 
  .input-main { width: calc(100% + 48px); padding: 15px 15px; font-size: 1.25rem;}
  .form-group { display: flex; flex-direction: column; align-items: center; }
  .form-group .btn-primary { width: calc(100% + 48px); }
  #btn-submit-code { width: 100%; margin-left: 0; }
  #card-code-input { width: 100%; margin-left: 0; }
  .container { padding-left: 24px; padding-right: 24px; }
  #imgLogo_desktop{ display: none; }
  #imgLogo_mobile{ display:inline-block; }
  #backgroundEdificios_mobile{ display:inline-block; }
  #logo-card { width: 27%; }
}

/* Tablet / iPad */
@media (min-width: 481px) and (max-width: 768px){
  .container { max-width: 500px; margin-bottom: 50px;}
  .app-title { font-size: 2.2rem; } 
  .lobby-buttons { flex-direction: column; }
  .score-grid { grid-template-columns: 1fr 1fr; }
  .ranking-container { padding: 40px 30px; }
  .ranking-header h1 { font-size: 2.4rem; }
  .ranking-table { font-size: 1.1rem; }
  .btn-primary { width: 100%;}
  .btn-secondary { width: 100%; }
  .container_welcomeText { display: flex; flex-direction: column; font-size: 2rem; }
  .welcome-text { margin-bottom:10px; font-size: 2rem; }
  #imgLogo_mobile{ display:inline-block; }  
  #imgLogo_desktop{ display: none; }
  #imgLogo_mobile2 { display: inline-block; }
  #view-room .container { padding-top: 20px;}
}