/* --- SHARED VARIABLES --- */
:root {
    --primary: #3b82f6; 
    --primary-glow: rgba(59, 130, 246, 0.5);
    --bg-gradient: radial-gradient(circle at top right, #1e293b, #0f172a, #000);
    --glass: rgba(255, 255, 255, 0.03);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text: #f8fafc;
    --muted: #94a3b8;
}

/* --- UNIFIED HOME BUTTON --- */
.home-link {
    position: fixed; left: 20px; top: 20px; z-index: 1001;
    background: var(--glass); backdrop-filter: blur(15px);
    border: 1px solid var(--glass-border); color: white;
    padding: 12px 20px; border-radius: 12px;
    text-decoration: none; font-weight: 800; font-size: 0.75rem;
    text-transform: uppercase; transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}
.home-link:hover {
    background: var(--primary);
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 0 20px var(--primary-glow);
}

/* --- UNIFIED ADMIN MODAL --- */
#authModal {
    display:none; position:fixed; inset:0; background:rgba(0,0,0,0.85);
    backdrop-filter: blur(20px); align-items:center; justify-content:center; z-index:2000;
}
.modal-content {
    background: rgba(30, 41, 59, 0.7); border: 1px solid var(--glass-border);
    padding: 40px; border-radius: 30px; width: 340px; text-align: center;
    box-shadow: 0 0 50px rgba(0,0,0,0.5);
}
.modal-content h2 { 
    font-weight: 900; letter-spacing: -1px; margin-top: 0; color: white; 
    text-transform: uppercase; margin-bottom: 25px;
}
.modal-input {
    width: 100%; background: rgba(0,0,0,0.3); border: 1px solid var(--glass-border);
    padding: 14px; border-radius: 12px; color: white; margin-bottom: 12px;
    box-sizing: border-box; outline: none; font-weight: 600;
}
.modal-input:focus { border-color: var(--primary); }

/* --- UNIFIED SORT BAR --- */
.sort-bar, .sort-row {
    display: flex; gap: 10px; flex-wrap: wrap; justify-content: center;
    padding: 20px 0; border-top: 1px solid var(--glass-border);
    margin-top: 20px;
}
.sort-btn {
    background: var(--glass); border: 1px solid var(--glass-border);
    color: var(--muted); padding: 10px 18px; border-radius: 30px;
    font-size: 0.7rem; font-weight: 800; cursor: pointer;
    text-transform: uppercase; transition: 0.3s;
}
.sort-btn:hover { background: rgba(255,255,255,0.08); color: white; }
.sort-btn.active {
    background: var(--primary); color: white; border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
}
.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 15px var(--primary-glow);
}
/* --- DROPDOWN & SELECT STYLING --- */
select {
    background-color: #0f172a !important; /* Deep Navy/Black */
    color: #f8fafc !important; /* Bright White Text */
    border: 1px solid var(--glass-border) !important;
    border-radius: 12px;
    padding: 10px 15px;
    cursor: pointer;
    outline: none;
    font-weight: 600;
    transition: all 0.3s ease;
}

/* This targets the actual list that opens up */
select option {
    background-color: #0f172a; /* Dark background for the list */
    color: #ffffff; /* White text for choices */
    padding: 10px;
}

/* Hover effect for the menu */
select:hover {
    border-color: var(--primary) !important;
    background-color: #1e293b !important; /* Slightly lighter slate on hover */
}

/* Focus effect when the menu is open */
select:focus {
    border-color: var(--primary) !important;
    box-shadow: 0 0 15px var(--primary-glow);
}


/* --- REUSABLE PAGE TITLE --- */
.page-title-main {
    font-size: 3.2rem;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: -1px;
    background: linear-gradient(to bottom, #ffffff, #94a3b8);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin: 0;
    text-shadow: 0 0 30px rgba(59, 130, 246, 0.2);
}

/* --- EXPANDABLE TROOP ROW --- */
.troop-row-container {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
}

.troop-row-container.open {
    max-height: 100px;
    opacity: 1;
    margin-top: 5px;
}

.toggle-trigger {
    width: 100%;
    display: flex;
    justify-content: center;
    cursor: pointer;
    padding-top: 5px;
    color: var(--muted);
    transition: 0.3s;
}

.toggle-trigger:hover { color: var(--primary); }

.toggle-trigger svg {
    width: 20px;
    height: 20px;
    transition: transform 0.3s;
}

.toggle-trigger.open svg { transform: rotate(180deg); }

/* This makes the container a scrollable window */
.table-wrapper {
    width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    /* This makes scrolling smooth on iPhones */
    -webkit-overflow-scrolling: touch; 
    margin-bottom: 20px;
    border-radius: 15px; /* Matches your card style */
}

/* This prevents the table from shrinking too small to read */
table {
    min-width: 800px; /* Adjust this based on how much data you have */
    border-collapse: collapse;
}


/* --- STICKY COLUMN LOGIC --- */

/* Kingdom ID Column (The first one) */
.sticky-col-kd {
    position: sticky !important;
    left: 0;
    z-index: 20; /* High enough to stay above normal rows */
    background: #0f172a !important; /* Must be solid color, not transparent */
    width: 80px; /* Fixed width ensures the next column lines up */
    min-width: 80px;
}
/* --- CLEAN STICKY COLUMNS --- */

/* 1. The Kingdom ID Column */
.sticky-col-kd {
    position: sticky !important;
    left: 0;
    z-index: 30; 
    background-color: #0f172a !important; /* Solid dark color to hide sliding numbers */
    width: 70px;
    min-width: 70px;
    border-right: 1px solid var(--glass-border) !important;
}

/* 2. The Alliance Column */
.sticky-col-ally {
    position: sticky !important;
    left: 70px; /* Must match width of KD column */
    z-index: 30;
    background-color: #0f172a !important; /* Solid dark color */
    width: 180px;
    min-width: 180px;
    border-right: 1px solid var(--primary) !important; /* A thin divider line */
    text-align: left !important;
    padding-left: 10px !important;
}

/* 3. Ensure Headers stay on top */
th.sticky-col-kd, th.sticky-col-ally {
    z-index: 31;
    background-color: #1e293b !important; /* Slightly lighter for the header row */
}

/* 4. Fix the "Look": Remove any weird blue highlights or default borders */
.sticky-col-kd, .sticky-col-ally {
    box-shadow: none !important;
    outline: none !important;
}

/* 5. The "Labels" for Total A/B in special rows */
.sticky-special-label {
    position: sticky !important;
    left: 0;
    z-index: 30;
    background-color: inherit; /* Inherit the row's special color (purple/blue) */
    text-align: left !important;
    padding-left: 15px !important;
    font-weight: 900;
}