/* ========== Theme Variables ========== */
:root {
  --primary: #007bff;
  --safe: #28a745;
  --danger: #dc3545;
  --admin-bg: linear-gradient(135deg, #e3f2fd, #f0f7ff);
  --player-bg: linear-gradient(135deg, #e8f5e9, #f4f6f9);
  --admin-accent: #0056b3;
  --player-accent: #1b5e20;
  --radius: 0.75rem;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.05);
  --shadow-lg: 0 6px 20px rgba(0,0,0,0.2);
  --focus-ring: 2px solid var(--primary);
}

/* ========== Base Styles ========== */
* {
  box-sizing: border-box;
}

body {
  font-family: system-ui, Arial, sans-serif;
  background: #f4f6f9;
  margin: 0;
  padding: 0;
  color: #222;
  line-height: 1.5;
}

.container {
  max-width: 900px;
  margin: 2rem auto;
  padding: 1.5rem;
}

/* ========== Header ========== */
.header {
  text-align: center;
  margin-bottom: 2rem;
}

.header h1 {
  font-size: 2rem;
  font-weight: 700;
  margin: 0;
}

.subtitle {
  color: #666;
  font-size: 0.95rem;
  margin-top: 0.5rem;
}

.badge {
  display: inline-block;
  margin-left: 0.5rem;
  padding: 0.2em 0.6em;
  font-size: 0.8rem;
  border-radius: 1rem;
  background: var(--primary);
  color: white;
  animation: pulse 1.5s infinite ease-in-out;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.05); opacity: 0.85; }
}

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

.modal[aria-hidden="false"] {
  animation: fadeIn 0.3s ease-out forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-content {
  background: #fff;
  padding: 2rem;
  border-radius: var(--radius);
  max-width: 400px;
  width: 100%;
  box-shadow: var(--shadow-lg);
  outline: none;
}

.modal-content:focus-visible {
  box-shadow: 0 0 0 4px rgba(0,123,255,0.3);
}

.modal-content h2 {
  margin-top: 0;
  margin-bottom: 1rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group.checkbox {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

input[type="password"] {
  width: 100%;
  padding: 0.6rem;
  border: 1px solid #ccc;
  border-radius: 0.4rem;
  font-size: 1rem;
}

.error-message {
  margin-top: 0.5rem;
  font-size: 0.9rem;
  color: #c00;
  animation: shake 0.3s ease;
}

@keyframes shake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  50% { transform: translateX(4px); }
  75% { transform: translateX(-2px); }
  100% { transform: translateX(0); }
}

/* ========== Buttons ========== */
.btn {
  display: inline-block;
  padding: 0.6rem 1.2rem;
  border: none;
  border-radius: 0.5rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
  position: relative;
  isolation: isolate;
}

.btn::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: rgba(255,255,255,0.1);
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: -1;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:hover::after {
  opacity: 1;
}

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

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

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

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

.button-group {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

/* ========== Section Wrappers ========== */
.section-admin {
  background: var(--admin-bg);
  border-left: 4px solid var(--admin-accent);
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

.section-player {
  background: var(--player-bg);
  border-left: 4px solid var(--player-accent);
  padding: 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

/* ========== Controls & Status ========== */
.controls {
  background: #fff;
  padding: 1rem;
  border-radius: var(--radius);
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.status {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    background: #fff;
    padding: 1rem;
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
}

.controls .field {
  margin-bottom: 0.5rem;
}

.pill {
  display: inline-block;
  padding: 0.3em 0.8em;
  border-radius: 1rem;
  font-size: 0.85rem;
  background: var(--primary);
  color: white;
}

.pill.admin {
  background: var(--admin-accent);
}

.pill.player {
  background: var(--player-accent);
}

/* ========== Table ========== */
.table-responsive {
  overflow-x: auto;
}

.players-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.players-table caption {
  background: #dcedc8;
  color: var(--player-accent);
  text-align: left;
  padding: 0.75rem;
  font-weight: 600;
}

.sessions-table caption {
  background: #bbdefb;
  color: var(--admin-accent);
  text-align: left;
  padding: 0.75rem;
  font-weight: 600;
}

.players-table th,
.players-table td,
.sessions-table th,
.sessions-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid #e5e7eb;
}

.players-table th {
  background: #f1f3f5;
  font-weight: 600;
}

.sessions-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.sessions-table th {
  background: #eef2f6;
  font-weight: 600;
}
.sessions-table .caption-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    padding-right: 0.5rem;
}

.sessions-table .caption-container span {
    font-weight: 600;
}

.sessions-table .caption-container button {
    margin-left: auto;
    font-size: 0.85rem;
    padding: 0.3rem 0.8rem;
}

.players-table tr:last-child td,
.sessions-table tr:last-child td {
  border-bottom: none;
}

.players-table tr:nth-child(even),
.sessions-table tr:nth-child(even) {
  background: #f9fbfc;
}

.players-table tr:hover,
.sessions-table tr:hover {
  background: #e6f0ff;
}

.nowrap {
  white-space: nowrap;
}

/* ========== Role Badges ========== */
.role-badge {
  display: inline-block;
  font-size: 0.75rem;
  padding: 0.2em 0.6em;
  border-radius: 1rem;
  font-weight: 600;
  text-transform: uppercase;
}

.role-badge.admin {
  background: var(--admin-accent);
  color: white;
}

.role-badge.player {
  background: var(--player-accent);
  color: white;
}

/* ========== Accessibility ========== */
*:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* Add this to your CSS file */
.flash-name {
    animation: nameFlash 1.5s ease-in-out infinite;
}

@keyframes nameFlash {
    0% { 
        background-color: transparent;
    }
    25% {
        background-color: var(--flash-color);
    }
    100% {
        background-color: transparent;
    }
}

/* If you want a different color or more subtle version */
.flash-name-subtle {
    animation: nameFlashSubtle 1.5s ease-in-out infinite;
}

@keyframes nameFlashSubtle {
    0% { 
        text-shadow: none;
        color: inherit;
    }
    25% {
        text-shadow: 0 0 8px rgba(255, 255, 0, 0.5);
        color: #666;
    }
    100% {
        text-shadow: none;
        color: inherit;
    }
}

.winner-display {
    order: 1;
    margin: 0;
    flex-grow: 0;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 300px;
    min-height: 80px;
    padding: 1rem;
    visibility: visible; /* Make this the default state */
}

.winner-display[hidden] {
    visibility: hidden; /* Instead of display: none */
    display: flex; /* Keep the element in the layout */
}

.winner-name {
    color: #000;
    font-weight: 800;
    font-size: 2.2rem;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.1);
    animation: winnerPulse 2s infinite ease-in-out;
    order: 2;
}

.winner-label {
    color: #744210;
    font-weight: normal;
    font-size: 0.8rem;
    opacity: 0.8;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0;
    order: 1;
    align-self: center;
}

@keyframes winnerPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

/* Make player table more compact */
.players-table td {
    padding: 0.5rem 0.75rem; /* Reduce padding */
    font-size: 0.9rem; /* Slightly smaller text */
    vertical-align: middle;
}

/* Smaller buttons in tables */
.players-table .btn {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    min-height: 0;
}

/* Style for the poke input */
.poke-input {
    width: 100%;
    padding: 0.4rem 0.6rem;
    border: 1px solid #e5e7eb;
    border-radius: var(--radius);
    font-size: 0.85rem;
    transition: border-color 0.2s ease;
}

.poke-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

/* Make the table cells with inputs have proper padding */
.players-table td .btn + .btn {
    margin-left: 0.5rem;
}

/* Style for remove button */
.players-table .btn-remove {
    background-color: #fee2e2; /* Light red background */
    color: #dc2626; /* Red text */
    border: 1px solid #fecaca;
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
}

.players-table .btn-remove:hover {
    background-color: #fecaca;
    border-color: #dc2626;
}

/* Style for the player name link */
.player-name-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.login-link {
    color: var(--primary);
    font-size: 0.8rem;
    text-decoration: none;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.login-link:hover {
    opacity: 1;
    text-decoration: underline;
} 

.player-name-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.player-name-cell .player-name {
    font-size: 1.1rem;  /* Larger name text */
    font-weight: 500;   /* Slightly bolder */
    color: #1a1a1a;     /* Darker text for better contrast */
}

.login-link {
    color: var(--primary);
    font-size: 0.8rem;
    text-decoration: none;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}.status-row.left {
    flex-shrink: 0;
}

.broadcast-container {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex: 1;
    max-width: 500px;
    margin-left: auto; /* Push to the right */
}

.broadcast-container .poke-input {
    flex: 1;
}

.broadcast-container .btn {
    white-space: nowrap;
    padding: 0.4rem 1rem;
}

hr {
    border: none;
    height: 4px;
    background: linear-gradient(to right, 
        transparent,
        var(--admin-accent),
        transparent
    );
    margin: 3rem 0;
    width: 100%;
    opacity: 0.3;
}