/* ANSC Cricket Scoreboard — Control Panel Styles */
/* School Theme: Deep Blue #001E35, Gold #FFF38B, Light Blue #87E1FF */

:root {
  --ansc-navy: #001E35;
  --ansc-navy-light: #003459;
  --ansc-gold: #FFF38B;
  --ansc-gold-dark: #E6D96E;
  --ansc-sky: #87E1FF;
  --ansc-white: #FFFFFF;
  --ansc-gray: #F0F4F8;
  --ansc-text: #1A2B3C;
  --ansc-danger: #D32F2F;
  --ansc-success: #2E7D32;
  --ansc-muted: #5A6B7C;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  font-family: 'Dosis', sans-serif;
  background: linear-gradient(135deg, #EAF2F8 0%, #D4E5F7 100%);
  color: var(--ansc-text);
  min-height: 100vh;
  overflow-x: hidden;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1rem;
}

/* Header */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: linear-gradient(135deg, var(--ansc-navy) 0%, var(--ansc-navy-light) 100%);
  color: var(--ansc-white);
  padding: 1rem 1.5rem;
  border-radius: 16px;
  margin-bottom: 1.5rem;
  box-shadow: 0 4px 20px rgba(0, 30, 53, 0.25);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  justify-content: center;
}

.header-logo {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid var(--ansc-gold);
}

.header h1 {
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.header-sub {
  font-size: 0.85rem;
  color: var(--ansc-sky);
  font-weight: 600;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.1);
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ansc-danger);
  transition: background 0.3s;
}

.status-indicator.connected .status-dot {
  background: var(--ansc-success);
  box-shadow: 0 0 8px var(--ansc-success);
}

.status-text {
  font-size: 0.85rem;
  font-weight: 600;
}

/* Buttons */
.btn {
  font-family: 'Dosis', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 30, 53, 0.2);
}

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

.btn-primary {
  background: var(--ansc-navy);
  color: var(--ansc-white);
}

.btn-primary:hover {
  background: var(--ansc-navy-light);
}

.btn-secondary {
  background: var(--ansc-sky);
  color: var(--ansc-navy);
}

.btn-secondary:hover {
  background: #6DD5FF;
}

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

.btn-danger:hover {
  background: #B71C1C;
}

/* Cards */
.card {
  background: var(--ansc-white);
  border-radius: 16px;
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  box-shadow: 0 2px 12px rgba(0, 30, 53, 0.08);
  border: 1px solid rgba(0, 30, 53, 0.06);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--ansc-navy);
  margin-bottom: 1rem;
  padding-bottom: 0.5rem;
  border-bottom: 2px solid var(--ansc-gold);
  display: inline-block;
}

/* Teams */
.teams-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
}

.team-block label {
  display: block;
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--ansc-navy);
  margin-bottom: 0.3rem;
  margin-top: 0.8rem;
}

.team-block input[type="text"] {
  width: 100%;
  padding: 0.6rem 0.8rem;
  border: 2px solid #E0E6EC;
  border-radius: 10px;
  font-family: 'Dosis', sans-serif;
  font-size: 1rem;
  transition: border-color 0.2s;
}

.team-block input[type="text"]:focus {
  outline: none;
  border-color: var(--ansc-navy);
}

.team-block input[type="file"] {
  width: 100%;
  padding: 0.4rem 0;
  font-family: 'Dosis', sans-serif;
}

.logo-preview {
  margin-top: 0.5rem;
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed #D0D8E0;
  border-radius: 10px;
  overflow: hidden;
}

.logo-preview img {
  max-height: 60px;
  max-width: 100%;
  object-fit: contain;
}

/* Squad Management */
.squad-section {
  margin-top: 1rem;
  border: 1px solid #E0E6EC;
  border-radius: 10px;
  overflow: hidden;
  background: #FAFBFC;
}

.squad-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.6rem 0.9rem;
  background: linear-gradient(90deg, #F0F4F8 0%, #E8EEF4 100%);
  cursor: pointer;
  user-select: none;
  border-bottom: 1px solid #E0E6EC;
  transition: background 0.2s;
}

.squad-header:hover {
  background: linear-gradient(90deg, #E8EEF4 0%, #E0E6EC 100%);
}

.squad-title {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ansc-navy);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.squad-toggle {
  font-size: 0.85rem;
  color: var(--ansc-muted);
  transition: transform 0.2s;
}

.squad-section.collapsed .squad-toggle {
  transform: rotate(-90deg);
}

.squad-section.collapsed .squad-list {
  display: none;
}

.squad-list {
  padding: 0.75rem;
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.4rem;
}

.squad-player-input {
  width: 100%;
  padding: 0.45rem 0.7rem;
  border: 1.5px solid #E0E6EC;
  border-radius: 8px;
  font-family: 'Dosis', sans-serif;
  font-size: 0.95rem;
  transition: border-color 0.2s;
}

.squad-player-input:focus {
  outline: none;
  border-color: var(--ansc-navy);
}

/* Player Select Dropdowns */
.player-select-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  align-items: center;
}

.player-select-row select {
  flex: 1;
  padding: 0.55rem 0.7rem;
  border: 2px solid #E0E6EC;
  border-radius: 8px;
  font-family: 'Dosis', sans-serif;
  font-size: 0.95rem;
  background: var(--ansc-white);
  color: var(--ansc-text);
  cursor: pointer;
  transition: border-color 0.2s;
}

.player-select-row select:focus {
  outline: none;
  border-color: var(--ansc-navy);
}

.btn-sm {
  font-size: 0.8rem;
  padding: 0.45rem 0.7rem;
  white-space: nowrap;
}

@keyframes highlightPulse {
  0% { box-shadow: 0 0 0 0 rgba(0, 119, 182, 0.5); border-color: var(--ansc-sky); }
  70% { box-shadow: 0 0 0 10px rgba(0, 119, 182, 0); border-color: var(--ansc-sky); }
  100% { box-shadow: 0 0 0 0 rgba(0, 119, 182, 0); border-color: #E0E6EC; }
}

.teams-actions {
  margin-top: 1rem;
  display: flex;
  gap: 0.75rem;
}

/* Score Grid */
.score-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0.75rem;
}

.score-btn {
  font-family: 'Dosis', sans-serif;
  font-weight: 700;
  font-size: 1.3rem;
  padding: 1rem;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  background: var(--ansc-gray);
  color: var(--ansc-navy);
  transition: all 0.15s;
}

.score-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 30, 53, 0.15);
}

.score-btn:active {
  transform: scale(0.98);
}

.score-btn-four {
  background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
  color: #2E7D32;
}

.score-btn-six {
  background: linear-gradient(135deg, #FFF3E0 0%, #FFE0B2 100%);
  color: #E65100;
}

.score-btn-extra {
  background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
  color: #1565C0;
  font-size: 1rem;
}

.score-btn-wicket {
  background: linear-gradient(135deg, #FFEBEE 0%, #FFCDD2 100%);
  color: var(--ansc-danger);
  font-size: 1rem;
}

.extra-runs {
  margin-top: 1rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.extra-runs label {
  font-weight: 600;
  color: var(--ansc-navy);
}

.extra-runs input {
  width: 70px;
  padding: 0.4rem 0.6rem;
  border: 2px solid #E0E6EC;
  border-radius: 8px;
  font-family: 'Dosis', sans-serif;
  font-size: 1rem;
}

/* Over Progress */
.over-progress {
  margin-top: 1rem;
  padding: 0.75rem;
  background: linear-gradient(90deg, #F0F4F8 0%, #E8EEF4 100%);
  border-radius: 10px;
  border: 1px solid #E0E6EC;
}

.over-progress-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--ansc-navy);
  margin-bottom: 0.4rem;
}

.over-progress-label span {
  color: var(--ansc-sky);
}

.over-progress-bar {
  width: 100%;
  height: 10px;
  background: #D0DAE6;
  border-radius: 5px;
  overflow: hidden;
  margin-bottom: 0.4rem;
}

.over-progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--ansc-navy) 0%, var(--ansc-sky) 100%);
  border-radius: 5px;
  transition: width 0.4s ease;
}

.over-progress-note {
  font-size: 0.75rem;
  color: var(--ansc-muted);
  text-align: right;
  font-weight: 600;
}

/* Players */
.players-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.25rem;
}

.bowler-block {
  grid-column: 1 / -1;
}

.player-block {
  background: var(--ansc-gray);
  border-radius: 12px;
  padding: 1rem;
}

.player-block h3 {
  font-size: 1rem;
  color: var(--ansc-navy);
  margin-bottom: 0.6rem;
  font-weight: 700;
}

.player-block input[type="text"] {
  width: 100%;
  padding: 0.5rem 0.7rem;
  border: 2px solid #E0E6EC;
  border-radius: 8px;
  font-family: 'Dosis', sans-serif;
  margin-bottom: 0.6rem;
}

.player-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.8rem;
}

.player-stats div {
  display: flex;
  flex-direction: column;
}

.player-stats label {
  font-size: 0.7rem;
  font-weight: 700;
  color: #6B7B8A;
  text-transform: uppercase;
  margin-bottom: 0.15rem;
}

.player-stats input {
  padding: 0.4rem;
  border: 2px solid #E0E6EC;
  border-radius: 8px;
  font-family: 'Dosis', sans-serif;
  font-size: 0.95rem;
  text-align: center;
}

/* Commentary */
.commentary-row {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.commentary-row input {
  flex: 1;
  padding: 0.6rem 0.9rem;
  border: 2px solid #E0E6EC;
  border-radius: 10px;
  font-family: 'Dosis', sans-serif;
  font-size: 1rem;
}

.commentary-row input:focus {
  outline: none;
  border-color: var(--ansc-navy);
}

.history-list {
  max-height: 200px;
  overflow-y: auto;
  background: var(--ansc-gray);
  border-radius: 10px;
  padding: 0.75rem;
}

.history-item {
  padding: 0.4rem 0;
  border-bottom: 1px solid #E0E6EC;
  font-size: 0.9rem;
  color: var(--ansc-text);
}

.history-item:last-child {
  border-bottom: none;
}

.history-item span {
  color: #8A9AA8;
  font-size: 0.75rem;
  margin-right: 0.5rem;
}

/* Footer */
.footer {
  text-align: center;
  padding: 1rem;
  color: #8A9AA8;
  font-size: 0.85rem;
}

/* ============================================================
   MOBILE-FIRST RESPONSIVE
   ============================================================ */

/* Mobile base (< 640px) */
@media (max-width: 639px) {
  .app {
    padding: 0.5rem;
  }

  .header {
    flex-direction: column;
    gap: 0.75rem;
    text-align: center;
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
  }

  .header-logo {
    width: 44px;
    height: 44px;
  }

  .header h1 {
    font-size: 1.1rem;
  }

  .header-sub {
    font-size: 0.78rem;
  }

  .header-status {
    flex-direction: column;
    gap: 0.5rem;
  }

  .btn {
    font-size: 0.85rem;
    padding: 0.5rem 1rem;
  }

  .btn-sm {
    font-size: 0.75rem;
    padding: 0.4rem 0.6rem;
    width: auto;
  }

  .teams-actions .btn,
  .header-status .btn,
  .player-block > .btn-primary {
    width: 100%;
  }

  .card {
    padding: 1rem;
    margin-bottom: 0.75rem;
    border-radius: 12px;
  }

  .card-title {
    font-size: 1rem;
    margin-bottom: 0.75rem;
  }

  .teams-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .team-block input[type="text"] {
    font-size: 0.95rem;
    padding: 0.5rem 0.7rem;
  }

  .teams-actions {
    flex-direction: column;
  }

  .squad-list {
    padding: 0.5rem;
  }

  .squad-player-input {
    font-size: 0.9rem;
    padding: 0.4rem 0.6rem;
  }

  .score-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
  }

  .score-btn {
    font-size: 1rem;
    padding: 0.65rem 0.3rem;
    border-radius: 10px;
    min-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: normal;
    word-break: break-word;
    line-height: 1.1;
    text-align: center;
  }

  .score-btn-extra,
  .score-btn-wicket {
    font-size: 0.78rem;
  }

  .extra-runs {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.4rem;
  }

  .extra-runs input {
    width: 100%;
    max-width: 100px;
  }

  .over-progress {
    padding: 0.6rem;
    margin-top: 0.75rem;
  }

  .over-progress-label {
    font-size: 0.8rem;
  }

  .over-progress-note {
    font-size: 0.7rem;
  }

  .players-grid {
    grid-template-columns: 1fr;
    gap: 1rem;
  }

  .bowler-block {
    grid-column: auto;
  }

  .player-block {
    padding: 0.875rem;
  }

  .player-select-row {
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 0.4rem;
  }

  .player-select-row select {
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.9rem;
    padding: 0.45rem 0.55rem;
  }

  .player-select-row .btn-sm {
    flex: 0 0 auto;
    white-space: nowrap;
  }

  .player-stats {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
  }

  .player-stats input {
    font-size: 0.9rem;
    padding: 0.35rem;
  }

  .commentary-row {
    flex-direction: column;
    gap: 0.5rem;
  }

  .commentary-row input {
    width: 100%;
    padding: 0.55rem 0.75rem;
  }

  .history-list {
    max-height: 160px;
  }

  .footer {
    padding: 0.75rem;
    font-size: 0.78rem;
  }
}

/* Tablet (640px – 1023px) */
@media (min-width: 640px) and (max-width: 1023px) {
  .app {
    padding: 0.75rem;
  }

  .header {
    padding: 0.875rem 1.25rem;
  }

  .header h1 {
    font-size: 1.25rem;
  }

  .teams-grid {
    grid-template-columns: 1fr 1fr;
    gap: 1.25rem;
  }

  .score-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 0.6rem;
  }

  .players-grid {
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
  }

  .bowler-block {
    grid-column: auto;
  }

  .player-stats {
    grid-template-columns: repeat(auto-fit, minmax(52px, 1fr));
  }
}

/* Desktop (1024px+) */
@media (min-width: 1024px) {
  .app {
    padding: 1.25rem;
    max-width: 1200px;
    margin: 0 auto;
  }

  .score-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .players-grid {
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.25rem;
  }

  .bowler-block {
    grid-column: auto;
  }
}
