:root {
    --isotopes-red: #ED1C24;
    --isotopes-white: #FFFFFF;
    --isotopes-dark: #333333;
    --isotopes-accent: #004684;
}

* {
    box-sizing: border-box;
}

html, body {
    height: 100%;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
    margin: 0;
    padding: 0;
}

.page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding-bottom: 70px; /* Space for mobile nav */
    box-sizing: border-box;
}

.isotopes-header {
    background-color: var(--isotopes-red);
    color: var(--isotopes-white);
    padding: 1rem 0;
    text-align: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    z-index: 1000;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 0 1rem;
    box-sizing: border-box;
}

.logo-atom {
    animation: spin 5s linear infinite;
    transform-origin: center;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.isotopes-header h1 {
    margin: 0;
    font-weight: 800;
    letter-spacing: 2px;
    font-size: 1.5rem;
    outline: none;
}

/* Desktop Top Nav */
.desktop-nav {
    display: none;
    margin-left: 2rem;
    gap: 1.5rem;
}

.desktop-nav a {
    color: white;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    transition: all 0.3s;
}

.desktop-nav a:hover {
    background: rgba(255,255,255,0.1);
}

.desktop-nav a.active {
    color: white;
    font-weight: 800;
}

@media (min-width: 769px) {
    .isotopes-header {
        position: sticky;
        top: 0;
    }
    .header-content {
        justify-content: space-between;
        max-width: 1200px;
        margin: 0 auto;
        width: 100%;
    }
    .desktop-nav {
        display: flex;
    }
    .mobile-nav {
        display: none !important;
    }
    .page {
        padding-bottom: 0 !important;
    }
}

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

/* Mobile Nav */
.mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--isotopes-white);
    display: flex;
    justify-content: space-around;
    padding: 0.5rem 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
}

.mobile-nav a {
    text-decoration: none;
    color: var(--isotopes-dark);
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.8rem;
    transition: color 0.3s;
}

.mobile-nav a.active {
    color: var(--isotopes-red);
}

.nav-icon {
    font-size: 1.5rem;
    margin-bottom: 2px;
}

/* Cards */
.stat-card {
    background: var(--isotopes-white);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
    border: 1px solid #eee;
    animation: fadeIn 0.5s ease-out both;
}

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

.stat-item {
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--isotopes-red);
}

.stat-label {
    font-size: 0.8rem;
    color: #666;
    text-transform: uppercase;
}

/* Tables */
.table-container {
    overflow-x: auto;
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05);
}

.table-sm th, .table-sm td {
    padding: 12px 4px;
    font-size: 0.8rem;
    white-space: nowrap;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th {
    background-color: #f8f9fa;
    padding: 12px;
    text-align: center;
    font-size: 0.9rem;
    color: #666;
    border-bottom: 2px solid #eee;
}

td {
    padding: 12px;
    border-bottom: 1px solid #eee;
    text-align: center;
}

tbody tr:nth-child(even) {
    background-color: #f9f9f9;
}

tbody tr:hover {
    background-color: #f1f1f1;
}

tr:last-child td {
    border-bottom: none;
}

.player-name, .sticky-col {
    text-align: left !important;
    font-weight: bold;
}

.game-header-row {
    background-color: var(--isotopes-accent) !important;
    color: white;
    cursor: pointer;
    user-select: none;
}

.game-header-row th {
    background-color: transparent !important;
    color: white !important;
    font-weight: bold;
    border-bottom: none;
}

.game-summary-row {
    background-color: #e9ecef !important;
    font-weight: 800;
    border-top: 2px solid #ccc;
    color: #212529;
}

.game-summary-row td {
    font-weight: 800 !important;
    border-top: 2px solid #ccc !important;
}

.game-summary-row td.sticky-col {
    background-color: #e9ecef !important;
}

/* Box Score Cards */
.game-card {
    background: white;
    border-radius: 16px;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.08);
    border: 1px solid #e0e0e0;
    overflow: hidden;
    animation: fadeIn 0.5s ease-out both;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.game-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.12);
}

.game-card-header {
    padding: 1.25rem;
    cursor: pointer;
    background: #fff;
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 1.5rem;
    transition: background 0.2s;
}

.game-card-header:hover {
    background: #f8f9fa;
}

.game-info-left {
    display: flex;
    flex-direction: column;
}

.game-number-badge {
    background: var(--isotopes-accent);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: bold;
    width: fit-content;
    margin-bottom: 4px;
}

.game-date {
    font-size: 0.85rem;
    color: #666;
}

.game-matchup {
    display: flex;
    flex-direction: column;
}

.opponent-name {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--isotopes-dark);
}

.diamond-name {
    font-size: 0.85rem;
    color: #888;
}

.game-score-summary {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.score-value {
    font-size: 1.5rem;
    font-weight: 900;
    color: var(--isotopes-red);
}

.score-label {
    font-size: 0.7rem;
    color: #999;
    text-transform: uppercase;
}

.game-card-footer {
    background: #fcfcfc;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid #f0f0f0;
    display: flex;
    gap: 2rem;
    font-size: 0.85rem;
}

.footer-stat {
    display: flex;
    gap: 6px;
    color: #555;
}

.footer-stat-label {
    font-weight: bold;
    color: #888;
}

.game-card-detail {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease;
    opacity: 0;
    background: #fcfcfc;
}

.game-card-detail.expanded {
    max-height: 8000px;
    opacity: 1;
    border-top: 1px solid #eee;
}

.box-score-table-wrapper {
    overflow-x: auto;
    padding: 1rem;
}

.box-score-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: white;
    border-radius: 8px;
    border: 1px solid #eee;
}

.box-score-table th {
    background: #f8f9fa;
    position: sticky;
    top: 0;
    z-index: 10;
}

.box-score-table .sticky-col {
    position: sticky;
    left: 0;
    background: #f8f9fa;
    z-index: 20;
    border-right: 2px solid #eee;
}

.box-score-table td.sticky-col {
    background: white;
}

.box-score-table tr:nth-child(even) td.sticky-col {
    background: #f9f9f9;
}

.box-score-table tr:hover td.sticky-col {
    background: #f1f1f1;
}

.box-score-table tr:hover {
    background-color: #f1f1f1;
}

/* Mobile Box Score Cards */
.mobile-player-grid {
    display: none;
    padding: 1rem;
    gap: 1rem;
    grid-template-columns: 1fr;
}

.mobile-player-card {
    background: white;
    border-radius: 12px;
    padding: 1rem;
    border: 1px solid #eee;
    box-shadow: 0 2px 8px rgba(0,0,0,0.03);
}

.mobile-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid #f0f0f0;
    padding-bottom: 0.5rem;
    margin-bottom: 0.75rem;
}

.mobile-card-name {
    font-weight: 800;
    color: var(--isotopes-accent);
}

.rank-badge {
    background: #f0f0f0;
    color: #666;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    margin-right: 8px;
    font-weight: bold;
    border: 1px solid #ddd;
}

.m-stat.active {
    background: #fff9f9;
    border-radius: 8px;
    border: 1px solid var(--isotopes-red);
    padding: 2px;
}

.m-stat.active .m-stat-val {
    color: var(--isotopes-red);
}

.mobile-card-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
}

.m-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.m-stat-val {
    font-weight: bold;
    font-size: 1.1rem;
}

.m-stat-label {
    font-size: 0.65rem;
    color: #999;
    text-transform: uppercase;
}

@media (max-width: 768px) {
    .box-score-table-wrapper {
        display: none;
    }
    .mobile-player-grid {
        display: grid;
    }
}

/* Player Leaderboard Enhancements */
.leader-highlights {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.leader-card {
    background: linear-gradient(135deg, var(--isotopes-accent), #002d5a);
    color: white;
    padding: 1.5rem;
    border-radius: 16px;
    text-align: center;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    position: relative;
    overflow: hidden;
    animation: fadeIn 0.5s ease-out both;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.leader-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 30px rgba(0,0,0,0.12);
}

.leader-card::after {
    content: "🏆";
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 4rem;
    opacity: 0.1;
}

.leader-category {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0.8;
}

.leader-name {
    font-size: 1.5rem;
    font-weight: 900;
    margin: 0.5rem 0;
}

.leader-value {
    font-size: 2rem;
    font-weight: 300;
    display: inline-block;
    animation: pulse 4s ease-in-out infinite;
}

.active-sort-col {
    font-weight: bold;
}

.sortable-header {
    position: relative;
    padding-left: 20px !important;
    padding-right: 20px !important;
    cursor: pointer;
    white-space: nowrap;
    text-align: center;
    transition: background-color 0.2s;
}

.sortable-header:hover {
    background-color: #f0f0f0 !important;
}

.sort-icon {
    display: inline-block;
    margin-left: 4px;
    width: 12px;
    text-align: center;
    color: var(--isotopes-accent);
    font-weight: bold;
}

.group-divider {
    border-left: 2px solid #ddd !important;
}

/* Form Styling */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: bold;
    color: var(--isotopes-dark);
}

.form-control {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 1rem;
}

.btn-primary {
    background-color: var(--isotopes-red);
    color: white;
    border: none;
    padding: 1rem 2rem;
    border-radius: 8px;
    font-weight: bold;
    cursor: pointer;
    width: 100%;
    font-size: 1rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.admin-player-card {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.admin-player-name {
    font-weight: bold;
    font-size: 1.1rem;
    color: var(--isotopes-red);
    margin-bottom: 0.5rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 0.3rem;
}

.admin-stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.admin-stat-input {
    display: flex;
    flex-direction: column;
}

.admin-stat-input label {
    font-size: 0.7rem;
    color: #666;
    margin-bottom: 2px;
}

.admin-stat-input input {
    padding: 0.3rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    text-align: center;
}

.admin-stat-input input.readonly {
    background-color: #f0f0f0;
}

/* View Switcher */
.view-switcher {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.75rem 0;
}

@media (min-width: 769px) {
    .view-switcher {
        overflow: visible;
    }
}

.view-btn {
    background: #fff;
    border: 1px solid #ddd;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    white-space: nowrap;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.view-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

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

.view-btn.active {
    background-color: var(--isotopes-accent);
    color: white;
    border-color: var(--isotopes-accent);
    font-weight: bold;
}

.view-fade-in {
    animation: fadeIn 0.4s ease-out both;
}

@keyframes skeletonPulse {
    0% { background-color: #eee; }
    50% { background-color: #f2f2f2; }
    100% { background-color: #eee; }
}

.skeleton {
    animation: skeletonPulse 1.8s ease-in-out infinite;
    border-radius: 4px;
    background-color: #eee;
    display: inline-block;
}

/* Mobile Sort Modal */
.sort-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid #eee;
    padding-bottom: 1rem;
}

.sort-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.sort-option {
    padding: 0.75rem;
    border: 1px solid #eee;
    border-radius: 12px;
    text-align: center;
    font-size: 0.9rem;
    background: #f9f9f9;
}

.sort-option.active {
    background: var(--isotopes-accent);
    color: white;
    border-color: var(--isotopes-accent);
    font-weight: bold;
}

/* Visibility Helpers */
@media (min-width: 769px) {
    .mobile-only {
        display: none !important;
    }
}

@media (max-width: 768px) {
    .desktop-only {
        display: none !important;
    }
}

/* Blazor Error UI */
#blazor-error-ui {
    background: lightyellow;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* Animations */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

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

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.sort-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    display: flex;
    align-items: flex-end;
    animation: fadeIn 0.3s ease-out;
}

.sort-modal {
    background: white;
    width: 100%;
    border-radius: 24px 24px 0 0;
    padding: 1.5rem;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.expand-icon {
    display: inline-block;
    width: 20px;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.collapsed .expand-icon {
    transform: rotate(-90deg);
}

.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: #999;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    display: block;
}

/* Spinner */
.spinner-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 5rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(0, 0, 0, 0.1);
    border-top-color: var(--isotopes-red);
    border-radius: 50%;
    animation: spinnerRotation 0.8s linear infinite;
}

/* Management Sub Nav */
.management-sub-nav {
    background-color: #f1f1f1;
    border-bottom: 1px solid #ddd;
    padding: 0.5rem 0;
    position: sticky;
    top: 70px; /* Exactly matches header height */
    z-index: 999;
}

.sub-nav-content {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    gap: 2rem;
    padding: 0 1rem;
}

.sub-nav-content a {
    color: #555;
    text-decoration: none;
    font-weight: 600;
    font-size: 0.9rem;
    padding: 0.25rem 0;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.sub-nav-content a:hover {
    color: var(--isotopes-red);
}

.sub-nav-content a.active {
    color: var(--isotopes-red);
    border-bottom-color: var(--isotopes-red);
}

/* Hamburger Menu */
.hamburger-btn {
    font-size: 1.5rem;
    cursor: pointer;
    background: none;
    border: none;
    color: white;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    animation: fadeIn 0.3s ease-out;
}

.mobile-drawer {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    background: white;
    z-index: 2001;
    display: flex;
    flex-direction: column;
    box-shadow: 5px 0 15px rgba(0,0,0,0.1);
    animation: slideInLeft 0.3s ease-out;
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

.drawer-header {
    background: var(--isotopes-red);
    color: white;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 0;
}

.drawer-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    text-decoration: none;
    color: var(--isotopes-dark);
    font-weight: 600;
    border-bottom: 1px solid #eee;
    transition: background 0.2s;
}

.drawer-item:active {
    background: #f5f5f5;
}

.drawer-item.active {
    color: var(--isotopes-red);
}

.drawer-footer {
    padding: 1rem;
    border-top: 1px solid #eee;
}

@keyframes spinnerRotation {
    to { transform: rotate(360deg); }
}

/* Selectable Button Checkboxes */
.selectable-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)) !important;
    grid-auto-rows: 1fr !important;
    gap: 0.75rem !important;
    width: 100% !important;
}

.selectable-item {
    position: relative !important;
    display: flex !important;
    flex-direction: column !important;
}

.selectable-item input[type="checkbox"] {
    position: absolute !important;
    opacity: 0 !important;
    cursor: pointer !important;
    height: 0 !important;
    width: 0 !important;
    margin: 0 !important;
}

.selectable-label {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0.75rem 50px !important;
    background: #fff !important;
    border: 2px solid #eee !important;
    border-radius: 12px !important;
    cursor: pointer !important;
    font-weight: 600 !important;
    text-align: center !important;
    transition: all 0.2s !important;
    user-select: none !important;
    font-size: 0.85rem !important;
    margin: 0 !important;
    min-height: 50px !important;
    height: 100% !important;
    width: 100% !important;
    position: relative !important;
}

.selectable-label::before {
    position: absolute !important;
    left: 8px !important;
    content: '\2610' !important;
    font-size: 1.2rem !important;
    color: #ccc !important;
    font-weight: normal !important;
    transition: all 0.2s !important;
}

.selectable-item input[type="checkbox"]:checked + .selectable-label {
    background: var(--isotopes-accent) !important;
    border-color: var(--isotopes-accent) !important;
    color: white !important;
    box-shadow: 0 4px 12px rgba(0, 70, 132, 0.3) !important;
}

.selectable-item input[type="checkbox"]:checked + .selectable-label::before {
    content: '\2611' !important;
    color: white !important;
}

.selectable-label:hover {
    border-color: var(--isotopes-accent) !important;
}

/* Numeric Input Refinements */
input[type="number"] {
    text-align: center !important;
    -moz-appearance: textfield !important;
}

input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none !important;
    margin: 0 !important;
}
