/* --- Variables & Base Styles --- */
:root {
    --primary-color: #005A9C; /* Dodger Blue-ish */
    --secondary-color: #28a745; /* Green */
    --light-gray: #f8f9fa;
    --medium-gray: #e9ecef;
    --dark-gray: #6c757d;
    --text-color: #343a40;
    --card-bg: #ffffff;
    --border-color: #dee2e6;
    --shadow: 0 4px 8px rgba(0, 0, 0, 0.08);
    --border-radius: 8px;
    --spacing-unit: 1rem; /* approx 16px */
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    line-height: 1.6;
    background-color: var(--light-gray);
    color: var(--text-color);
    padding: var(--spacing-unit);
}

.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 var(--spacing-unit);
}

header {
    text-align: center;
    margin-bottom: calc(var(--spacing-unit) * 2);
    padding-bottom: var(--spacing-unit);
    border-bottom: 1px solid var(--border-color);
}

header h1 {
    color: var(--primary-color);
    margin-bottom: calc(var(--spacing-unit) / 2);
}

h2 {
    color: var(--primary-color);
    margin-bottom: var(--spacing-unit);
    display: flex;
    align-items: center;
    gap: calc(var(--spacing-unit) / 2);
}

h2 .icon {
    font-size: 1.2em;
}

main {
    display: grid;
    gap: calc(var(--spacing-unit) * 1.5);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 2; /* Ensure it's above other content */
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
}

.modal-content {
    background-color: #fefefe;
    margin: 15% auto;
    padding: 20px;
    border: 1px solid #888;
    width: 80%;
    max-width: 500px;
    border-radius: 10px;
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
}

.close:hover,
.close:focus {
    color: black;
    text-decoration: none;
    cursor: pointer;
}


/* --- Card Style --- */
.card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    padding: calc(var(--spacing-unit) * 1.5);
    border: 1px solid var(--border-color);
}

/* --- Import Section (Optional) --- */
.import-section {
    margin-top: calc(var(--spacing-unit) * 1.5);
    padding-top: var(--spacing-unit);
    border-top: 1px dashed var(--border-color);
}

.import-section h3 {
    margin-bottom: calc(var(--spacing-unit) / 2);
    color: var(--dark-gray);
}
.import-section p {
    font-size: 0.9em;
    color: var(--dark-gray);
    margin-bottom: var(--spacing-unit);
}

#csvFile {
    display: block;
    margin-bottom: var(--spacing-unit);
}


/* --- Buttons --- */
.button {
    display: inline-block; /* Allows margin auto for center */
    width: auto; /* Fit content */
    padding: 12px 24px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1.05em;
    font-weight: 500;
    text-align: center;
    transition: background-color 0.2s ease, box-shadow 0.2s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.button .icon {
    margin-left: 8px;
}

.button.primary {
    background-color: var(--primary-color);
    color: white;
    display: block; /* Make primary button full width */
    width: 100%;
    margin-top: var(--spacing-unit); /* Add space above */
}

.button.primary:hover {
    background-color: #004175; /* Darker shade */
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.button.secondary {
    background-color: var(--secondary-color);
    color: white;
}
.button.secondary:hover {
    background-color: #1f7a36; /* Darker shade */
     box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

/* --- Results Section --- */
#results-section[hidden] {
    display: none;
}

#lineup-display {
    list-style: none;
    padding: 0;
    margin-top: var(--spacing-unit);
}

.lineup-item {
    display: flex;
    align-items: center;
    background-color: var(--medium-gray);
    margin-bottom: calc(var(--spacing-unit) / 2);
    padding: calc(var(--spacing-unit) * 0.75) var(--spacing-unit);
    border-radius: 4px;
    border-left: 5px solid var(--primary-color);
    gap: var(--spacing-unit); /* Space between elements */
    flex-wrap: wrap; /* Allow wrapping on small screens */
}

.lineup-spot {
    font-weight: bold;
    font-size: 1.2em;
    color: var(--primary-color);
    min-width: 25px; /* Ensure space for number */
    text-align: right;
}

.lineup-name {
    font-weight: 600;
    flex-grow: 1; /* Takes up available space */
    min-width: 120px; /* Prevent excessive shrinking */
}

.lineup-stats {
    font-size: 0.85em;
    color: var(--dark-gray);
    margin-left: auto; /* Pushes stats to the right */
    text-align: right;
    white-space: nowrap; /* Keep stats on one line */
    min-width: 150px;
}

/* --- Footer --- */
footer {
    text-align: center;
    margin-top: calc(var(--spacing-unit) * 2);
    padding-top: var(--spacing-unit);
    border-top: 1px solid var(--border-color);
    font-size: 0.9em;
    color: var(--dark-gray);
}

/* --- Table Input Styles --- */
#player-input-table {
    width: 100%;
    border-collapse: separate; /* Use separate instead of collapse */
    border-spacing: 0; /* Remove spacing between cells */
    margin-top: 10px;
    border: 1px solid var(--border-color); /* Add a border to the entire table */
    border-radius: var(--border-radius);
    overflow: hidden; /* Hide any overflow from rounded corners */
}

#player-input-table th,
#player-input-table td {
    padding: 8px 12px; /* Adjust padding for more compact look */
    text-align: left;
    white-space: nowrap;
}

#player-input-table th {
    background-color: var(--medium-gray); /* Lighter header background */
    font-weight: 600;
    color: var(--text-color);
    border-bottom: 2px solid var(--border-color); /* Add a thicker border below header */
}

#player-input-table td {
    border-bottom: 1px solid var(--border-color); /* Add border between rows */
}

#player-input-table tr:last-child td {
    border-bottom: none; /* Remove border from last row */
}

#player-input-table input[type="text"] {
    width: 100%;
    box-sizing: border-box;
    border: none; /* Remove input borders */
    background-color: transparent; /* Transparent background */
    padding: 4px 0; /* Adjust padding */
    font-size: 1em;
    outline: none; /* Remove focus outline */
}

#player-input-table input[type="text"]:focus {
    background-color: var(--light-gray); /* Highlight on focus */
    border-radius: 4px;
}

/* --- Collapsible Section --- */
.collapsible-section .card-content {
    display: none; /* Hide content by default */
    overflow: hidden; /* Hide any overflowing content */
    transition: max-height 0.3s ease-out; /* Smooth transition for expanding/collapsing */
    max-height: 0; /* Start with no height */
}

.collapsible-section.expanded .card-content {
    display: block; /* Show content when expanded */
    max-height: 5000px; /* Set a large max-height to accommodate content */
    /* Adjust this value if you have a lot of content and need more space */
}

.collapsible-section h3 {
    cursor: pointer; /* Make the header clickable */
    user-select: none; /* Prevent text selection */
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0; /* Remove default margin */
}

.collapsible-section h3::after {
    content: '\25BC'; /* Down arrow by default */
    font-size: 0.8em;
    margin-left: 10px;
}

.collapsible-section.expanded h3::after {
    content: '\25B2'; /* Up arrow when expanded */
}

/* Adjustments for the button */
#optimizeBtn {
    margin-top: 15px; /* Add some space above the button */
    width: 100%;
}

/* Styles for the header instructions */
.header-instructions {
    font-size: 0.8em; /* Smaller font size */
    font-style: italic; /* Italic text */
    margin-top: 5px; /* Add a little space above the instructions */
    color: #666; /* Slightly muted color */
}

/* --- Modernized Results Display --- */
#results-section {
    background-color: #f8f8f8; /* Light gray background */
    border: 1px solid #ddd; /* Light gray border */
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1); /* Subtle shadow */
    padding: 20px;
    border-radius: 8px;
    position: relative;
    margin-top: 20px; /* Add some space above the results */
}

#lineup-display {
    list-style: none;
    padding: 0;
    margin-top: 10px;
    counter-reset: lineup-counter; /* Initialize counter */
}

.lineup-item {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
    padding: 10px;
    gap: 10px;
    flex-wrap: wrap;
    position: relative;
    background-color: #fff; /* White background for each item */
    border-radius: 4px;
    border: 1px solid #eee;
}

.lineup-item::before {
    counter-increment: lineup-counter;
    content: counter(lineup-counter) ".";
    position: relative;
    font-weight: bold;
    color: #333;
    font-size: 1.1em;
    margin-right: 5px;
}

.lineup-spot {
    display: none; /* Hide the spot number */
}

.lineup-name {
    font-family: sans-serif; /* Clean, modern font */
    font-size: 1.1em;
    font-weight: 500;
    flex-grow: 1;
    min-width: 120px;
    color: #333;
}

.lineup-stats {
    font-size: 0.9em;
    color: #666;
    margin-left: auto;
    text-align: right;
    white-space: nowrap;
    min-width: 150px;
}

/* Copy Button */
#copy-results-btn {
    background-color: #4CAF50; /* Green */
    border: none;
    color: white;
    padding: 8px 16px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 14px;
    margin: 10px 0;
    cursor: pointer;
    border-radius: 4px;
}

#copy-results-btn:hover {
    background-color: #367c39;
}

.info-icon {
    cursor: pointer;
    margin-left: 5px;
    color: #005A9C;
}

/* --- Responsive Adjustments --- */
@media (max-width: 600px) {
    body {
        padding: calc(var(--spacing-unit) / 2);
    }
    .container {
         padding: 0 calc(var(--spacing-unit) / 2);
    }
    .card {
        padding: var(--spacing-unit);
    }
    h1 {
        font-size: 1.8em;
    }
    h2 {
        font-size: 1.3em;
    }
    .lineup-item {
        flex-direction: column; /* Stack vertically */
        align-items: flex-start; /* Align left */
        gap: calc(var(--spacing-unit) / 4);
    }
     .lineup-spot {
        font-size: 1em;
        min-width: auto;
        margin-bottom: 5px;
     }
    .lineup-name {
        font-size: 1.1em;
    }
    .lineup-stats {
         margin-left: 0; /* Remove auto margin */
         text-align: left;
         font-size: 0.8em;
    }
    #player-input-table th,
    #player-input-table td {
        padding: 6px 8px; /* Further reduce padding on small screens */
    }
}
