body {
    font-family: Arial, sans-serif;
    margin: 0;
    padding: 20px;
    background-color: #f5f5f5;
}

h2 {
    color: #333;
}


.custom-navbar {
    background-color: #2c3338;
    padding: 1rem 2rem;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.navbar-brand {
    color: #ffffff !important;
    font-size: 1.4rem;
    font-weight: 500;
    padding: 0.5rem 1rem;
    margin-right: 2rem;
}

.navbar-collapse {
    justify-content: flex-end;
}

.navbar-nav {
    width: auto;
}

@media (max-width: 991px) {
    .navbar-collapse {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background-color: #2c3338;
        padding: 0;
        box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        z-index: 1000;
    }

    .navbar-nav {
        padding: 0.5rem 0;
        text-align: right;
    }

    .nav-item {
        border-bottom: 1px solid rgba(255,255,255,0.1);
    }

    .nav-item:last-child {
        border-bottom: none;
    }

    .nav-link {
        color: rgba(255,255,255,0.7) !important;
        padding: 1rem 1.5rem !important;
        text-align: right;
        transition: all 0.2s ease;
    }

    .nav-link:hover {
        background-color: rgba(255,255,255,0.1);
        color: #ffffff !important;
    }
}

@media (min-width: 992px) {
    .nav-link {
        color: rgba(255,255,255,0.7) !important;
        padding: 0.5rem 1.5rem !important;
        transition: color 0.2s ease;
    }
}

.nav-link {
    color: rgba(255,255,255,0.7) !important;
    font-size: 1rem;
    padding: 0.5rem 1.5rem !important;
    transition: color 0.2s ease;
}

.nav-link:hover {
    color: #ffffff !important;
    text-decoration: none;
}

main {
    padding: 20px;
}

/* Responsive table styles */
.table-responsive {
    width: 100%;
    margin-bottom: 1rem;
    overflow: hidden; /* Hide overflow to prevent scrollbars during scaling */
}

table {
    width: 100%;
    border-collapse: collapse;
    background-color: transparent;
}

/* Container for rotation table */
.table-responsive {
    margin: 0;
    padding: 0;
    overflow-x: auto !important;
    position: relative;
}

/* Rotation prompt for portrait mode */
.rotation-prompt {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.95);
    color: white;
    padding: 25px;
    border-radius: 15px;
    text-align: center;
    z-index: 1000;
    width: 90%;
    max-width: 320px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    backdrop-filter: blur(5px);
}

.rotation-prompt i {
    font-size: 2.5rem;
    margin-bottom: 15px;
    display: block;
    animation: rotatePhone 2s infinite;
    color: #4CAF50;
}

.rotation-prompt p {
    margin: 0;
    font-size: 1.1rem;
    line-height: 1.4;
}

@keyframes rotatePhone {
    0% {
        transform: rotate(0deg);
    }
    20% {
        transform: rotate(-90deg);
    }
    80% {
        transform: rotate(-90deg);
    }
    100% {
        transform: rotate(0deg);
    }
}

.rotation-container {
    width: 100%;
    position: relative;
    transform-origin: left top;
    margin-bottom: 1rem;
}

/* Portrait mode detection and handling */
@media screen and (max-width: 414px) and (orientation: portrait) {
    .rotation-prompt {
        display: block;
    }
    
    .rotation-container, .table-responsive {
        width: 100% !important;
        margin-left: 0 !important;
        overflow-x: auto !important;
    }
    
    .rotation-table, table {
        min-width: 600px !important;
        transform: none !important;
        font-size: 14px;
    }

    th, td {
        padding: 8px !important;
        white-space: nowrap;
    }
}

/* Landscape mode optimization */
@media screen and (max-width: 914px) and (orientation: landscape) {
    .rotation-prompt {
        display: none;
    }
    
    .rotation-container, .table-responsive {
        width: 100% !important;
        margin-left: 0 !important;
        overflow-x: auto !important;
    }
    
    .rotation-table, table {
        transform: none !important;
    }

    th, td {
        padding: 10px !important;
    }
}

#rotation-container {
    width: 100%;
}

.rotation-table {
    width: 100%;
    margin: 0;
    transform-origin: left top;
}

/* Mobile-first responsive table styles */
@media screen and (max-width: 992px) {
    .table-responsive {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }

    table, .rotation-table {
        min-width: 600px;
        margin-bottom: 1rem;
        white-space: nowrap;
    }

    th, td {
        padding: 8px !important;
        font-size: 14px;
    }
}

/* Additional optimizations for very small screens */
@media screen and (max-width: 576px) {
    th, td {
        padding: 6px !important;
        font-size: 13px;
    }
}

/* Ensure consistent behavior for all tables */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 1rem;
    border-radius: 8px;
}

/* Player-based View specific styles */
.player-based-view {
    overflow-x: auto;
    width: 100%;
    margin-bottom: 1rem;
}

.player-based-view table {
    min-width: 600px;
    border-collapse: collapse;
    margin-bottom: 0;
}

.player-based-view th,
.player-based-view td {
    white-space: nowrap;
    padding: 8px;
    border: 1px solid #dee2e6;
}

/* Responsive styles for Player-based View */
@media screen and (max-width: 414px) {
    .player-based-view {
        margin: 0 -20px;  /* Compensate for body padding */
        width: calc(100% + 40px);
        border-radius: 0;
    }
    
    .player-based-view table {
        margin: 0;
    }
    
    .player-based-view th,
    .player-based-view td {
        padding: 6px;
        font-size: 13px;
    }
}

/* Ensure table header stays visible */
.rotation-table thead {
    position: sticky;
    top: 0;
    z-index: 1;
}

table th, table td {
    border: 1px solid #dee2e6;
    padding: 12px;
    text-align: left;
    vertical-align: top;
    background-color: #ffffff;
}

/* Enhanced table styles */
table:not(.rotation-table) {
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid #dee2e6;
}

/* Regular table headers (not .table class) */
table:not(.table):not(.rotation-table) th,
table:not(.table):not(.rotation-table) thead th,
table:not(.table):not(.rotation-table) thead tr th,
.table-responsive table:not(.table):not(.rotation-table) thead tr th,
.table-responsive table:not(.table):not(.rotation-table) th {
    background-color: #f8f9fa !important;
    font-weight: 600;
    border-bottom: 2px solid #dee2e6;
    color: #2c3338;
    border-left: none;
    padding: 12px 16px;
    font-size: 0.95rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

table:not(.rotation-table) tbody tr:nth-of-type(odd) {
    background-color: #f8f9fa;
}

table:not(.rotation-table) tbody tr:nth-of-type(even) {
    background-color: #ffffff;
}

table:not(.rotation-table) tbody tr:hover {
    background-color: #e9ecef;
    transition: background-color 0.2s ease;
}

table:not(.rotation-table) td {
    padding: 12px 16px;
    vertical-align: middle;
    border-bottom: 1px solid #dee2e6;
    font-size: 0.95rem;
    color: #495057;
}

/* Action buttons in tables */
.table td .btn,
table:not(.rotation-table) .btn {
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    border: none;
    color: white;
    margin-right: 0.5rem;
}

.table td .btn:last-child,
table:not(.rotation-table) .btn:last-child {
    margin-right: 0;
}

/* User management table specific styles */
.table td:last-child {
    align-items: center;
    gap: 8px;
    white-space: nowrap;
}

.table td:last-child .btn {
    margin: 0;
    flex-shrink: 0;
}

.table td:last-child form {
    margin: 0;
    padding: 0;
    box-shadow: none;
    background: none;
    border: none;
    display: inline-flex;
}

.table td:last-child .d-inline {
    display: inline-flex !important;
}

.table td:last-child .d-inline .btn {
    margin: 0;
}

.table td .btn-danger,
table:not(.rotation-table) .btn-danger {
    background-color: #dc3545;
}

.table td .btn-primary,
table:not(.rotation-table) .btn-primary {
    background-color: #0d6efd;
}

table:not(.rotation-table) button:hover {
    background-color: #c82333;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Mobile responsiveness for tables */
@media screen and (max-width: 768px) {
    table:not(.rotation-table) th,
    table:not(.rotation-table) td {
        padding: 10px 12px;
        font-size: 0.9rem;
    }
    
    table:not(.rotation-table) button {
        padding: 4px 8px;
        font-size: 0.85rem;
    }
}

/* Enhanced Form and Button Styles */
input[type="text"],
input[type="number"],
input[type="email"],
select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    background-color: #fff;
    color: #495057;
}

input[type="text"]:focus,
input[type="number"]:focus,
input[type="email"]:focus,
select:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

input::placeholder {
    color: #6c757d;
    opacity: 0.8;
}

button {
    background-color: #0d6efd;
    color: white;
    border: none;
    padding: 8px 16px;
    cursor: pointer;
    border-radius: 4px;
    font-size: 0.95rem;
    font-weight: 500;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    line-height: 1.5;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

button:hover {
    background-color: #0b5ed7;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

button:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}

button.danger {
    background-color: #dc3545;
}

button.danger:hover {
    background-color: #c82333;
}

button.success {
    background-color: #198754;
}

button.success:hover {
    background-color: #157347;
}

button:disabled {
    background-color: #6c757d;
    cursor: not-allowed;
    opacity: 0.65;
    transform: none;
    box-shadow: none;
}

@media screen and (max-width: 768px) {
    button {
        padding: 6px 12px;
        font-size: 0.9rem;
    }
    
    input[type="text"],
    input[type="number"],
    input[type="email"],
    select {
        padding: 6px 10px;
        font-size: 0.9rem;
    }
}
/* Player Assignment Modal */
.modal-container {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 1000;
}

.modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 20px;
    border-radius: 5px;
    width: 80%;
    max-width: 800px;
}

.player-list {
    min-height: 200px;
    max-height: 400px;
    overflow-y: auto;
    padding: 10px;
}

.player-item {
    cursor: pointer;
    transition: all 0.3s ease;
    margin: 5px 0;
    padding: 8px;
    border-radius: 4px;
    display: block;
    width: 100%;
    text-align: left;
    border: 1px solid transparent;
}

.player-item:hover {
    transform: scale(1.02);
    opacity: 0.9;
}

#red-box {
    border: 2px solid #dc3545;
    border-radius: 5px;
}


/* Schedule Table Styling */
.rotation-table {
    width: 100%;
    margin-top: 20px;
    border-collapse: separate;
    border-spacing: 0;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.rotation-table th, .rotation-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
    border-right: 1px solid #dee2e6;
    min-width: 70px; /* Further reduced minimum width */
}

/* Ensure period column doesn't get too narrow */
.rotation-table td:first-child,
.rotation-table th:first-child {
    min-width: 35px;
}

@media screen and (max-width: 768px) {
    .rotation-table th, .rotation-table td {
        min-width: 60px;
        padding: 6px 8px;
    }
    .rotation-table td:first-child,
    .rotation-table th:first-child {
        min-width: 25px;
    }
    /* Reduce header text size */
    .rotation-table thead tr:first-child th,
    .rotation-table thead tr:nth-child(2) th {
        font-size: 0.8rem;
        padding: 6px;
    }
}

@media screen and (max-width: 576px) {
    .rotation-table th, .rotation-table td {
        min-width: 50px;
        padding: 4px 6px;
    }
    .rotation-table td:first-child,
    .rotation-table th:first-child {
        min-width: 20px;
    }
    /* Further reduce header text size */
    .rotation-table thead tr:first-child th,
    .rotation-table thead tr:nth-child(2) th {
        font-size: 0.75rem;
        padding: 4px;
    }
}

/* Enhance visibility of active and next players on small screens */
@media screen and (max-width: 768px) {
    .rotation-table tbody tr.active td,
    .rotation-table tbody tr.active + tr td {
        font-weight: 700;
    }
    
    .rotation-table thead tr:first-child th,
    .rotation-table thead tr:nth-child(2) th {
        font-size: 0.9rem;
        padding: 8px;
    }
}

@media screen and (max-width: 576px) {
    .rotation-table tbody tr.active td,
    .rotation-table tbody tr.active + tr td {
        font-size: 0.85rem;
        padding: 6px;
    }
}

.rotation-table th:last-child, .rotation-table td:last-child {
    border-right: none;
}

.rotation-table th {
    background-color: #f1f3f5;
    font-weight: 600;
    color: #495057;
    white-space: nowrap;
}

.rotation-table thead tr:first-child th {
    background-color: #ffcdd2;
    border-left: 6px solid #d32f2f;
    color: #d32f2f;
    font-weight: bold;
}

/* Bootstrap table overrides */
.table {
    margin-bottom: 1rem;
    background-color: transparent;
}

.table th {
    background-color: #ffffff;
    color: #495057;
    font-weight: 600;
    border-bottom: 2px solid #dee2e6;
}

.table td {
    background-color: #ffffff;
}

.table tbody tr:hover {
    background-color: rgba(0,0,0,.075);
}

/* Rotation table specific styles */
.rotation-table thead tr:nth-child(2) th {
    background-color: #c8e6c9;
    border-left: 6px solid #4caf50;
    color: #4caf50;
    font-weight: bold;
}

.rotation-table tbody tr.completed {
    text-decoration: line-through;
    color: #6c757d;
    background-color: #f8f9fa;
}

.rotation-table tbody tr.active {
    background-color: #ffcdd2;
    border-left: 6px solid #d32f2f;
    font-weight: 600;
    box-shadow: 0 0 10px rgba(211, 47, 47, 0.15);
    position: relative;
}

.rotation-table tbody tr.active td {
    border-color: #d32f2f;
}

.rotation-table tbody tr.active::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    border: 2px solid #d32f2f;
    pointer-events: none;
}

.rotation-table tbody tr.active + tr {
    background-color: #c8e6c9;
    border-left: 6px solid #4caf50;
    font-weight: 600;
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.15);
    position: relative;
}

.rotation-table tbody tr.active + tr td {
    border-color: #4caf50;
}

.rotation-table tbody tr.active + tr::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;
    border: 2px solid #4caf50;
    pointer-events: none;
}

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

/* Enhanced Form Styling */
form, .form-section {
    background: #ffffff;
    padding: 24px;
    border-radius: 8px;
    margin-bottom: 24px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border: 1px solid #e9ecef;
}

.form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 16px;
    align-items: flex-end;
}

.form-group {
    flex: 1;
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    color: #495057;
    font-weight: 500;
    font-size: 0.95rem;
}

.form-control {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-control:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0,123,255,.25);
}

/* Card-like sections */
.section-card {
    background: #ffffff;
    padding: 24px;
    border-radius: 8px;
    margin-bottom: 24px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    border: 1px solid #e9ecef;
}

.section-card h2 {
    margin-top: 0;
    margin-bottom: 24px;
    color: #2c3338;
    font-size: 1.5rem;
    font-weight: 600;
}

/* Table improvements */
.table-container {
    background: #ffffff;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    margin-bottom: 24px;
    overflow: hidden;
}

.table-header {
    background: #f8f9fa;
    padding: 16px 24px;
    border-bottom: 1px solid #dee2e6;
}

.table-header h3 {
    margin: 0;
    color: #2c3338;
    font-size: 1.2rem;
    font-weight: 600;
}

/* Action buttons in forms */
.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

.btn {
    padding: 8px 16px;
    border-radius: 4px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn i {
    margin-right: 8px;
}

.btn-primary {
    background-color: #0d6efd;
    color: white;
}

.btn-primary:hover {
    background-color: #0b5ed7;
    transform: translateY(-1px);
}

.btn-danger {
    background-color: #dc3545;
    color: white;
}

.btn-danger:hover {
    background-color: #c82333;
    transform: translateY(-1px);
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
        gap: 12px;
    }
    
    .form-group {
        width: 100%;
    }
    
    .section-card {
        padding: 16px;
    }
    
    .table-header {
        padding: 12px 16px;
    }
}

/* Rotation System */
#rotation-grid {
    margin-top: 2rem;
}

.period-players {
    min-height: 150px;
    border: 2px dashed #ccc;
    padding: 10px;
    transition: all 0.3s;
}

.drag-over {
    background-color: #f8f9fa;
    border-color: #28a745;
}

.player-card {
    background: #fff;
    border: 1px solid #dee2e6;
    padding: 8px;
    margin: 4px;
    border-radius: 4px;
    cursor: move;
    transition: all 0.3s;
}

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

/* Add to style.css */
#game-select option[value=""] {
    color: #6c757d;
    font-style: italic;
}

.loading-spinner {
    display: inline-block;
    width: 1rem;
    height: 1rem;
    border: 2px solid currentColor;
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 0.75s linear infinite;
}

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

/* Error states */
.rotation-error {
    border: 2px solid #dc3545;
    padding: 20px;
    border-radius: 8px;
    background: #fff5f5;
}

/* Loading spinner */
#loading-spinner {
    animation: fadeIn 0.3s ease-in;
}

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

/* Rotation Page Styles */
.rotation-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
    margin-top: 1rem;
}

.period-section {
    padding: 1rem;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    background: #fff;
}

.time-slot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem;
    margin: 0.25rem 0;
    background: #f8f9fa;
    border-radius: 4px;
}

.player-tag {
    background: #4CAF50;
    color: white;
    padding: 0.25rem 0.5rem;
    border-radius: 12px;
    font-size: 0.9rem;
}

.injury-list {
    position: fixed;
    right: 1rem;
    top: 1rem;
    background: #fff;
    padding: 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.modal {
    background: rgba(0,0,0,0.5);
}

.rotation-controls {
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 8px;
}

.export-btn {
    margin-top: 1rem;
}

.player-card {
    background: #f8f9fa;
    border: 1px dashed #dee2e6;
    padding: 8px;
    margin: 4px;
    border-radius: 4px;
    cursor: move;
}

.player-card[data-player-id] {
    background: #e9ecef;
    border-style: solid;
}

.text-muted {
    color: #6c757d !important;
    font-style: italic;
}

.empty-slot {
    color: #666;
    font-style: italic;
    padding: 10px;
}

.rotation-loading {
    text-align: center;
    padding: 2rem;
    color: #666;
}

.time-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    gap: 2px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 4px;
}

.time-slot {
    padding: 5px;
    text-align: center;
    background: #fff;
    border: 1px solid #dee2e6;
    font-size: 0.8rem;
}

.player-assignment {
    background-color: #4CAF50;
    color: white;
    border-radius: 3px;
    margin: 2px;
    padding: 2px;
}

.time-slot-header {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    padding: 8px;
    text-align: center;
    font-weight: bold;
}

.period-players {
    min-height: 150px;
    border: 2px dashed #ccc;
    padding: 10px;
    transition: all 0.3s;
}

.player-card {
    background: #e9ecef;
    border: 1px solid #ced4da;
    padding: 8px;
    margin: 4px;
    border-radius: 4px;
    cursor: move;
    transition: all 0.3s;
}

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

#loading-state {
    animation: fadeIn 0.3s ease-in;
}

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

.player-item {
    background-color: #f8f9fa;
    border: 1px solid #dee2e6 !important;
    cursor: move;
    transition: all 0.3s ease;
}

.player-item:hover {
    background-color: #e9ecef;
    transform: scale(1.05);
}

#green-box {
    min-height: 100px;
    padding: 15px;
    border: 2px dashed #4caf50;
    border-radius: 8px;
    background-color: #f1f8e9;
}
