/* ========================================
   Modern Color Palette
======================================== */
:root {
  --primary: #4361ee;
  --primary-dark: #3a0ca3;
  --secondary: #7209b7;
  --accent: #f72585;
  --success: #06d6a0;
  --warning: #ffd166;
  --danger: #ef476f;
  
  --bg-primary: #f8f9fa;
  --bg-secondary: #e9ecef;
  --bg-card: #ffffff;
  
  --text-primary: #212529;
  --text-secondary: #6c757d;
  --text-muted: #adb5bd;
  
  --border-color: #dee2e6;
  --border-radius: 12px;
  --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
}

/* ========================================
   Base Styles
======================================== */
body {
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Arial, sans-serif;
  margin: 0;
  padding: 0;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  color: var(--text-primary);
  line-height: 1.6;
}

/* ========================================
   Header Styling
======================================== */
header {
  background: linear-gradient(135deg, #4361ee 0%, #7209b7 100%);
  color: #fff;
  padding: 16px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

header h1 {
  font-size: 20px;
  margin: 0;
  font-weight: 600;
  letter-spacing: -0.5px;
}

nav a {
  color: rgba(255, 255, 255, 0.9);
  margin-left: 24px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: 20px;
  transition: all 0.2s ease;
}

nav a:hover, nav a.active {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  text-decoration: none;
}

/* ========================================
   Main Content Area
======================================== */
main {
  max-width: 90%;
  margin: 24px auto;
  padding: 0 20px;
}

/* ========================================
   Card Components
======================================== */
.card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
  border: none;
}

.card h2 {
  margin-top: 0;
  margin-bottom: 16px;
  font-size: 18px;
  color: var(--primary);
  font-weight: 600;
}

/* ========================================
   Typography & Small Text
======================================== */
.card h3 {
  margin: 24px 0 12px;
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
  border-bottom: 2px solid var(--bg-secondary);
  padding-bottom: 8px;
}

h3 {
  margin-top: 0;
  font-weight: 600;
}

p {
  margin: 0 0 12px;
  color: var(--text-secondary);
}

.small {
  font-size: 13px;
  color: var(--text-muted);
  margin: 0 0 16px;
}

/* ========================================
   Table Styling
======================================== */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--bg-card);
  border-radius: var(--border-radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

th, td {
  border: 1px solid var(--border-color);
  padding: 12px 14px;
  text-align: center;
}

th {
  background: linear-gradient(135deg, #f0f2f5 0%, #e9ecef 100%);
  font-weight: 600;
  color: var(--text-primary);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.5px;
}

tr:nth-child(even) {
  background: #f8f9fa;
}

tr:hover {
  background: #f1f3f5;
}

/* ========================================
   Form Elements
======================================== */
input[type=text],
input[type=password],
input[type=number],
select {
  padding: 10px 14px;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  transition: all 0.2s ease;
  outline: none;
  background: #fff;
}

input[type=text]:focus,
input[type=password]:focus,
input[type=number]:focus,
select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(67, 97, 238, 0.1);
}

input[type=number] {
  width: 70px;
  text-align: center;
}

/* ========================================
   Button Styling
======================================== */
button {
  cursor: pointer;
  padding: 10px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  outline: none;
}

/* Primary Button */
button, button#loginBtn, button#saveLongTermBtn, button#saveAllBtn {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
  color: #fff;
}

button:hover, button#loginBtn:hover, button#saveLongTermBtn:hover, button#saveAllBtn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  background: linear-gradient(135deg, #3a56d4 0%, #5e28cc 100%);
}

/* Secondary Button */
button#logoutBtn, button#refreshBtn {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

button#logoutBtn:hover, button#refreshBtn:hover {
  background: #dde1e6;
}

/* Danger Button (Delete) */
button.deleteMatchBtn {
  background: linear-gradient(135deg, #ef476f 0%, #d90429 100%);
  color: #fff;
}

button.deleteMatchBtn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

/* ========================================
   Message Styling
======================================== */
.msg {
  font-size: 13px;
  margin: 8px 0;
  padding: 8px 12px;
  border-radius: 6px;
  text-align: center;
}

.msg.error {
  background: #ffe5e7;
  color: var(--danger);
  border: 1px solid #fcb6d3;
}

.msg.ok {
  background: #d4edda;
  color: var(--success);
  border: 1px solid #c3e6cb;
}

/* ========================================
   Round Group Headers
======================================== */
.round-group h3 {
  margin: 20px 0 12px;
  font-size: 16px;
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
  padding-bottom: 8px;
}

/* ========================================
   Locked/Disabled Styles
======================================== */
.locked {
  color: var(--text-muted) !important;
  font-style: italic;
}

/* ========================================
   Joker Column
======================================== */
.joker-col {
  width: 45px;
  text-align: center;
}

.joker-col input[type=checkbox] {
  width: 18px;
  height: 18px;
  cursor: pointer;
}

/* ========================================
   Input Container Alignment
======================================== */
.card > *:not(h2):first-of-type {
  margin-top: -8px;
  margin-bottom: 16px;
}

#appArea {
  animation: fadeIn 0.3s ease;
}

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

/* ========================================
   Responsive Design
======================================== */
@media (max-width: 600px) {
  header {
    flex-direction: column;
    gap: 12px;
    padding: 14px 16px;
  }
  
  nav a {
    margin-left: 8px;
    margin-right: 8px;
  }
  
  .card {
    padding: 18px;
  }
  
  table, tbody, tr, td, th {
    display: block;
  }
  
  thead {
    display: none;
  }
  
  tr {
    margin-bottom: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 10px;
  }
  
  td {
    text-align: left;
    padding: 8px 10px;
    position: relative;
  }
}