/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #3B82F6;
    --primary-dark: #2563EB;
    --primary-light: #DBEAFE;
    --success: #10B981;
    --warning: #F59E0B;
    --danger: #EF4444;
    --purple: #8B5CF6;
    --sidebar-bg: #F8FAFC;
    --sidebar-text: #64748B;
    --sidebar-active: #3B82F6;
    --bg: #F1F5F9;
    --card-bg: #FFFFFF;
    --text: #1E293B;
    --text-muted: #64748B;
    --border: #E2E8F0;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 4px 6px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
}

/* Login Screen */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1E3A5F 0%, #0F172A 100%);
}

.login-box {
    background: var(--card-bg);
    border-radius: 16px;
    padding: 48px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.logo-icon {
    margin-bottom: 16px;
}

.login-logo h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
}

.login-logo .subtitle {
    color: var(--text-muted);
    font-size: 14px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    font-size: 15px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.error-text {
    color: var(--danger);
    font-size: 14px;
    margin-top: 12px;
    text-align: center;
}

.forgot-link {
    display: block;
    text-align: center;
    margin-top: 16px;
    color: var(--primary);
    text-decoration: none;
    font-size: 14px;
}

.forgot-link:hover {
    text-decoration: underline;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 600;
    border-radius: 8px;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-primary:hover {
    background: #334155;
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.btn-outline:hover {
    background: var(--bg);
}

.btn-full {
    width: 100%;
}

.btn-sm {
    padding: 8px 16px;
    font-size: 13px;
}

.btn-icon {
    width: 18px;
    height: 18px;
}

/* App Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.logo-icon.small svg {
    width: 32px;
    height: 32px;
}

.logo-text {
    display: flex;
    flex-direction: column;
}

.logo-text .brand {
    font-weight: 700;
    font-size: 15px;
    color: var(--text);
}

.logo-text .portal-type {
    font-size: 12px;
    color: var(--text-muted);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 12px;
    margin-bottom: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px;
    border-radius: 8px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    margin-bottom: 4px;
}

.nav-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.nav-item.active {
    background: var(--primary-light);
    color: var(--primary);
}

.nav-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 240px;
    padding: 24px 32px;
    min-height: 100vh;
}

/* Page */
.page {
    display: none;
}

.page.active {
    display: block;
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 24px;
}

.page-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
}

.title-icon {
    width: 24px;
    height: 24px;
    color: var(--text-muted);
}

.page-subtitle {
    font-size: 18px;
    font-weight: 600;
    color: var(--text);
    margin-top: 8px;
}

.page-desc {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow);
}

.stat-label {
    display: block;
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-icon svg {
    width: 24px;
    height: 24px;
}

.stat-icon.blue {
    background: var(--primary-light);
    color: var(--primary);
}

.stat-icon.green {
    background: #D1FAE5;
    color: var(--success);
}

.stat-icon.purple {
    background: #EDE9FE;
    color: var(--purple);
}

.stat-icon.red {
    background: #FEE2E2;
    color: var(--danger);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 16px;
}

/* Activity List */
.activity-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.activity-item {
    display: flex;
    flex-direction: column;
}

.activity-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.activity-meta {
    font-size: 13px;
    color: var(--text-muted);
}

/* Quick Actions */
.quick-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.action-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s;
}

.action-item:hover {
    border-color: var(--primary);
    background: var(--primary-light);
}

.action-content {
    display: flex;
    flex-direction: column;
}

.action-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.action-desc {
    font-size: 13px;
    color: var(--primary);
}

.action-arrow {
    width: 20px;
    height: 20px;
    color: var(--text-muted);
}

/* Teams Grid */
.teams-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.team-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.team-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.team-name {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
}

.team-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    text-transform: lowercase;
}

.team-badge.active {
    background: var(--text);
    color: white;
}

.team-badge.inactive {
    background: var(--bg);
    color: var(--text-muted);
}

.team-info {
    margin-bottom: 16px;
}

.team-info-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.team-info-row svg {
    width: 16px;
    height: 16px;
}

.team-info-row.highlight {
    color: var(--primary);
}

.team-meta {
    display: flex;
    gap: 24px;
    margin-bottom: 20px;
}

.team-meta-item {
    display: flex;
    flex-direction: column;
}

.team-meta-label {
    font-size: 12px;
    color: var(--text-muted);
}

.team-meta-value {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.team-actions {
    display: flex;
    gap: 8px;
}

.team-actions .btn {
    flex: 1;
}

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

.btn-view:hover {
    background: var(--primary-dark);
}

.btn-edit {
    background: var(--card-bg);
    border: 1px solid var(--border);
    color: var(--text);
}

.btn-edit:hover {
    background: var(--bg);
}

/* Filters Row */
.filters-row {
    display: flex;
    gap: 20px;
    margin-bottom: 24px;
}

.search-box,
.filter-box {
    flex: 1;
}

.search-box label,
.filter-box label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.search-box input,
.filter-box select {
    width: 100%;
    padding: 12px 16px;
    font-size: 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text);
}

/* Players Grid */
.players-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
}

.player-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
}

.player-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.player-name {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.player-jersey {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    background: var(--bg);
    padding: 4px 10px;
    border-radius: 4px;
}

.player-info {
    margin-bottom: 16px;
}

.player-info-row {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.player-info-row span {
    color: var(--primary);
}

.player-actions {
    display: flex;
    gap: 8px;
}

.player-actions .btn {
    flex: 1;
}

/* Leaderboard */
.tab-buttons {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
}

.tab-btn {
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--card-bg);
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.tab-btn.active {
    background: var(--text);
    color: white;
    border-color: var(--text);
}

.leaderboard-tab {
    display: none;
}

.leaderboard-tab.active {
    display: block;
}

.section-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.section-desc {
    font-size: 14px;
    color: var(--text-muted);
    margin-bottom: 20px;
}

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

.ranking-item {
    display: flex;
    align-items: center;
    padding: 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    gap: 16px;
}

.rank-badge {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
}

.rank-badge.gold {
    color: #F59E0B;
}

.rank-badge.silver {
    color: #94A3B8;
}

.rank-badge.bronze {
    color: #CD7F32;
}

.rank-badge svg {
    width: 24px;
    height: 24px;
}

.ranking-info {
    flex: 1;
}

.ranking-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
}

.ranking-meta {
    font-size: 13px;
    color: var(--text-muted);
}

.ranking-meta span {
    color: var(--primary);
}

.ranking-stats {
    display: flex;
    gap: 24px;
    align-items: center;
}

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

.ranking-stat-value {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
}

.ranking-stat-label {
    font-size: 11px;
    color: var(--text-muted);
}

.ranking-change {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    background: #D1FAE5;
    color: var(--success);
}

.ranking-change.negative {
    background: #FEE2E2;
    color: var(--danger);
}

/* Plays Table */
.plays-header {
    margin-bottom: 20px;
}

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

.plays-table th,
.plays-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.plays-table th {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.plays-table td {
    font-size: 14px;
    color: var(--text);
}

.situation-id {
    font-family: monospace;
    font-size: 12px;
    background: var(--bg);
    padding: 4px 8px;
    border-radius: 4px;
    color: var(--text-muted);
}

.play-name {
    color: var(--primary);
    font-weight: 500;
}

.hit-type-badge {
    font-size: 11px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 4px;
    text-transform: lowercase;
}

.hit-type-badge.ground-ball {
    background: #FEF3C7;
    color: #92400E;
}

.hit-type-badge.fly-ball {
    background: #DBEAFE;
    color: #1E40AF;
}

.hit-type-badge.line-drive {
    background: #D1FAE5;
    color: #065F46;
}

.hit-type-badge.pop-up {
    background: #F3E8FF;
    color: #6B21A8;
}

.hit-type-badge.extra-base-hit {
    background: #FEE2E2;
    color: #991B1B;
}

.outs-indicator {
    display: flex;
    gap: 4px;
}

.out-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--border);
}

.out-dot.active {
    background: var(--text);
}

.runners-indicator {
    display: flex;
    align-items: center;
    gap: 2px;
}

.base-dot {
    width: 8px;
    height: 8px;
    transform: rotate(45deg);
    border: 1px solid var(--border);
    background: transparent;
}

.base-dot.occupied {
    background: var(--success);
    border-color: var(--success);
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
}

.modal-overlay.active {
    display: block;
}

.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: var(--card-bg);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.modal.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 700;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: var(--bg);
    border-radius: 8px;
    font-size: 20px;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-close:hover {
    background: var(--border);
}

.modal-body {
    padding: 24px;
}

/* Stats Modal */
.stats-grid-modal {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-box {
    background: var(--bg);
    padding: 16px;
    border-radius: 8px;
    text-align: center;
}

.stat-box-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
}

.stat-box-label {
    font-size: 12px;
    color: var(--text-muted);
}

.plays-history {
    margin-top: 24px;
}

.plays-history h4 {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 12px;
}

.play-history-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

/* Attention / Inactive Players Card */
.attention-card {
    border-left: 4px solid var(--warning);
    margin-top: 24px;
}

.card-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.title-icon-small {
    width: 18px;
    height: 18px;
    margin-right: 8px;
    vertical-align: middle;
}

.title-icon-small.warning {
    color: var(--warning);
}

.badge {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
}

.badge-warning {
    background: #FEF3C7;
    color: #92400E;
}

.card-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

.inactive-players-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.inactive-player-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #FFFBEB;
    border: 1px solid #FDE68A;
    border-radius: 8px;
    flex-wrap: wrap;
    gap: 8px;
}

.inactive-player-info {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 200px;
}

.inactive-player-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
}

.inactive-player-meta {
    font-size: 12px;
    color: var(--text-muted);
}

.inactive-player-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.inactive-player-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.status-tag {
    font-size: 11px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
}

.status-tag.not-registered {
    background: #FEE2E2;
    color: #991B1B;
}

.status-tag.never-logged-in {
    background: #FEF3C7;
    color: #92400E;
}

.status-tag.inactive {
    background: #E0E7FF;
    color: #3730A3;
}

.status-tag.escalated {
    background: #FCE7F3;
    color: #9D174D;
}

/* Action Buttons */
.btn-small {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s;
}

.btn-small:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-reminder {
    background: var(--primary-light);
    color: var(--primary-dark);
}

.btn-reminder:hover:not(:disabled) {
    background: var(--primary);
    color: white;
}

.btn-escalate {
    background: #FEE2E2;
    color: #991B1B;
}

.btn-escalate:hover:not(:disabled) {
    background: #EF4444;
    color: white;
}

/* Responsive */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .teams-grid,
    .players-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .main-content {
        margin-left: 0;
    }

    .stats-grid,
    .teams-grid,
    .players-grid {
        grid-template-columns: 1fr;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .filters-row {
        flex-direction: column;
    }
}

/* ============================================================ */
/* TOP BAR */
/* ============================================================ */

.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    margin: -24px -24px 24px -24px;
}

.top-bar-left {
    font-size: 14px;
    color: var(--text-muted);
}

.top-bar-right {
    display: flex;
    gap: 12px;
}

.btn-account {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

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

.btn-account svg {
    width: 16px;
    height: 16px;
}

/* ============================================================ */
/* ACCOUNT SETTINGS MODAL */
/* ============================================================ */

.modal-lg {
    width: 500px;
    max-width: 95%;
}

.settings-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--border);
    padding-bottom: 12px;
}

.settings-tab {
    padding: 8px 16px;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 14px;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s;
}

.settings-tab:hover {
    background: var(--surface-hover);
    color: var(--text);
}

.settings-tab.active {
    background: var(--primary);
    color: white;
}

.settings-tab-content {
    display: none;
}

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

.settings-tab-content input[readonly] {
    background: var(--surface);
    color: var(--text-muted);
    cursor: not-allowed;
}

#contact-save-btn-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

@media (max-width: 768px) {
    .top-bar {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
}