/*
 * File: /css/ladder.css
 * Description: Styles specifically for the Single Ladder/Operation front-end display.
 */

/* Banner & Layout Structure */
.gwl-hub-banner {
    width: 100%;
    height: 350px;
    background-color: #1a1a1a;
    background-size: cover;
    background-position: center;
    border-bottom: 3px solid #dd9933;
    position: relative;
    border-radius: 8px 8px 0 0;
}

.gwl-hub-banner-overlay {
    position: absolute;
    inset: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.9) 0%, rgba(0,0,0,0) 100%);
    border-radius: 8px 8px 0 0;
}

.gwl-hub-container {
    width: 100%;
    padding: 0 20px 40px;
    position: relative;
    z-index: 10;
    margin-top: -80px;
}

.gwl-hub-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 40px;
}

/* Header & Avatar */
.gwl-hub-header {
    display: flex;
    gap: 30px;
    align-items: flex-end;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.gwl-hub-avatar-wrapper {
    width: 150px;
    height: 150px;
    min-width: 150px;
    background: #222;
    border: 4px solid #111;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,0.8);
}

.gwl-hub-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.gwl-hub-avatar-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    text-transform: uppercase;
    font-size: 12px;
    text-align: center;
}

/* Title & Meta Data */
.gwl-hub-header-content {
    flex-grow: 1;
    padding-bottom: 10px;
}

.gwl-hub-header-content h1 {
    margin: 0 0 10px 0;
    color: #fff;
    font-size: 2.5rem;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.9);
    line-height: 1.1;
}

.gwl-hub-author-byline {
    margin-bottom: 15px;
    font-size: 14px;
    color: #aaa;
}

.gwl-hub-author-link {
    color: #98cb00;
    text-decoration: none;
    font-weight: bold;
}

/* Badges */
.gwl-hub-badges {
    display: flex;
    gap: 10px;
    font-size: 13px;
    color: #ccc;
    flex-wrap: wrap;
}

.gwl-badge-game {
    background: #dd9933;
    color: #000;
    padding: 5px 12px;
    border-radius: 4px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.gwl-badge-standard {
    background: #333;
    padding: 5px 12px;
    border-radius: 4px;
    border: 1px solid #444;
}

/* Action Buttons */
.gwl-hub-actions {
    padding-bottom: 10px;
}

.gwl-enlisted-wrapper {
    display: flex;
    align-items: center;
    justify-content: flex-end; /* <--- Forces buttons to stay pinned to the right */
    gap: 15px;
}

/* Keeps the "hours set" warning text right-aligned to match the buttons */
#gwl-hours-warning {
    justify-content: flex-end;
}

.gwl-enlisted-badge {
    color: #28a745;
    font-weight: bold;
    font-size: 16px;
    text-transform: uppercase;
    border: 2px solid #28a745;
    padding: 13px 20px;
    border-radius: 4px;
    display: inline-block;
}

.gwl-btn-join-solo {
    background: #28a745;
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    padding: 15px 35px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}

.gwl-btn-withdraw {
    background: transparent;
    color: #ff4444;
    font-size: 13px;
    font-weight: bold;
    padding: 10px 20px;
    border: 1px solid #ff4444;
    border-radius: 4px;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s;
}

.gwl-btn-withdraw:hover {
    background: #ff4444;
    color: #fff;
}

.gwl-btn-draft-roster {
    background: #007bff;
    color: #fff;
    font-size: 16px;
    font-weight: bold;
    padding: 15px 35px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-transform: uppercase;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
}

/* Section Headings */
.gwl-hub-section-heading {
    color: #007bff;
    border-bottom: 2px solid #222;
    padding-bottom: 10px;
    margin-top: 0;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-size: 1.2rem;
}

.gwl-heading-gold {
    color: #dd9933 !important;
}

/* Rules & Participants Boxes */
.gwl-hub-rules-box {
    background: #151515;
    padding: 30px;
    border-radius: 8px;
    color: #ddd;
    line-height: 1.7;
    font-size: 15px;
    border: 1px solid #222;
}

.gwl-hub-rules-empty {
    color: #666;
    font-style: italic;
}

.gwl-hub-participants-wrapper {
    margin-top: 40px;
}

.gwl-hub-participants-box {
    background: #111;
    padding: 20px;
    border-radius: 8px;
    border: 1px solid #222;
}

.gwl-hub-participants-empty {
    color: #666;
    font-style: italic;
    margin: 0;
    text-align: center;
}

/* Operation Intel Sidebar */
.gwl-hub-intel-box {
    background: #111;
    padding: 25px;
    border-radius: 8px;
    border: 1px solid #222;
}

.gwl-hub-intel-list {
    list-style-type: none;
    padding: 0;
    margin: 0;
    color: #aaa;
    font-size: 14px;
}

.gwl-hub-intel-item {
    margin-bottom: 15px;
    border-bottom: 1px solid #222;
    padding-bottom: 15px;
    display: flex;
    justify-content: space-between;
}

.gwl-hub-intel-item:last-child {
    margin-bottom: 0;
    border-bottom: none;
    padding-bottom: 0;
}

.gwl-hub-intel-label {
    color: #007bff;
}

.gwl-hub-intel-data {
    color: #dd9933;
    font-weight: bold;
}

/* ============================================================================
   LADDER STANDINGS ENGINE
   ============================================================================ */
.gwl-standings-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.gwl-standings-header {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    background: #1a1a1a;
    border-bottom: 2px solid #333;
    color: #007bff; /* Swapped from #888 to Blue */
    font-size: 12px;
    text-transform: uppercase;
    font-weight: bold;
    letter-spacing: 1px;
}

.gwl-standings-row {
    display: flex;
    align-items: center;
    padding: 12px 15px;
    background: rgba(255,255,255,0.02);
    border-radius: 4px;
    border-left: 3px solid #333;
    transition: background 0.2s, border-color 0.2s;
}

.gwl-standings-row:hover {
    background: rgba(255,255,255,0.05);
    border-left: 3px solid #dd9933; /* Gold hover indicator */
}

/* Zebra striping for alternating rows */
.gwl-standings-container .gwl-standings-row:nth-child(even) {
    background: rgba(255, 255, 255, 0.04);
}

/* Flex Grid Columns (Upgraded for Matchmaking) */
.gwl-st-rank { width: 75px; text-align: left; padding-left: 5px; }

.gwl-st-name { 
    width: 220px; 
    font-weight: bold; 
    font-size: 16px; 
    white-space: nowrap;         /* Forces the text to stay on one single line */
    overflow: hidden;            /* Hides anything that spills outside the 220px width */
    text-overflow: ellipsis;     /* Adds the "..." at the cut-off point */
    padding-right: 15px;         /* Adds a buffer so long names don't touch the Status text */
}

.gwl-st-status { 
    flex-grow: 1; 
    font-size: 13px; 
    font-style: italic; 
    padding-right: 15px; 
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center; /* Centers the stacked text horizontally */
    text-align: center;  /* Ensures the header text is also centered */
}

/* The Opponent's Name (2nd Line of Status) */
.gwl-status-opp-link {
    font-size: 14px;
    font-weight: bold;
    color: #98cb00;
    text-decoration: none;
    margin-top: 2px;
    white-space: nowrap;         
    overflow: hidden;            
    text-overflow: ellipsis; 
    max-width: 150px; /* Prevents long names from pushing the action column */
    font-style: normal; /* Removes the italic from the parent status text */
}

.gwl-status-opp-link:hover {
    color: #b5f000;
    text-decoration: underline;
}

.gwl-st-action { width: 110px; text-align: center; } /* Reserved for Challenge buttons */
.gwl-st-record { width: 100px; text-align: center; color: #ccc; }
.gwl-st-elo { width: 80px; text-align: right; color: #dd9933; font-weight: bold; font-size: 16px; }

/* Force the W-L header to be blue and slightly larger */
.gwl-standings-header .gwl-st-record {
    color: #007bff;
    font-size: 14px; 
}

/* ============================================================================
   MATCHMAKING BUTTONS & STATUS
   ============================================================================ */

/* The Auto-Match Button in the Header */
.gwl-btn-automatch {
    background: #007bff;
    color: #fff;
    border: none;
    padding: 6px 15px;
    font-size: 12px;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    text-transform: uppercase;
    transition: background 0.2s;
}

.gwl-btn-automatch:hover {
    background: #0056b3;
}

/* The Challenge Button in the Rows */
.gwl-btn-challenge {
    background: #007bff;
    color: #fff;
    border: none;
    padding: 6px 15px;
    font-size: 12px;
    font-weight: bold;
    border-radius: 4px;
    cursor: pointer;
    text-transform: uppercase;
    transition: background 0.2s;
}

.gwl-btn-challenge:hover {
    background: #0056b3;
}

/* Status Text Colors */
.gwl-status-available { color: #28a745; }
.gwl-status-busy { color: #dd9933; }
.gwl-status-penalized { color: #ff4444; }
.gwl-status-white { color: #fff; font-weight: bold; } /* Added for Pre-Deployment & Active Challenges */

/* Admin Console Buttons */
#gwl-reset-competition-btn:hover { background: #ff4444 !important; color: #fff !important; }
#gwl-archive-competition-btn:hover { background: #dd9933 !important; color: #000 !important; }

/* Styling Elements */
.gwl-rank-badge {
    background: #222;
    color: #dd9933; /* Swapped from #fff to Gold */
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: bold;
    border: 1px solid #444;
}

.gwl-toxic-link {
    color: #98cb00;
    text-decoration: none;
    transition: color 0.2s;
}

.gwl-toxic-link:hover {
    color: #b5f000;
    text-decoration: underline;
}

/* ============================================================================
   RULES ACCORDION
   ============================================================================ */
.gwl-accordion-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #111;
    padding: 15px 20px;
    border-radius: 4px;
    border: 1px solid #222;
    border-left: 3px solid #007bff;
    cursor: pointer;
    margin-bottom: 10px;
    transition: background 0.2s;
}

.gwl-accordion-header:hover {
    background: #151515;
}

.gwl-accordion-arrow {
    color: #007bff;
    font-size: 14px;
    transition: transform 0.3s ease;
}

/* When JS adds this class, the arrow rotates pointing up */
.gwl-accordion-arrow.is-open {
    transform: rotate(180deg);
}

/* Adjust the rules box so it sits flush under the accordion header */
.gwl-hub-rules-box.gwl-accordion-content {
    margin-top: -10px;
    margin-bottom: 20px;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-top: none;
}

/* ============================================================================
   AVAILABILITY SCHEDULER
   ============================================================================ */
.gwl-avail-header {
    margin-top: 15px;
    border-left: 3px solid #007bff; /* Swapped to Blue */
}

.gwl-avail-content {
    background: #111;
    padding: 20px;
    border: 1px solid #222;
    border-top: none;
    border-radius: 0 0 4px 4px;
}

.gwl-avail-label {
    display: block;
    color: #007bff;
    font-size: 12px;
    text-transform: uppercase;
    font-weight: bold;
    margin-bottom: 8px;
}

.gwl-avail-days-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.gwl-day-checkbox {
    background: #1a1a1a;
    color: #ccc;
    padding: 6px 12px;
    border: 1px solid #333;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.gwl-day-checkbox:hover {
    background: #222;
    border-color: #555;
}

.gwl-day-checkbox input[type="checkbox"] {
    margin-right: 5px;
}

.gwl-avail-input {
    width: 100%;
    padding: 8px;
    background: #1a1a1a;
    color: #fff;
    border: 1px solid #333;
    border-radius: 4px;
}

/* Fix browser defaults on time inputs so they match the dark theme */
.gwl-avail-input::-webkit-calendar-picker-indicator {
    filter: invert(1);
    cursor: pointer;
}

/* Base styling for the action panel (Adds your 30px breathing room normally) */
#gwl-hub-action-panel {
    margin-top: 30px; 
}

/* Dynamic Action Panel Expansion (Forces the drop down ONLY when Custom Hours are open) */
#gwl-hub-action-panel.gwl-panel-expanded {
    flex-basis: 100%; 
    margin-top: 30px;
}

/* Mode Toggle Radios */
.gwl-avail-mode-toggle {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px dashed #333;
}

.gwl-radio-label {
    color: #ccc;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}

.gwl-radio-label input[type="radio"] {
    accent-color: #007bff; /* Tints the radio button blue */
    cursor: pointer;
}

/* Custom Day Rows - Upgraded to Responsive Multi-Column Grid */
.gwl-custom-days-wrapper {
    display: grid;
    /* This tells the browser: "Make as many columns as will fit, but never smaller than 310px" */
    grid-template-columns: repeat(auto-fit, minmax(310px, 1fr));
    gap: 12px;
}

.gwl-custom-day-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #1a1a1a;
    padding: 8px 12px;
    border: 1px solid #333;
    border-radius: 4px;
}

.gwl-custom-check {
    margin: 0;
    width: 70px; /* Trimmed slightly to give the time inputs more room */
}

.gwl-custom-time-inputs {
    display: flex;
    align-items: center;
    transition: opacity 0.3s;
}

.gwl-custom-time-inputs .gwl-avail-input {
    width: 105px; /* Shaved 5px off so it fits perfectly in the new grid columns */
    padding: 5px;
    font-size: 13px;
}

/**
 * ============================================================================
 * MOBILE RESPONSIVENESS (BELOW 800PX)
 * ============================================================================
 */
@media (max-width: 800px) {
    
    /* 1. Stack the Main Layout Grid (Fixes the Squeezed Intel Sidebar) */
    .gwl-hub-grid {
        /* Forces the 2fr/1fr layout to become a single full-width column, 
           dropping the Intel sidebar safely below the main content */
        grid-template-columns: 1fr; 
        gap: 20px;
    }

    /* ========================================================================
       2. CONVERT LADDER STANDINGS INTO MOBILE CARDS
       ======================================================================== */
       
    .gwl-standings-header {
        display: none; /* Hide the standard column headers */
    }

    .gwl-standings-row {
        /* Keep it as flex, but allow the children inside to wrap to new lines */
        display: flex;
        flex-wrap: wrap;
        margin-bottom: 20px;
        border: 1px solid #333;
        border-left: 3px solid #007bff; /* Moves the blue highlight to the card edge */
        border-radius: 6px;
        padding: 0;
        background: #111;
    }

    /* Keep the Rank and Name side-by-side at the top like a header */
    .gwl-st-rank {
        width: auto;
        padding: 15px 10px 15px 15px;
    }
    
    .gwl-st-name {
        flex-grow: 1; /* Takes up the rest of the top row */
        width: auto;
        padding: 15px 15px 15px 0;
        white-space: normal; /* Allows super long names to wrap if needed */
        display: flex; /* NEW: Use flexbox inside the name container */
        justify-content: center; /* NEW: Pushes the player name to the absolute center of the available space */
        align-items: center; /* NEW: Keeps it vertically aligned with the rank badge */
    }

    /* Force the Status to drop to a new line, stack vertically, and pin to the right */
    .gwl-st-status {
        position: relative; 
        display: flex !important; 
        flex-direction: column !important; /* Forces all children to stack like a tower */
        align-items: flex-end !important; /* Shoves the entire tower against the right wall */
        justify-content: center;
        width: 100%;
        padding: 12px 15px 12px 85px; 
        border-top: 2px solid #333;
        border-bottom: 1px solid #222;
        line-height: 1.4; 
    }

    /* Pin the Status label to the left and mathematically center it vertically */
    .gwl-st-status::before {
        content: "Status";
        position: absolute; 
        left: 15px; 
        top: 50%; 
        transform: translateY(-50%); /* Keeps it perfectly centered regardless of how many lines of text are on the right */
        color: #007bff;
        font-size: 11px;
        text-transform: uppercase;
        font-weight: bold;
    }

    /* Strip any hidden theme margins and force the text to comply */
    .gwl-st-status a,
    .gwl-st-status strong,
    .gwl-st-status span {
        display: block !important;
        margin: 1px 0 !important; /* Strips theme margins, applies a uniform 1px gap */
        text-align: right !important;
        width: auto !important; /* Prevents the elements from stretching to 100% and breaking the flex-end alignment */
    }

    /* Force the Action buttons to drop to a new line */
    .gwl-st-action {
        width: 100%;
        padding: 10px 15px;
        text-align: center; /* Centered for fallback */
        border-bottom: 1px solid #222;
        display: flex;
        justify-content: center; /* CHANGED: This pulls the Wiretap button (and all other challenge buttons) to the absolute center */
    }

    /* If they aren't in a match and have no action buttons, hide the empty padding */
    .gwl-st-action:empty {
        display: none;
    }

    /* Format Record and Elo as clean, spread-out data rows */
    .gwl-st-record, 
    .gwl-st-elo {
        display: flex;
        justify-content: space-between; /* Pushes the generated label left, data right */
        align-items: center;
        width: 100%;
        padding: 12px 15px;
        text-align: right;
    }

    .gwl-st-record {
        border-bottom: 1px solid #222;
    }

    /* Inject labels dynamically using CSS so we don't have to change the PHP */
    .gwl-st-record::before {
        content: "Record (W-L)";
        color: #007bff;
        font-size: 11px;
        text-transform: uppercase;
        font-weight: bold;
    }

    .gwl-st-elo::before {
        content: "Elo Rating";
        color: #007bff;
        font-size: 11px;
        text-transform: uppercase;
        font-weight: bold;
    }

    /* ========================================================================
       3. MOBILE TYPOGRAPHY UPSCALING
       ======================================================================== */
       
    /* Bump up the blue generated row headings */
    .gwl-st-status::before,
    .gwl-st-record::before,
    .gwl-st-elo::before {
        font-size: 13px !important; /* Scaled up from 11px */
    }

    /* Squeak the main player heading (Rank and Name) up a notch */
    .gwl-st-rank,
    .gwl-st-rank span,
    .gwl-st-name,
    .gwl-st-name a {
        font-size: 18px !important; /* Larger, more authoritative header text */
    }

}

/* ========================================================================
   4. LADDER ACTIVITY LOG UI
   ======================================================================== */
.gwl-activity-log-container {
    width: 100%;
    max-height: 400px; /* Forces the box to contain only roughly ~10 logs visually, triggering scroll for the rest */
    overflow-y: auto;  /* Enables vertical scrolling */
    background: #111;
    border: 1px solid #333;
    border-radius: 6px;
    padding: 10px 15px;
    
    /* Firefox Custom Scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: #007bff #151515;
}

/* Chrome/Edge Custom Scrollbar styling */
.gwl-activity-log-container::-webkit-scrollbar {
    width: 8px;
}
.gwl-activity-log-container::-webkit-scrollbar-track {
    background: #151515;
    border-radius: 0 6px 6px 0;
}
.gwl-activity-log-container::-webkit-scrollbar-thumb {
    background-color: #007bff;
    border-radius: 4px;
}

.gwl-activity-log-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

/* Individual Log Entry Styling */
.gwl-log-entry {
    display: flex;
    align-items: flex-start;
    padding: 12px 15px; /* Added 15px horizontal padding to pull the text away from the left margin */
    border-bottom: 1px dashed #222;
    font-size: 16px;
    color: #ccc;
    transition: background-color 0.2s ease;
}

.gwl-log-entry:last-child {
    border-bottom: none;
}

/* On hover, slightly highlight the row so it's easy to read across */
.gwl-log-entry:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

/* The Timestamp styling */
.gwl-log-time {
    color: #dd9933; /* Uses the same gold from your primary headings */
    font-weight: bold;
    white-space: nowrap;
    margin-right: 15px;
    min-width: 130px; /* Keeps the messages aligned evenly regardless of date string length */
}

.gwl-log-message {
    line-height: 1.5;
}

/* Allows you to wrap player names in <strong> tags when inserting to the DB to highlight them in blue */
.gwl-log-message strong {
    color: #007bff; 
    font-weight: bold;
}