/* ======================================================
   KADRO KUR - Broadcaster Control Panel Styles
   ====================================================== */

:root {
  /* Base colors */
  --bg-darkest:   #0d0d1a;
  --bg-dark:      #1a1a2e;
  --bg-mid:       #16213e;
  --bg-light:     #0f3460;
  --bg-card:      #1e2746;
  --bg-input:     #131a2e;

  /* Accent */
  --accent:       #e94560;
  --accent-hover: #ff6b81;

  /* Status */
  --green:        #2ecc71;
  --yellow:       #f1c40f;
  --red:          #e74c3c;
  --blue:         #3498db;

  /* Tier colors */
  --tier-bronze:  #cd7f32;
  --tier-silver:  #c0c0c0;
  --tier-gold:    #ffd700;
  --tier-diamond: #b9f2ff;

  /* Text */
  --text:         #e8e8f0;
  --text-muted:   #8888a8;
  --text-dim:     #555570;

  /* Borders */
  --border:       #2a2a4a;
  --border-light: #3a3a5a;

  /* Sizing */
  --radius:       8px;
  --radius-lg:    12px;
  --radius-sm:    4px;

  /* Transitions */
  --transition:   0.2s ease;
}

/* ============ RESET ============ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg-darkest);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4 { font-weight: 600; }
a { color: var(--accent); text-decoration: none; }

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--accent); }

/* ============ LOGIN SCREEN ============ */
.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, var(--bg-darkest) 0%, var(--bg-mid) 100%);
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 40px;
  width: 100%;
  max-width: 420px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.login-logo svg { display: block; margin: 0 auto 12px; }
.login-logo h1 { font-size: 1.8rem; letter-spacing: 3px; color: var(--accent); }
.login-subtitle { color: var(--text-muted); margin-top: 4px; font-size: 0.9rem; }

.login-form { margin-top: 32px; }
.login-form label {
  display: block;
  text-align: left;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.login-form input {
  width: 100%;
  padding: 14px 16px;
  font-size: 1.1rem;
  text-align: center;
  letter-spacing: 2px;
  text-transform: uppercase;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
}
.login-form input:focus { border-color: var(--accent); }
.login-form input::placeholder { color: var(--text-dim); letter-spacing: 1px; text-transform: none; }

.login-error {
  background: rgba(231, 76, 60, 0.15);
  border: 1px solid var(--red);
  border-radius: var(--radius-sm);
  color: var(--red);
  padding: 10px;
  margin-top: 12px;
  font-size: 0.85rem;
}

.login-form .btn { margin-top: 20px; width: 100%; }

/* ============ BUTTONS ============ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 24px;
  font-size: 0.95rem;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  color: #fff;
  white-space: nowrap;
}
.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.btn svg { flex-shrink: 0; }

.btn-primary   { background: var(--accent); }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }

.btn-success   { background: var(--green); color: #fff; }
.btn-success:hover:not(:disabled) { background: #27ae60; }

.btn-warning   { background: var(--yellow); color: #1a1a2e; }
.btn-warning:hover:not(:disabled) { background: #d4ac0d; }

.btn-danger    { background: var(--red); }
.btn-danger:hover:not(:disabled) { background: #c0392b; }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border-light);
  color: var(--text-muted);
}
.btn-ghost:hover:not(:disabled) {
  background: rgba(255,255,255,0.05);
  color: var(--text);
  border-color: var(--text-muted);
}

.btn-lg  { padding: 16px 32px; font-size: 1.05rem; }
.btn-sm  { padding: 8px 14px;  font-size: 0.8rem; }

/* ============ TOP BAR ============ */
.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: var(--bg-dark);
  border-bottom: 1px solid var(--border);
  padding: 12px 24px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.top-bar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.top-bar-title {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--accent);
}

.top-bar-center {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  justify-content: center;
  min-width: 0;
}
.obs-label { color: var(--text-muted); font-size: 0.8rem; flex-shrink: 0; }
.obs-url {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 0.8rem;
  color: var(--blue);
  max-width: 360px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-bar-right { flex-shrink: 0; }

/* Status Badge */
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  display: inline-block;
}
.status-online  { background: rgba(46,204,113,0.15); color: var(--green); }
.status-online .status-dot  { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-offline { background: rgba(231,76,60,0.15); color: var(--red); }
.status-offline .status-dot { background: var(--red); }

/* Small status dot for inline use */
.status-dot-sm {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
}
.status-dot-green { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot-red   { background: var(--red); }

/* ============ TAB NAVIGATION ============ */
.tab-nav {
  display: flex;
  gap: 2px;
  background: var(--bg-dark);
  border-bottom: 2px solid var(--border);
  padding: 0 24px;
  overflow-x: auto;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 20px;
  font-size: 0.88rem;
  font-weight: 600;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  white-space: nowrap;
}
.tab-btn:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.tab-btn.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.tab-btn.active svg { stroke: var(--accent); }

/* ============ TAB CONTENT ============ */
.tab-content-wrapper {
  padding: 24px;
  max-width: 1200px;
  margin: 0 auto;
}

.tab-content { display: none; }
.tab-content.active { display: block; }

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.section-header h2 { font-size: 1.3rem; }
.section-actions { display: flex; gap: 8px; }

.section-footer {
  margin-top: 24px;
  text-align: center;
}

/* ============ FORM ELEMENTS ============ */
input[type="text"],
input[type="number"],
input[type="url"],
select {
  padding: 10px 14px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text);
  outline: none;
  transition: border-color var(--transition);
  font-family: inherit;
}
input:focus, select:focus { border-color: var(--accent); }
input::placeholder { color: var(--text-dim); }

input[type="color"] {
  width: 48px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  cursor: pointer;
  padding: 2px;
}

select {
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238888a8' stroke-width='2' xmlns='http://www.w3.org/2000/svg'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.input-row input[type="text"],
.input-row input[type="number"] {
  flex: 1;
  min-width: 160px;
}

/* Checkbox */
.checkbox-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  transition: all var(--transition);
  font-size: 0.88rem;
}
.checkbox-item:hover { border-color: var(--accent); }
.checkbox-item input[type="checkbox"] {
  accent-color: var(--accent);
  width: 16px;
  height: 16px;
}

/* ============ TAB 1 - TEAM CARDS ============ */
.teams-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.team-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  position: relative;
  transition: border-color var(--transition);
}
.team-card:hover { border-color: var(--border-light); }

.team-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--text-muted);
}
.team-number {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
}

.team-card label {
  display: block;
  font-size: 0.78rem;
  color: var(--text-muted);
  margin-bottom: 4px;
  margin-top: 12px;
}
.team-card label:first-of-type { margin-top: 0; }

.team-card input[type="text"],
.team-card select {
  width: 100%;
}

.team-card-color-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.team-card-color-row input[type="color"] { flex-shrink: 0; }
.team-card-color-row span { font-size: 0.8rem; color: var(--text-dim); }

.emblem-upload {
  display: flex;
  align-items: center;
  gap: 10px;
}
.emblem-upload input[type="file"] { display: none; }
.emblem-upload-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 0.8rem;
  background: var(--bg-input);
  border: 1px dashed var(--border-light);
  border-radius: var(--radius);
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
}
.emblem-upload-btn:hover { border-color: var(--accent); color: var(--accent); }

.emblem-preview {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  background: var(--bg-input);
  border: 1px solid var(--border);
  display: none;
}

/* ============ TAB 2 - SETTINGS ============ */
.settings-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 20px;
}

.settings-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
}
.settings-card h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1rem;
  margin-bottom: 16px;
}

.connection-status {
  display: flex;
  align-items: center;
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.tier-ranges {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.tier-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--bg-input);
  border-left: 3px solid transparent;
}
.tier-row input { width: 70px; text-align: center; }
.tier-sep { color: var(--text-dim); }
.tier-label { width: 60px; font-weight: 600; font-size: 0.85rem; }

.tier-bronze  { border-left-color: var(--tier-bronze); }
.tier-bronze .tier-label { color: var(--tier-bronze); }
.tier-silver  { border-left-color: var(--tier-silver); }
.tier-silver .tier-label { color: var(--tier-silver); }
.tier-gold    { border-left-color: var(--tier-gold); }
.tier-gold .tier-label { color: var(--tier-gold); }
.tier-diamond { border-left-color: var(--tier-diamond); }
.tier-diamond .tier-label { color: var(--tier-diamond); }

.league-checkboxes {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.card-count-display {
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--bg-input);
  border-radius: var(--radius);
  font-size: 0.9rem;
  color: var(--text-muted);
}
.card-count-display strong { color: var(--accent); font-size: 1.1rem; }

/* ============ TAB 3 - CARD DISTRIBUTION ============ */
.game-controls {
  display: flex;
  gap: 12px;
  margin-bottom: 24px;
  flex-wrap: wrap;
}
.game-controls .btn { min-width: 140px; }

.cards-layout {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 20px;
  margin-bottom: 24px;
  position: relative;
}

/* Queue Panel */
.queue-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.queue-panel h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  margin-bottom: 12px;
  color: var(--text-muted);
}

.request-queue {
  max-height: 400px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.queue-empty, .log-empty {
  text-align: center;
  color: var(--text-dim);
  padding: 40px 20px;
  font-size: 0.85rem;
}

.queue-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--bg-input);
  border-radius: var(--radius);
  border-left: 3px solid var(--border-light);
  cursor: pointer;
  transition: all var(--transition);
}
.queue-item:hover { background: rgba(255,255,255,0.05); }
.queue-item.selected {
  border-left-color: var(--accent);
  background: rgba(233, 69, 96, 0.1);
}

.queue-item-user {
  font-weight: 600;
  font-size: 0.88rem;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.queue-item-comment {
  font-size: 0.75rem;
  color: var(--text-dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 160px;
}

.tier-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.7rem;
  font-weight: 700;
  flex-shrink: 0;
}
.tier-badge-1 { background: rgba(205,127,50,0.2); color: var(--tier-bronze); }
.tier-badge-2 { background: rgba(192,192,192,0.2); color: var(--tier-silver); }
.tier-badge-3 { background: rgba(255,215,0,0.15); color: var(--tier-gold); }
.tier-badge-4 { background: rgba(185,242,255,0.15); color: var(--tier-diamond); }

/* Assign Panel */
.assign-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.assign-panel h3 {
  font-size: 0.9rem;
  margin-bottom: 12px;
  color: var(--text-muted);
}

.team-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.team-assign-btn {
  width: 100%;
  padding: 18px 16px;
  font-size: 1rem;
  font-weight: 700;
  border: 2px solid transparent;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  color: #fff;
  text-align: center;
  background: var(--bg-light);
}
.team-assign-btn:hover {
  transform: scale(1.02);
  filter: brightness(1.2);
}
.team-assign-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  transform: none;
  filter: none;
}

/* Card Result Popup */
.card-result-popup {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}
.popup-inner {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  text-align: center;
  min-width: 300px;
  max-width: 420px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.popup-icon { font-size: 2rem; margin-bottom: 12px; }
.popup-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 8px; }
.popup-detail { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 20px; }

.popup-added  .popup-title { color: var(--green); }
.popup-replaced .popup-title { color: var(--yellow); }
.popup-rejected .popup-title { color: var(--red); }

/* ============ FORMATIONS ROW ============ */
.formations-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}

.formation-mini {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px;
  text-align: center;
}
.formation-mini-title {
  font-size: 0.78rem;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text-muted);
}

.mini-pitch {
  position: relative;
  width: 100%;
  padding-bottom: 130%;
  background: linear-gradient(to bottom, #1a5c2a 0%, #1e6b31 48%, #1a5c2a 50%, #1e6b31 100%);
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.mini-pitch::before {
  content: '';
  position: absolute;
  top: 48%; left: 10%;
  width: 80%; height: 4%;
  border-top: 1px solid rgba(255,255,255,0.2);
}
.mini-pitch::after {
  content: '';
  position: absolute;
  top: 30%; left: 25%;
  width: 50%; height: 0;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 50%;
  padding-bottom: 20%;
}

.mini-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #fff;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 4px rgba(0,0,0,0.5);
  transition: background var(--transition);
}
.mini-dot.filled {
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
}

.formation-mini-count {
  margin-top: 8px;
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* ============ ACTION LOG ============ */
.action-log-section {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.action-log-section h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  margin-bottom: 12px;
  color: var(--text-muted);
}

.action-log {
  max-height: 240px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.log-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  background: var(--bg-input);
}
.log-time { color: var(--text-dim); font-size: 0.75rem; flex-shrink: 0; width: 60px; }
.log-msg  { flex: 1; }

/* ============ TAB 4 - SCORE ============ */
.score-section { max-width: 800px; margin: 0 auto; }

.score-table-wrap {
  overflow-x: auto;
  margin-bottom: 24px;
}
.score-table {
  width: 100%;
  border-collapse: collapse;
}
.score-table th,
.score-table td {
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.score-table th {
  background: var(--bg-mid);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
}
.score-table td { font-size: 0.9rem; }
.score-table tr:hover td { background: rgba(255,255,255,0.02); }
.empty-row { text-align: center; color: var(--text-dim); }

.rank-1 { color: var(--tier-gold); font-weight: 700; }
.rank-2 { color: var(--tier-silver); font-weight: 600; }
.rank-3 { color: var(--tier-bronze); font-weight: 600; }

.stats-summary, .profile-stats {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.stat-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px 16px;
  text-align: center;
}
.stat-value { display: block; font-size: 1.8rem; font-weight: 700; color: var(--accent); }
.stat-label { display: block; font-size: 0.78rem; color: var(--text-muted); margin-top: 4px; }

.final-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

/* ============ TAB 5 - PROFILE ============ */
.profile-section { max-width: 800px; margin: 0 auto; }
.profile-section h3 { margin-bottom: 16px; }

.past-games-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.past-game-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.88rem;
}
.past-game-date { color: var(--text-dim); font-size: 0.8rem; }
.past-game-info { color: var(--text-muted); }
.past-game-winner { color: var(--tier-gold); font-weight: 600; }

/* ============ RESPONSIVE ============ */
@media (max-width: 768px) {
  .top-bar {
    flex-wrap: wrap;
    padding: 10px 16px;
    gap: 8px;
  }
  .top-bar-center { order: 3; flex-basis: 100%; justify-content: flex-start; }

  .tab-nav { padding: 0 12px; }
  .tab-btn { padding: 10px 14px; font-size: 0.8rem; }
  .tab-btn svg { display: none; }

  .tab-content-wrapper { padding: 16px; }

  .teams-grid { grid-template-columns: 1fr; }
  .settings-grid { grid-template-columns: 1fr; }
  .cards-layout { grid-template-columns: 1fr; }
  .formations-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 480px) {
  .login-card { padding: 32px 24px; margin: 16px; }
  .game-controls { flex-direction: column; }
  .game-controls .btn { width: 100%; }
}
