/*
 * BUXjr Squares - Custom Styles
 * Apple-inspired design with custom blue color palette
 */

/* ========================================
   Color Palette
   ======================================== */
:root {
  --color-primary-dark: #3A5975;
  --color-secondary-blue: #5B7A95;
  --color-light-accent: #E5E7EB;
  --color-background: #FFFFFF;

  /* Additional shades for flexibility */
  --color-primary-darker: #2d4a5f;
  --color-primary-lighter: #4a6882;
  --color-text-dark: #1B3C53;
  --color-text-muted: #456882;
  --color-white: #ffffff;
  --color-success: #34c759;
  --color-danger: #ff3b30;
  --color-warning: #ff9500;

  /* Spacing (Apple-inspired generous spacing) */
  --spacing-xs: 0.5rem;
  --spacing-sm: 1rem;
  --spacing-md: 1.5rem;
  --spacing-lg: 2.5rem;
  --spacing-xl: 4rem;

  /* Border radius */
  --border-radius-sm: 8px;
  --border-radius-md: 12px;
  --border-radius-lg: 16px;

  /* Shadows */
  --shadow-sm: 0 2px 8px rgba(27, 60, 83, 0.08);
  --shadow-md: 0 4px 16px rgba(27, 60, 83, 0.12);
  --shadow-lg: 0 8px 24px rgba(27, 60, 83, 0.16);

  /* Transitions */
  --transition-fast: 0.15s ease;
  --transition-normal: 0.3s ease;
}

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

html {
  overscroll-behavior: none;
  -webkit-overflow-scrolling: auto;
  height: 100%;
  overflow-x: hidden;
  touch-action: pan-x pan-y;
  -ms-touch-action: pan-x pan-y;
}

body {
  font-family: 'Ubuntu', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background-color: var(--color-background);
  color: var(--color-text-dark);
  line-height: 1.5;
  font-size: 14px;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overscroll-behavior: none;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  touch-action: pan-x pan-y;
  -ms-touch-action: pan-x pan-y;
}

main {
  flex: 1;
}

h1, h2, h3, h4, h5, h6 {
  color: var(--color-primary-dark);
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.25rem; }
h4 { font-size: 1.1rem; }
h5 { font-size: 1rem; }
h6 { font-size: 0.875rem; }

p {
  margin-bottom: 1rem;
  color: var(--color-text-muted);
}

a {
  color: var(--color-secondary-blue);
  text-decoration: none;
  transition: color var(--transition-fast);
}

a:hover {
  color: var(--color-primary-dark);
  text-decoration: none;
}

/* ========================================
   Navigation
   ======================================== */
.navbar {
  background: linear-gradient(135deg, #E8EEF2 0%, #F0F5F8 100%);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  padding: 0.25rem 0;
  position: relative;
  z-index: 100;
}

.navbar-brand {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--color-primary-dark) !important;
  display: flex;
  align-items: center;
  padding: 0 !important;
  margin: 0;
  overflow: visible;
}

.navbar-brand img {
  height: 28px;
  width: auto;
  max-width: none;
}

.navbar-brand:hover {
  color: var(--color-primary-darker) !important;
}

.nav-link {
  color: #8B9DAF !important;
  font-weight: 500;
  font-size: 0.875rem;
  padding: 0.25rem 0.75rem !important;
  transition: color var(--transition-fast);
}

.nav-link:hover {
  color: var(--color-primary-dark) !important;
}

.nav-link.active {
  color: var(--color-primary-dark) !important;
}

.navbar-toggler {
  border: none;
  outline: none;
  box-shadow: none;
  padding: 0.5rem;
}

.navbar-toggler:focus {
  border: none;
  outline: none;
  box-shadow: none;
}

/* Animated hamburger icon */
.hamburger-icon {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 24px;
  height: 18px;
  cursor: pointer;
}

.hamburger-line {
  display: block;
  width: 100%;
  height: 2px;
  background-color: var(--color-primary-dark);
  border-radius: 2px;
  transition: all 0.3s ease;
  transform-origin: center;
}

/* Animate to X when menu is open */
.navbar-toggler[aria-expanded="true"] .hamburger-line:nth-child(1) {
  transform: translateY(8px) rotate(45deg);
}

.navbar-toggler[aria-expanded="true"] .hamburger-line:nth-child(2) {
  opacity: 0;
}

.navbar-toggler[aria-expanded="true"] .hamburger-line:nth-child(3) {
  transform: translateY(-8px) rotate(-45deg);
}

/* Mobile nav alignment */
@media (max-width: 991.98px) {
  .navbar-nav {
    text-align: left;
    padding-left: 0;
  }

  .navbar-nav .nav-link {
    padding-left: 0;
  }

  .navbar-collapse .navbar-nav:first-child {
    margin-left: 0 !important;
  }

  /* Only apply inline dropdown styles within the collapse */
  .navbar-collapse .navbar-nav .dropdown-menu {
    border: none;
    box-shadow: none;
    padding-left: 0.5rem;
  }

  .navbar-collapse .navbar-nav .dropdown-menu .dropdown-item {
    padding-left: 0.5rem;
  }

  /* Non-admin player dropdown: overlay outside navbar */
  .navbar > .container > .navbar-nav .dropdown-menu {
    position: absolute;
    right: 0;
    left: auto;
    box-shadow: var(--shadow-md);
    border: none;
    border-radius: var(--border-radius-sm);
  }
}

/* Remove focus ring from navbar dropdown toggles */
.navbar .nav-link.dropdown-toggle:focus {
  outline: none;
  box-shadow: none;
}

.dropdown-menu {
  border: none;
  box-shadow: var(--shadow-md);
  border-radius: var(--border-radius-sm);
}

.dropdown-item {
  color: var(--color-text-dark);
  font-size: 0.875rem;
  padding: 0.4rem 1rem;
}

.dropdown-item:hover {
  background-color: var(--color-light-accent);
  color: var(--color-primary-dark);
}

.dropdown-item i {
  color: var(--color-secondary-blue);
}

/* ========================================
   Buttons
   ======================================== */
.btn {
  padding: 8px 16px;
  border-radius: var(--border-radius-sm);
  font-weight: 500;
  font-size: 0.875rem;
  border: none;
  cursor: pointer;
  transition: all var(--transition-normal);
  display: inline-block;
  text-align: center;
}

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

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

.btn-primary:active,
.btn-primary:focus:active {
  background-color: #24394d !important;
  color: var(--color-white) !important;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2) !important;
  border-color: #24394d !important;
}

.btn-secondary {
  background-color: var(--color-secondary-blue);
  color: var(--color-white);
  border-color: var(--color-secondary-blue);
}

.btn-secondary:hover {
  background-color: var(--color-primary-dark);
  border-color: var(--color-primary-dark);
  color: var(--color-white);
}

.btn-secondary:active,
.btn-secondary:focus:active {
  background-color: #24394d !important;
  color: var(--color-white) !important;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.2) !important;
  border-color: #24394d !important;
}

.btn-outline-primary {
  background-color: transparent;
  border: 2px solid var(--color-primary-dark);
  color: var(--color-primary-dark);
}

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

/* Override Bootstrap's default blue focus ring on all buttons */
.btn:focus,
.btn:focus-visible {
  box-shadow: 0 0 0 0.2rem rgba(58, 89, 117, 0.25) !important;
}

/* ========================================
   Cards
   ======================================== */
.card {
  background: var(--color-white);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-sm);
  border: none;
  transition: box-shadow 0.2s ease-in-out;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  background-color: var(--color-primary-dark);
  color: var(--color-white);
  border-radius: var(--border-radius-md) var(--border-radius-md) 0 0 !important;
  font-weight: 500;
}

.card-header h1,
.card-header h2,
.card-header h3,
.card-header h4,
.card-header h5,
.card-header h6 {
  color: var(--color-white);
}

.card-title {
  color: var(--color-primary-dark);
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: var(--spacing-sm);
}

.card-text {
  color: var(--color-text-muted);
  margin-bottom: 0;
}

/* ========================================
   Tables
   ======================================== */
.table-responsive {
  border-radius: var(--border-radius-md);
  overflow: hidden;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.table {
  border-radius: var(--border-radius-md);
  margin-bottom: 0;
}

.table th,
.table td {
  border-color: rgba(0, 0, 0, 0.06);
}

.table th {
  white-space: nowrap;
  color: var(--color-white);
}

.table-dark {
  background-color: var(--color-primary-dark) !important;
}

.table-dark th {
  background-color: var(--color-primary-dark) !important;
  border-color: var(--color-primary-darker) !important;
}

/* Rounded bottom corners for last row */
.table tbody tr:last-child td:first-child {
  border-bottom-left-radius: var(--border-radius-md);
}

.table tbody tr:last-child td:last-child {
  border-bottom-right-radius: var(--border-radius-md);
}

/* Remove bottom border on last row to avoid double border */
.table tbody tr:last-child td {
  border-bottom: none;
}

/* Table hover effects - desktop only */
@media (min-width: 769px) {
  .table-hover tbody tr:hover {
    background-color: rgba(58, 89, 117, 0.08);
  }

  .table-hover-pulse tbody tr {
    cursor: pointer;
    transition: all 0.2s ease;
  }

  .table-hover-pulse tbody tr:hover {
    background-color: rgba(58, 89, 117, 0.12);
    animation: pulse-blue 1.5s ease-in-out infinite;
  }
}

@keyframes pulse-blue {
  0%, 100% {
    background-color: rgba(58, 89, 117, 0.08);
  }
  50% {
    background-color: rgba(58, 89, 117, 0.18);
  }
}

/* ========================================
   Forms
   ======================================== */
.form-control {
  border: 1px solid var(--color-light-accent);
  border-radius: var(--border-radius-sm);
  padding: 8px 12px;
  font-size: 0.875rem;
  transition: border-color var(--transition-fast);
}

.form-control:focus {
  border-color: #9BB0C5;
  outline: none;
  box-shadow: 0 0 0 3px rgba(58, 89, 117, 0.15);
}

.form-label {
  color: var(--color-primary-dark);
  font-weight: 500;
  font-size: 0.875rem;
  margin-bottom: 0.375rem;
}

.form-control::placeholder {
  color: #B8BEC7;
  opacity: 1;
}

.form-select {
  border: 1px solid var(--color-light-accent);
  border-radius: var(--border-radius-sm);
  padding: 8px 12px;
  font-size: 0.875rem;
}

.form-select:focus {
  border-color: #9BB0C5;
  box-shadow: 0 0 0 3px rgba(58, 89, 117, 0.15);
}

.input-group-text {
  background-color: #F3F4F6;
  border: 1px solid var(--color-light-accent);
  border-right: none;
  color: #6B7280;
  font-weight: 500;
  font-size: 0.875rem;
  padding: 8px 12px;
  border-radius: var(--border-radius-sm) 0 0 var(--border-radius-sm);
}

.input-group .form-control {
  border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
}

/* ========================================
   Checkbox Overrides - Use App Blue
   ======================================== */
.form-check-input:checked,
input[type="checkbox"]:checked {
  background-color: var(--color-primary-dark) !important;
  border-color: var(--color-primary-dark) !important;
}

.form-check-input:focus {
  box-shadow: 0 0 0 0.2rem rgba(58, 89, 117, 0.25) !important;
  border-color: var(--color-primary-dark) !important;
}

.form-check-input:hover:not(:disabled),
input[type="checkbox"]:hover:not(:disabled) {
  border-color: var(--color-primary-dark) !important;
}

/* ========================================
   Alerts
   ======================================== */
.alert {
  border-radius: var(--border-radius-sm);
  border: none;
  animation: slideIn 0.3s ease-out;
}

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

/* ========================================
   Toast Notifications
   ======================================== */
#toastMessage i {
  font-size: 1.125rem;
  opacity: 0.9;
}

#toastMessage span {
  flex: 1;
}

.toast-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.15);
  backdrop-filter: blur(4px);
  z-index: 9998;
  opacity: 0;
  transition: opacity 0.2s ease-out;
  pointer-events: none;
}

.toast-backdrop.show {
  opacity: 1;
}

.toast-container {
  z-index: 9999 !important;
}

.toast-countdown {
  display: block;
}

/* ========================================
   Badges
   ======================================== */
.badge {
  border-radius: 20px;
  padding: 0.3em 0.6em;
  font-weight: 500;
  font-size: 0.75rem;
}

.badge + .badge {
  margin-left: 0.25rem;
}

.bg-primary {
  background-color: var(--color-primary-dark) !important;
}

.bg-secondary {
  background-color: var(--color-secondary-blue) !important;
}

/* ========================================
   Footer
   ======================================== */
.footer {
  background-color: var(--color-primary-dark);
  color: var(--color-white);
  padding: 0;
  margin-top: 0;
}

.footer a {
  color: var(--color-light-accent);
}

.footer a:hover {
  color: var(--color-white);
}

.footer p,
.footer small {
  color: rgba(255, 255, 255, 0.8);
  margin-bottom: 0;
}

/* ========================================
   Modal
   ======================================== */
.modal-content {
  border-radius: var(--border-radius-md);
  border: none;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  background-color: var(--color-primary-dark) !important;
  color: var(--color-white) !important;
  border-radius: var(--border-radius-md) var(--border-radius-md) 0 0;
  border-bottom: none;
  padding: 0.75rem 1rem;
}

.modal-header .btn-close {
  filter: brightness(0) invert(1);
  opacity: 0.8;
}

.modal-header .btn-close:hover {
  opacity: 1;
}

.modal-header .modal-title,
.modal-title {
  color: var(--color-white) !important;
  font-weight: 600;
  font-size: 1.1rem;
  margin: 0;
}

/* ========================================
   Accordion
   ======================================== */
.accordion-button:not(.collapsed) {
  background-color: rgba(58, 89, 117, 0.1);
  color: var(--color-primary-dark);
}

.accordion-button:focus {
  box-shadow: 0 0 0 0.2rem rgba(58, 89, 117, 0.25);
  border-color: var(--color-secondary-blue);
}

/* ========================================
   Game-specific Styles
   ======================================== */
.team-logo {
  max-height: 80px;
  width: auto;
}

.score-display {
  font-size: 1rem;
  font-weight: bold;
  color: var(--color-primary-dark);
}

/* ========================================
   Utilities
   ======================================== */
.text-primary { color: var(--color-primary-dark) !important; }
.text-secondary { color: var(--color-secondary-blue) !important; }
.text-muted { color: var(--color-text-muted) !important; }

.bg-light { background: linear-gradient(135deg, #E8EEF2 0%, #F0F5F8 100%) !important; }

code {
  background-color: #f8f9fa;
  padding: 0.125rem 0.375rem;
  border-radius: 0.25rem;
}

.loading {
  opacity: 0.6;
  pointer-events: none;
}

/* ========================================
   Tables
   ======================================== */
.table {
  font-size: 0.875rem;
}

.table th,
.table td {
  padding: 0.5rem 0.75rem;
}

/* ========================================
   Responsive
   ======================================== */
@media (max-width: 768px) {
  h1 { font-size: 1.5rem; }
  h2 { font-size: 1.25rem; }
  h3 { font-size: 1.1rem; }

  .team-logo {
    max-height: 50px;
  }

  .score-display {
    font-size: 0.875rem;
  }

  .btn {
    padding: 6px 12px;
  }

  /* Stacked table for mobile */
  .table-stacked thead {
    display: none;
  }

  .table-stacked tbody tr {
    display: flex;
    flex-wrap: wrap;
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding: 0.5rem 0.75rem;
  }

  .table-stacked tbody tr:last-child {
    border-bottom: none;
  }


  .table-stacked tbody tr {
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }

  /* Disable ALL hover effects on mobile - override Bootstrap */
  .table-hover tbody tr:hover,
  .table-hover-pulse tbody tr:hover,
  .table-stacked tbody tr:hover,
  .table-stacked.table-hover tbody tr:hover,
  .table-stacked.table-hover-pulse tbody tr:hover {
    background-color: transparent !important;
    animation: none !important;
  }

  .table-hover > tbody > tr:hover > * {
    --bs-table-bg-state: transparent !important;
    --bs-table-accent-bg: transparent !important;
    background-color: transparent !important;
  }

  .table-stacked tbody td {
    padding: 0;
    border: none;
  }

  .table-stacked tbody td::before {
    display: none;
  }

  /* Line 1: Name + badges */
  .table-stacked tbody td.mobile-line1 {
    flex: 0 0 100%;
    display: flex !important;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.25rem;
  }

  .table-stacked tbody td.mobile-line1 .mobile-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--color-primary-dark);
  }

  /* Line 2: Contact details */
  .table-stacked tbody td.mobile-line2 {
    flex: 0 0 100%;
    display: flex !important;
    flex-wrap: wrap;
    gap: 0 0.5rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
  }

  /* Each contact item stays together (no mid-word breaks) */
  .table-stacked tbody td.mobile-line2 .contact-item,
  .table-stacked tbody td.mobile-line3 .contact-item {
    white-space: nowrap;
  }

  /* Line 3: Additional details (for pages that need it) */
  .table-stacked tbody td.mobile-line3 {
    flex: 0 0 100%;
    display: flex !important;
    flex-wrap: wrap;
    gap: 0 0.5rem;
    font-size: 0.8rem;
    color: var(--color-text-muted);
  }

  /* Hide individual cells on mobile - we use consolidated cells instead */
  .table-stacked tbody td.mobile-hide {
    display: none !important;
  }
}

/* Desktop: hide mobile-specific cells, show regular cells */
@media (min-width: 769px) {
  .table-stacked tbody td.mobile-line1,
  .table-stacked tbody td.mobile-line2,
  .table-stacked tbody td.mobile-line3 {
    display: none !important;
  }

  .table-stacked tbody td.mobile-hide {
    display: table-cell !important;
  }
}
