/* Custom CSS for Golf League Manager */

/* Golf-Themed Color Palette */
:root {
    /* Primary Colors - Golf Course Greens */
    --golf-green-dark: #1b5e20;
    --golf-green: #2e7d32;
    --golf-green-light: #4caf50;

    /* Secondary Colors - Sand & Earth Tones */
    --golf-sand: #d4a574;
    --golf-sand-light: #e8c9a1;
    --golf-earth: #8d6e63;

    /* Accent Colors - Tournament Gold */
    --golf-gold: #c8a962;
    --golf-gold-light: #ddc184;

    /* Background Colors */
    --golf-bg-cream: #faf8f5;
    --golf-bg-light: #f5f7f6;
    --golf-bg-white: #ffffff;

    /* Text Colors */
    --golf-text-dark: #2c3e50;
    --golf-text-medium: #546e7a;
    --golf-text-light: #90a4ae;

    /* Status Colors */
    --golf-success: #4caf50;
    --golf-warning: #ff9800;
    --golf-danger: #f44336;
    --golf-info: #29b6f6;

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.15);

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
}

/* Dark Mode Colors */
[data-theme="dark"] {
    /* Dark Mode Backgrounds */
    --golf-bg-cream: #1a1a1a;
    --golf-bg-light: #2d2d2d;
    --golf-bg-white: #3a3a3a;

    /* Dark Mode Text */
    --golf-text-dark: #e0e0e0;
    --golf-text-medium: #b0b0b0;
    --golf-text-light: #808080;

    /* Adjust greens for dark mode */
    --golf-green-dark: #66bb6a;
    --golf-green: #4caf50;
    --golf-green-light: #81c784;

    /* Shadows for dark mode */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 16px rgba(0, 0, 0, 0.5);
}

/* Dark mode body styles */
[data-theme="dark"] body {
    background-color: var(--golf-bg-cream);
    color: var(--golf-text-dark);
}

[data-theme="dark"] .card {
    background-color: var(--golf-bg-white);
    color: var(--golf-text-dark);
    border-color: #555;
}

[data-theme="dark"] .card-header {
    background-color: var(--golf-bg-light);
    color: var(--golf-text-dark);
    border-bottom-color: #555;
}

[data-theme="dark"] .table {
    color: var(--golf-text-dark);
}

[data-theme="dark"] .table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .table-hover tbody tr:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

[data-theme="dark"] .navbar {
    background-color: var(--golf-bg-white) !important;
}

[data-theme="dark"] .modal-content {
    background-color: var(--golf-bg-white);
    color: var(--golf-text-dark);
}

[data-theme="dark"] .modal-header {
    border-bottom-color: #555;
}

[data-theme="dark"] .modal-footer {
    border-top-color: #555;
}

[data-theme="dark"] input,
[data-theme="dark"] select,
[data-theme="dark"] textarea {
    background-color: var(--golf-bg-light);
    color: var(--golf-text-dark);
    border-color: #555;
}

[data-theme="dark"] input:focus,
[data-theme="dark"] select:focus,
[data-theme="dark"] textarea:focus {
    background-color: var(--golf-bg-white);
    border-color: var(--golf-green);
}

[data-theme="dark"] .form-control:disabled {
    background-color: #2a2a2a;
    color: #666;
}

[data-theme="dark"] hr {
    border-color: #555;
}

/* Dark mode toggle button */
.dark-mode-toggle {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    transition: transform 0.3s ease;
}

.dark-mode-toggle:hover {
    transform: scale(1.1);
}

/* General styling */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--golf-bg-cream);
    background-image:
        radial-gradient(circle at 20px 20px, rgba(46, 125, 50, 0.03) 1px, transparent 1px),
        radial-gradient(circle at 60px 60px, rgba(46, 125, 50, 0.03) 1px, transparent 1px);
    background-size: 80px 80px;
    background-position: 0 0, 40px 40px;
    color: var(--golf-text-dark);
    line-height: 1.6;
}

/* Typography System */
h1 {
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
    color: var(--golf-green-dark);
    margin-bottom: 1.5rem;
    line-height: 1.2;
}

h2 {
    font-size: 2rem;
    font-weight: 600;
    letter-spacing: -0.25px;
    color: var(--golf-green-dark);
    margin-bottom: 1.25rem;
    line-height: 1.3;
}

h3 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--golf-green);
    margin-bottom: 1rem;
    line-height: 1.3;
}

h4 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--golf-text-dark);
    margin-bottom: 0.875rem;
    line-height: 1.4;
}

h5 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--golf-text-dark);
    margin-bottom: 0.75rem;
    line-height: 1.4;
}

h6 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--golf-text-medium);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    line-height: 1.4;
}

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

.text-muted {
    color: var(--golf-text-light) !important;
}

/* Card styling */
.card {
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
    border: 1px solid rgba(46, 125, 50, 0.1);
    background-color: var(--golf-bg-white);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.card-header {
    background: linear-gradient(135deg, var(--golf-bg-light) 0%, var(--golf-bg-cream) 100%);
    border-bottom: 3px solid var(--golf-green);
    font-weight: 600;
    border-top-left-radius: var(--radius-lg);
    border-top-right-radius: var(--radius-lg);
    color: var(--golf-text-dark);
    padding: 1rem 1.25rem;
}

/* Navbar */
.navbar {
    box-shadow: var(--shadow-md);
    backdrop-filter: blur(10px);
    background-color: rgba(255, 255, 255, 0.98) !important;
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--golf-green-dark) !important;
}

.navbar-toggler {
    border: 2px solid var(--golf-green);
    padding: 0.5rem 0.75rem;
}

.navbar-toggler:focus {
    box-shadow: 0 0 0 0.2rem rgba(46, 125, 50, 0.25);
}

.navbar-toggler-icon {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 30 30'%3e%3cpath stroke='%232e7d32' stroke-linecap='round' stroke-miterlimit='10' stroke-width='2' d='M4 7h22M4 15h22M4 23h22'/%3e%3c/svg%3e") !important;
}

/* Tables */
table {
    background-color: white;
    border-radius: var(--radius-md);
    overflow: hidden;
}

table thead th {
    background-color: var(--golf-green);
    color: white;
    border: none;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.5px;
    padding: 1rem 0.75rem;
    position: sticky;
    top: 0;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

table tbody tr {
    transition: all 0.2s ease;
}

table tbody tr:hover {
    background-color: var(--golf-bg-light) !important;
    transform: scale(1.01);
    box-shadow: 0 2px 8px rgba(46, 125, 50, 0.1);
}

table tbody tr:nth-child(even) {
    background-color: rgba(250, 248, 245, 0.5);
}

table tbody td {
    padding: 0.875rem 0.75rem;
    vertical-align: middle;
    border-color: rgba(46, 125, 50, 0.08);
}

/* Highlighted table rows */
.table-success {
    background-color: rgba(76, 175, 80, 0.15) !important;
    border-left: 4px solid var(--golf-success);
}

.table-info {
    background-color: rgba(41, 182, 246, 0.12) !important;
    border-left: 4px solid var(--golf-info);
}

.table-warning {
    background-color: rgba(200, 169, 98, 0.15) !important;
    border-left: 4px solid var(--golf-gold);
}

/* Buttons */
.btn {
    border-radius: var(--radius-md);
    font-weight: 600;
    padding: 0.625rem 1.25rem;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
    border: none;
    text-transform: uppercase;
    font-size: 0.875rem;
    letter-spacing: 0.5px;
}

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

.btn:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.btn-primary {
    background: linear-gradient(135deg, var(--golf-green) 0%, var(--golf-green-dark) 100%);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--golf-green-dark) 0%, var(--golf-green) 100%);
}

.btn-success {
    background: linear-gradient(135deg, var(--golf-success) 0%, #388e3c 100%);
}

.btn-success:hover {
    background: linear-gradient(135deg, #388e3c 0%, var(--golf-success) 100%);
}

.btn-danger {
    background: linear-gradient(135deg, var(--golf-danger) 0%, #d32f2f 100%);
}

.btn-danger:hover {
    background: linear-gradient(135deg, #d32f2f 0%, var(--golf-danger) 100%);
}

.btn-info {
    background: linear-gradient(135deg, var(--golf-info) 0%, #0288d1 100%);
}

.btn-info:hover {
    background: linear-gradient(135deg, #0288d1 0%, var(--golf-info) 100%);
}

.btn-warning {
    background: linear-gradient(135deg, var(--golf-warning) 0%, #f57c00 100%);
}

.btn-warning:hover {
    background: linear-gradient(135deg, #f57c00 0%, var(--golf-warning) 100%);
}

.btn-lg {
    padding: 0.875rem 1.5rem;
    font-size: 1rem;
}

/* Forms */
.form-label {
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.form-control, .form-select {
    border-radius: 6px;
}

/* Mobile responsive */
@media (max-width: 768px) {
    /* Container spacing */
    .container {
        padding-left: 10px;
        padding-right: 10px;
    }

    /* Typography scaling */
    h1 {
        font-size: 1.75rem;
        letter-spacing: -0.25px;
    }

    h2 {
        font-size: 1.5rem;
    }

    h3 {
        font-size: 1.25rem;
    }

    /* Touch-friendly buttons - minimum 44px height */
    .btn {
        min-height: 44px;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    .btn-lg {
        min-height: 48px;
        font-size: 1rem;
        padding: 0.875rem 1.25rem;
    }

    .btn-sm {
        min-height: 38px;
        padding: 0.5rem 0.75rem;
    }

    /* Card adjustments */
    .card {
        margin-bottom: 1rem;
        border-radius: var(--radius-md);
    }

    .card-header {
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }

    .card-body {
        padding: 1rem;
    }

    /* Table responsiveness */
    table {
        font-size: 0.875rem;
    }

    table thead th {
        padding: 0.75rem 0.5rem;
        font-size: 0.75rem;
    }

    table tbody td {
        padding: 0.75rem 0.5rem;
    }

    /* Form elements - larger touch targets */
    .form-control,
    .form-select {
        min-height: 44px;
        font-size: 1rem;
        padding: 0.625rem 0.75rem;
    }

    .form-label {
        font-size: 0.9rem;
        margin-bottom: 0.375rem;
    }

    /* Navigation adjustments */
    .navbar-brand {
        font-size: 1.1rem;
    }

    .navbar-toggler {
        min-height: 44px;
        min-width: 44px;
    }

    .navbar-collapse {
        background-color: var(--golf-bg-white);
        padding: 1rem;
        margin: 0.5rem -1rem -0.5rem;
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-sm);
    }

    .navbar-nav {
        padding: 0.5rem 0;
        width: 100%;
    }

    .nav-item {
        width: 100%;
    }

    .nav-link {
        padding: 1rem 1.25rem !important;
        min-height: 48px;
        display: flex;
        align-items: center;
        border-radius: var(--radius-sm);
        margin-bottom: 0.25rem;
        font-size: 1rem;
    }

    .nav-link:hover,
    .nav-link:active {
        background-color: var(--golf-bg-light);
    }

    /* Disable underline animation on mobile */
    .nav-link::after {
        display: none;
    }

    /* Reduce spacing */
    .mb-3 {
        margin-bottom: 0.75rem !important;
    }

    .mb-4 {
        margin-bottom: 1rem !important;
    }

    .mt-3 {
        margin-top: 0.75rem !important;
    }

    .mt-4 {
        margin-top: 1rem !important;
    }

    /* Stats leaders mobile */
    .stats-leader {
        padding: 0.625rem;
        font-size: 0.9rem;
    }

    /* Dashboard cards */
    .dashboard-card {
        margin-bottom: 1rem;
    }

    /* Score entry container */
    #player-scores-container .row {
        padding: 0.5rem;
        margin-bottom: 0.375rem;
    }
}

/* Extra small devices (phones in portrait) */
@media (max-width: 576px) {
    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    .card-header {
        font-size: 0.875rem;
    }

    /* Stack table cells for very small screens */
    table {
        font-size: 0.8rem;
    }

    table thead th,
    table tbody td {
        padding: 0.5rem 0.375rem;
    }

    /* Full width buttons on small screens */
    .btn-block-mobile {
        width: 100%;
        display: block;
        margin-bottom: 0.5rem;
    }
}

/* Score entry specific */
#player-scores-container .row {
    background-color: #f8f9fa;
    padding: 0.75rem;
    border-radius: 6px;
    margin-bottom: 0.5rem;
}

/* Dashboard cards */
.dashboard-card {
    transition: transform 0.2s;
}

.dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* Stats leaders */
.stats-leader {
    padding: 0.5rem;
    background-color: #fef8e7;
    border-left: 4px solid var(--golf-gold);
    margin-bottom: 0.5rem;
}

/* Animations and Transitions */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes slideInFromLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

/* Apply fade-in to main content */
#page-content > div {
    animation: fadeIn 0.4s ease-out;
}

/* Smooth transitions for interactive elements */
a, button, input, select, textarea {
    transition: all 0.2s ease;
}

/* Form inputs hover and focus states */
.form-control:hover {
    border-color: var(--golf-green-light);
}

.form-control:focus {
    border-color: var(--golf-green);
    box-shadow: 0 0 0 0.2rem rgba(46, 125, 50, 0.15);
}

.form-select:hover {
    border-color: var(--golf-green-light);
}

.form-select:focus {
    border-color: var(--golf-green);
    box-shadow: 0 0 0 0.2rem rgba(46, 125, 50, 0.15);
}

/* Loading states */
.loading {
    text-align: center;
    padding: 2rem;
    color: var(--golf-text-medium);
    animation: pulse 2s ease-in-out infinite;
}

/* Alert animations */
.alert {
    animation: slideInFromLeft 0.3s ease-out;
}

/* Nav link hover effects */
.nav-link {
    transition: all 0.2s ease;
    position: relative;
    color: var(--golf-text-dark) !important;
    font-weight: 500;
}

.nav-link:hover {
    transform: translateY(-1px);
    color: var(--golf-green) !important;
}

.nav-link::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: var(--golf-gold);
    transition: all 0.3s ease;
    transform: translateX(-50%);
}

.nav-link:hover::after {
    width: 80%;
}

/* ==================== PWA ENHANCEMENTS ==================== */

/* PWA Mode Specific Styles */
body.pwa-mode {
    /* Add safe area padding for notched devices (iPhone X+) */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* iOS PWA: Remove bounce effect */
body.pwa-mode {
    overscroll-behavior-y: contain;
}

/* Disable text selection on buttons for better mobile feel */
.btn, button {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Better touch feedback */
.btn:active, button:active, a.nav-link:active {
    opacity: 0.7;
}

/* Disable pull-to-refresh for PWA */
body.pwa-mode {
    overscroll-behavior-y: none;
}

/* Improve touch scrolling */
* {
    -webkit-overflow-scrolling: touch;
}

/* Better focus states for keyboard navigation */
*:focus {
    outline: 2px solid var(--golf-green);
    outline-offset: 2px;
}

.btn:focus, .form-control:focus, .form-select:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.25);
}

/* Offline indicator */
.offline-indicator {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--golf-warning);
    color: white;
    text-align: center;
    padding: 0.5rem;
    font-weight: 600;
    z-index: 9999;
    transform: translateY(-100%);
    transition: transform 0.3s ease;
}

.offline-indicator.show {
    transform: translateY(0);
}

/* Install prompt banner */
.install-prompt {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(135deg, var(--golf-green) 0%, var(--golf-green-dark) 100%);
    color: white;
    padding: 1rem;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.install-prompt.show {
    transform: translateY(0);
}

.install-prompt .btn-close {
    background-color: rgba(255, 255, 255, 0.3);
}

/* Score entry optimizations for mobile */
@media (max-width: 768px) {
    /* Larger touch targets for score inputs */
    #player-scores-container input[type="number"],
    #player-scores-container select {
        min-height: 48px;
        font-size: 1.1rem;
    }

    /* Better spacing for score entry rows */
    #player-scores-container .row {
        padding: 1rem;
        margin-bottom: 0.75rem;
        border: 1px solid rgba(46, 125, 50, 0.15);
    }

    /* Sticky submit button */
    .score-submit-container {
        position: sticky;
        bottom: 0;
        background: white;
        padding: 1rem;
        box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
        z-index: 100;
    }

    /* Full width submit on mobile */
    .score-submit-container .btn {
        width: 100%;
        min-height: 56px;
        font-size: 1.1rem;
    }
}

/* Landscape orientation optimizations */
@media (max-width: 896px) and (orientation: landscape) {
    /* Reduce vertical spacing in landscape */
    .card {
        margin-bottom: 0.75rem;
    }

    .card-header {
        padding: 0.5rem 1rem;
    }

    .card-body {
        padding: 0.75rem;
    }

    h1 {
        font-size: 1.5rem;
        margin-bottom: 0.75rem;
    }

    h2 {
        font-size: 1.25rem;
        margin-bottom: 0.5rem;
    }
}

/* Pull to refresh custom styling */
@media (max-width: 768px) {
    .pull-to-refresh {
        position: relative;
    }

    .pull-to-refresh-indicator {
        position: absolute;
        top: -50px;
        left: 50%;
        transform: translateX(-50%);
        color: var(--golf-green);
        transition: all 0.3s ease;
    }
}

/* Better modal experience on mobile */
@media (max-width: 768px) {
    .modal-dialog {
        margin: 0.5rem;
    }

    .modal-content {
        border-radius: var(--radius-md);
    }

    .modal-header {
        padding: 1rem;
    }

    .modal-body {
        padding: 1rem;
        max-height: 70vh;
        overflow-y: auto;
    }

    .modal-footer {
        padding: 0.75rem 1rem;
    }

    .modal-footer .btn {
        min-height: 48px;
        flex: 1;
    }
}

/* Improved table scrolling on mobile */
@media (max-width: 768px) {
    .table-responsive {
        border-radius: var(--radius-md);
        box-shadow: var(--shadow-sm);
    }

    /* Horizontal scroll indicator */
    .table-responsive::after {
        content: '← Scroll →';
        position: absolute;
        bottom: 0;
        right: 0;
        background: rgba(46, 125, 50, 0.9);
        color: white;
        padding: 0.25rem 0.5rem;
        font-size: 0.7rem;
        border-radius: var(--radius-sm) 0 0 0;
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .table-responsive:hover::after {
        opacity: 1;
    }
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
    /* iOS Safari */
    .form-control,
    .form-select,
    input,
    select,
    textarea {
        font-size: 16px !important; /* Prevent iOS zoom on focus */
    }

    /* Fix iOS input shadows - but NOT on select elements! */
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    input[type="date"],
    textarea {
        -webkit-appearance: none;
        appearance: none;
    }

    /* Keep native appearance on select elements to ensure iOS picker wheel */
    select,
    .form-select {
        -webkit-appearance: menulist !important;
        appearance: auto !important;
        -webkit-user-select: none;
        user-select: none;
    }

    /* Prevent text selection in select dropdowns */
    select option {
        -webkit-user-select: none;
        user-select: none;
    }
}

/* Android specific fixes */
@media (max-width: 768px) {
    /* Remove Android tap highlight */
    * {
        -webkit-tap-highlight-color: transparent;
    }
}

/* Loading spinner for PWA */
.pwa-loading {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
}

.pwa-loading::after {
    content: '';
    width: 40px;
    height: 40px;
    border: 4px solid var(--golf-bg-light);
    border-top-color: var(--golf-green);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Accessibility improvements */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }

    .card {
        border: 2px solid var(--golf-green);
    }
}

/* Dark mode support (future enhancement) */
@media (prefers-color-scheme: dark) {
    /* Currently using light theme only, but ready for dark mode */
}

/* Print styles */
@media print {
    .navbar,
    .btn,
    footer {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .card {
        box-shadow: none;
        border: 1px solid #ccc;
        page-break-inside: avoid;
    }

    table {
        page-break-inside: avoid;
    }
}

/* Active nav link */
.nav-link.active,
.nav-link:active {
    color: var(--golf-green-dark) !important;
    font-weight: 600;
}

/* ===== MOBILE ENHANCEMENTS FOR NEW FEATURES ===== */

/* Player Profile Stats Cards - Mobile Responsive */
@media (max-width: 992px) {
    /* Stack stat cards 2 per row on tablets */
    .player-stats-card {
        margin-bottom: 0.75rem;
    }
}

@media (max-width: 576px) {
    /* Stack stat cards vertically on mobile */
    .player-stats-card {
        margin-bottom: 0.5rem;
    }

    .player-stats-card .card-body {
        padding: 0.75rem;
    }

    .player-stats-card h6 {
        font-size: 0.85rem;
        margin-bottom: 0.25rem;
    }

    .player-stats-card h3 {
        font-size: 1.5rem;
    }
}

/* Plotly Charts - Mobile Responsive */
@media (max-width: 768px) {
    /* Make Plotly charts responsive */
    .js-plotly-plot {
        width: 100% !important;
    }

    .js-plotly-plot .plotly {
        width: 100% !important;
    }

    /* Adjust chart margins for mobile */
    .js-plotly-plot .main-svg {
        max-width: 100%;
    }

    /* Hide chart mode bar on mobile for cleaner look */
    .modebar {
        display: none !important;
    }

    /* Chart title adjustments */
    .gtitle {
        font-size: 0.9rem !important;
    }
}

/* Achievement Badges - Mobile Layout */
@media (max-width: 576px) {
    .badge {
        margin-bottom: 0.5rem;
        padding: 0.5rem 0.75rem;
        font-size: 0.875rem;
    }

    .badge .me-1 {
        margin-right: 0.25rem !important;
    }
}

/* Player Profile Modal - Mobile Optimizations */
@media (max-width: 768px) {
    /* Player profile header section */
    .player-profile-header {
        margin-bottom: 1rem;
    }

    .player-profile-header h3 {
        font-size: 1.5rem;
        margin-bottom: 0.75rem;
    }

    .player-profile-header h5 {
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }

    /* Better spacing for profile sections */
    .player-profile-content hr {
        margin: 1rem 0;
    }

    /* Tables in profile - better mobile view */
    .player-profile-content .table {
        font-size: 0.8rem;
    }

    .player-profile-content .table thead th {
        padding: 0.5rem 0.25rem;
        font-size: 0.7rem;
    }

    .player-profile-content .table tbody td {
        padding: 0.5rem 0.25rem;
    }

    /* Scrollable modal body for long profiles */
    #player-profile-modal .modal-body {
        max-height: calc(100vh - 150px);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Extra small screens - ultra compact profile view */
@media (max-width: 380px) {
    .player-profile-content .table {
        font-size: 0.7rem;
    }

    .player-profile-content .table thead th,
    .player-profile-content .table tbody td {
        padding: 0.375rem 0.15rem;
    }
}

/* Dashboard Cards - Mobile Responsive */
@media (max-width: 768px) {
    /* Quick action buttons - stack on mobile */
    .dashboard-quick-actions .btn {
        margin-bottom: 0.75rem;
        min-height: 56px;
    }

    /* Recent rounds and standings cards */
    .dashboard-card {
        margin-bottom: 1rem;
    }

    .dashboard-card .card-body {
        padding: 1rem;
    }
}

/* Stats Page - Mobile Responsive */
@media (max-width: 768px) {
    /* Player comparison dropdowns */
    #player-comparison-container select {
        min-height: 48px;
        font-size: 1rem;
        margin-bottom: 0.5rem;
    }

    /* League stats display */
    #league-stats-container .stat-item {
        padding: 0.75rem;
        margin-bottom: 0.5rem;
    }
}

/* Loading indicators - Mobile optimized */
@media (max-width: 768px) {
    .loading-spinner {
        transform: scale(0.8);
    }

    #loading-profile {
        min-height: 200px;
    }
}

/* Touch-friendly pairing stats table */
@media (max-width: 768px) {
    .pairing-stats-table {
        font-size: 0.85rem;
    }

    .pairing-stats-table td,
    .pairing-stats-table th {
        white-space: nowrap;
    }
}

/* Best performances table - mobile view */
@media (max-width: 768px) {
    .best-performances-table {
        font-size: 0.85rem;
    }

    /* Emphasize net score on mobile */
    .best-performances-table .text-success {
        font-weight: 700;
        font-size: 1.1em;
    }
}

/* PWA Mode - Additional enhancements */
body.pwa-mode {
    /* Safe area insets for notched devices */
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* Prevent overscroll bounce in PWA mode */
body.pwa-mode {
    overscroll-behavior-y: contain;
}

/* iOS PWA - Remove bounce effect */
@supports (-webkit-touch-callout: none) {
    body.pwa-mode {
        position: fixed;
        overflow: hidden;
        width: 100%;
        height: 100%;
    }

    body.pwa-mode > #react-entry-point,
    body.pwa-mode > ._dash-loading {
        height: 100%;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Landscape mode - player profile optimizations */
@media (max-width: 896px) and (orientation: landscape) {
    #player-profile-modal .modal-body {
        max-height: calc(100vh - 100px);
    }

    .player-profile-header h3 {
        font-size: 1.25rem;
        margin-bottom: 0.5rem;
    }

    .player-stats-card .card-body {
        padding: 0.5rem;
    }

    .player-stats-card h3 {
        font-size: 1.25rem;
    }
}

/* Compact mode for small landscape phones */
@media (max-width: 667px) and (orientation: landscape) {
    .modal-header {
        padding: 0.5rem 1rem;
    }

    .modal-footer {
        padding: 0.5rem 1rem;
    }

    .player-profile-content hr {
        margin: 0.5rem 0;
    }
}

/* ==================== MOBILE BOTTOM NAVIGATION ==================== */

/* Mobile bottom navigation bar */
.mobile-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.95) 0%, rgba(255, 255, 255, 0.98) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-top: 1px solid rgba(46, 125, 50, 0.15);
    box-shadow: 0 -2px 16px rgba(0, 0, 0, 0.08);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

[data-theme="dark"] .mobile-bottom-nav {
    background: linear-gradient(180deg, rgba(58, 58, 58, 0.95) 0%, rgba(58, 58, 58, 0.98) 100%);
    border-top-color: rgba(255, 255, 255, 0.1);
}

/* Individual navigation items */
.mobile-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-decoration: none;
    color: var(--golf-text-medium);
    transition: all 0.2s ease;
    padding: 0.5rem 0.25rem;
    position: relative;
    min-height: 60px;
    -webkit-tap-highlight-color: transparent;
}

.mobile-nav-item:hover {
    color: var(--golf-green);
    text-decoration: none;
    transform: translateY(-2px);
}

.mobile-nav-item:active {
    transform: scale(0.95);
    opacity: 0.7;
}

/* Active state indicator */
.mobile-nav-item.active {
    color: var(--golf-green-dark);
}

.mobile-nav-item.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 3px;
    background: linear-gradient(90deg, var(--golf-green) 0%, var(--golf-green-dark) 100%);
    border-radius: 0 0 3px 3px;
}

/* Primary action button (Enter Scores) */
.mobile-nav-item-primary {
    color: var(--golf-green);
    font-weight: 600;
}

.mobile-nav-item-primary .mobile-nav-icon {
    background: linear-gradient(135deg, var(--golf-green) 0%, var(--golf-green-dark) 100%);
    color: white;
    border-radius: 50%;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.25);
    margin-bottom: 0.15rem;
}

.mobile-nav-item-primary:hover .mobile-nav-icon {
    transform: scale(1.05);
    box-shadow: 0 6px 16px rgba(46, 125, 50, 0.35);
}

/* Navigation icon */
.mobile-nav-icon {
    font-size: 1.5rem;
    margin-bottom: 0.15rem;
    line-height: 1;
}

/* Navigation label */
.mobile-nav-label {
    font-size: 0.7rem;
    font-weight: 500;
    line-height: 1.1;
    text-align: center;
    letter-spacing: 0.25px;
    margin-top: 0.15rem;
}

/* Add padding to body content to prevent overlap with bottom nav */
@media (max-width: 767.98px) {
    body {
        padding-bottom: 80px; /* Height of nav + some spacing */
    }

    /* Adjust page content container */
    #page-content {
        padding-bottom: 2rem;
    }

    /* Hide bottom nav when keyboard is visible (iOS) */
    @supports (-webkit-touch-callout: none) {
        input:focus ~ .mobile-bottom-nav,
        textarea:focus ~ .mobile-bottom-nav,
        select:focus ~ .mobile-bottom-nav {
            transform: translateY(100%);
        }
    }
}

/* Small screens - more compact */
@media (max-width: 360px) {
    .mobile-nav-label {
        font-size: 0.65rem;
    }

    .mobile-nav-icon {
        font-size: 1.35rem;
    }

    .mobile-nav-item-primary .mobile-nav-icon {
        width: 44px;
        height: 44px;
        font-size: 1.35rem;
    }
}

/* Dark mode adjustments */
[data-theme="dark"] .mobile-nav-item {
    color: var(--golf-text-medium);
}

[data-theme="dark"] .mobile-nav-item:hover {
    color: var(--golf-green-light);
}

[data-theme="dark"] .mobile-nav-item.active {
    color: var(--golf-green-light);
}

/* Smooth animations for nav reveal */
@keyframes slideUpNav {
    from {
        transform: translateY(100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.mobile-bottom-nav {
    animation: slideUpNav 0.3s ease-out;
}

/* Landscape mode - reduce height */
@media (max-width: 896px) and (orientation: landscape) {
    .mobile-bottom-nav {
        height: 60px;
    }

    .mobile-nav-item {
        min-height: 50px;
        padding: 0.25rem 0.15rem;
    }

    .mobile-nav-icon {
        font-size: 1.25rem;
        margin-bottom: 0.1rem;
    }

    .mobile-nav-label {
        font-size: 0.65rem;
    }

    .mobile-nav-item-primary .mobile-nav-icon {
        width: 42px;
        height: 42px;
        font-size: 1.25rem;
    }

    body {
        padding-bottom: 70px;
    }
}

/* ==================== PRINT STYLES ==================== */
@media print {
    /* Hide navigation and buttons */
    nav,
    .navbar,
    .btn,
    button,
    .modal,
    .navbar-toggler,
    #navbar-collapse,
    [role="navigation"],
    .no-print,
    .mobile-bottom-nav {
        display: none !important;
    }

    /* Show only content */
    body {
        background: white !important;
        background-image: none !important;
        color: black !important;
    }

    /* Optimize page breaks */
    .card,
    .table,
    h1,
    h2,
    h3,
    h4,
    h5,
    h6 {
        page-break-inside: avoid;
        page-break-after: avoid;
    }

    /* Table styles for printing */
    table {
        width: 100%;
        border-collapse: collapse;
    }

    table thead {
        display: table-header-group;
    }

    table tbody tr {
        page-break-inside: avoid;
    }

    table td,
    table th {
        border: 1px solid #000 !important;
        padding: 8px !important;
    }

    /* Card styles for printing */
    .card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
        margin-bottom: 1rem;
    }

    .card-header {
        background-color: #f0f0f0 !important;
        color: black !important;
        font-weight: bold;
        border-bottom: 1px solid #000 !important;
    }

    .card-body {
        padding: 1rem;
    }

    /* Remove box shadows and backgrounds */
    * {
        box-shadow: none !important;
        text-shadow: none !important;
    }

    /* Optimize font sizes */
    body {
        font-size: 11pt;
    }

    h1 {
        font-size: 24pt;
    }

    h2 {
        font-size: 20pt;
    }

    h3 {
        font-size: 16pt;
    }

    h4 {
        font-size: 14pt;
    }

    h5,
    h6 {
        font-size: 12pt;
    }

    /* Links */
    a[href]:after {
        content: none !important;
    }

    /* Ensure charts are visible but compressed */
    .js-plotly-plot {
        max-height: 300px !important;
    }

    /* Page margins */
    @page {
        margin: 1.5cm;
    }

    /* Print title */
    .print-title {
        display: block;
        text-align: center;
        margin-bottom: 1cm;
    }

    /* Standings table enhancements */
    .standings-table td:nth-child(1),
    .standings-table th:nth-child(1) {
        font-weight: bold;
    }

    /* Trophy emojis should be visible */
    .trophy-emoji {
        font-size: 14pt;
    }
}
