/* --- Toggle Button --- */
#toggle-btn {
    position: absolute;
    top: 30px;
    left: 9px;
    z-index: 100; /* Ensure it stays on top of everything */
    background: transparent;
    border: none;
    color: white;
    font-size: 30px;
    cursor: pointer;
    /* Using width/height is often simpler if you don't need min/max constraints, but keeping max/min for strict sizing: */
    min-width: 45px;
    max-width: 45px;
    min-height: 45px;
    max-height: 45px;
    padding: 5px;
    line-height: 1;
    border-radius: 22px;
}

#toggle-btn:hover {
    background-color: #444;
}

/* --- Sidebar (Sidenav) --- */
/* Combined both redundant #sidenav blocks into one */
#sidenav {
    position: relative;
    top: 0;
    left: 0;
    height: 100vh;
    background-color: #333; /* Gray bar */
    overflow-x: hidden; /* Hide text in narrow mode */
    transition: width 0.3s ease, transform 0.3s ease; /* Kept transform for completeness, as it was in the first definition */
    z-index: 90;
    white-space: nowrap; /* Keep text on one line */
    box-shadow: 2px 0 5px rgba(0, 0, 0, 0.5);
    /* Added from the second definition to manage vertical layout */
    display: flex;
    flex-direction: column;
}

/* Styling the links inside */
.nav-content {
    margin-top: 80px; /* Space for the toggle button */
    /* Added properties from the second .nav-content block: */
    flex: 1; /* Take remaining height */
    overflow-y: auto; /* Enable vertical scrolling */
    overflow-x: hidden;
    padding-bottom: 20px;
}

.nav-link {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    color: white;
    text-decoration: none;
    transition: background 0.2s;
}

.nav-link:hover {
    background-color: #555;
}

.nav-link .icon {
    min-width: 30px;
    font-size: 20px;
    margin-right: 15px;
    text-align: center;
}

.nav-link .text {
    opacity: 0; /* Hidden by default in narrow mode */
    transition: opacity 0.2s ease;
}

/* Custom Scrollbar for the nav */
.nav-content::-webkit-scrollbar {
    width: 6px;
}
.nav-content::-webkit-scrollbar-track {
    background: #333;
}
.nav-content::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}
.nav-content::-webkit-scrollbar-thumb:hover {
    background: #777;
}

/* --- Team Card Styling --- */
.team-card {
    display: flex;
    flex-direction: column; /* Stack details vertically */
    padding: 15px 10px;
    border-bottom: 1px solid #444;
    cursor: pointer;
    color: white;
    transition: background 0.2s;
    position: relative;
}

.team-card:hover {
    background-color: #444;
}

/* The header: Always visible (Compact view) */
.team-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 30px;
}

.team-name-main {
    font-weight: bold;
    font-size: 1.1em;
    color: #ec4034; /* distinct color for name */
    max-width: 40px; /* Force truncation in narrow mode */
    overflow: hidden;
    text-overflow: ellipsis;
    transition: max-width 0.3s ease;
}

.team-score-main {
    font-size: 0.9em;
    font-weight: bold;
    background: #555;
    padding: 2px 6px;
    border-radius: 4px;
    min-width: 35px; /* Ensure score fits in narrow mode */
    text-align: center;
}

/* Detailed Info: Hidden in narrow mode, Visible in expanded */
.team-details {
    margin-top: 8px;
    font-size: 0.85em;
    color: #ccc;
    opacity: 0; /* Hidden by default */
    transition: opacity 0.2s ease, max-height 0.3s ease;
    max-height: 0; /* Collapse height so it doesn't take space in narrow mode */
    overflow: hidden;
    display: flex;
    flex-direction: column;
    gap: 4px;
    white-space: normal; /* Allow text wrapping in expanded mode */
}

/* --- Expanded Mode Logic --- */
/* Default: Narrow Mode */
#sidenav {
    width: 60px;
}

/* Expanded Mode (Pinned or Hovered logic handled in JS/CSS) */
#sidenav.pinned {
    width: 500px;
}

/* When expanded, show details */
#sidenav.pinned .team-details {
    opacity: 1;
    max-height: 500px; /* Allow expansion */
}

#sidenav.pinned .team-name-main {
    max-width: 300px; /* Expand name width */
}

@media (max-width: 768px) {
    #sidenav {
        /* This is the key line to make it fixed to the viewport */
        position: fixed;
    }
    #sidenav.pinned {
        width: 350px;
    }
    #main {
        margin-left: 60px;
    }
}

#sidenav img {
    /* 1. Visibility and Spacing (Default/Collapsed State) */
    display: none; /* Hide the image by default */

    /* 2. Sizing (Ensuring it's small when visible) */
    max-width: 100%; /* Prevents overflow if it somehow appears */
    height: auto;

    /* 3. Transition for smooth appearance */
    opacity: 0;
    transition: opacity 0.3s ease;
}

/* --- Expanded/Pinned State --- */
#sidenav.pinned img {
    /* 1. Make it visible when sidebar has the 'pinned' class */
    display: block;
    opacity: 1; /* Fade it in */

    /* 2. Assign to the right (Centering within the remaining space) */
    margin: 30px auto 10px auto; /* Top: 20px, Bottom: 10px, auto margins center it horizontally */

    /* 3. Define the desired 'reasonably small' size */
    height: 40px; /* Adjust this value for your desired small size */
}

#sidenav.pinned .nav-content {
    margin-top: 0;
}
