/* --- Global Reset & Core Body --- */
* {
    box-sizing: border-box;
}

body { 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    color: #e0e0e0; 
    font-size: 12px; 
    background-color: #0c0c0c; /* Deep Magicbane Black */
    margin: 0;
    padding: 0;
}

/* --- Typography & Links --- */
font { 
    font-family: inherit; 
    color: #a3b8cc; 
}

a { 
    color: #ff4d4d; /* Crimson highlight for links */
    text-decoration: none;
    transition: color 0.2s ease;
}

a:hover { 
    color: #ffffff; 
}

/* --- Table & Container Styling --- */
table {
    border-collapse: collapse;
    margin: 10px auto; /* Centered tables */
}

td { 
    font-family: inherit; 
    color: #e0e0e0; 
    font-size: 12px; 
    background-color: #181818; /* Dark Charcoal cells */
    border: 1px solid #2a2a2a; /* Subtle separator borders */
    padding: 6px 10px;
}

/* --- Form Inputs & Dropdowns --- */
input[type="text"], select {
    background-color: #242424;
    color: #ffffff;
    border: 1px solid #444444;
    padding: 4px 6px;
    font-family: inherit;
    font-size: 12px;
    border-radius: 3px;
    vertical-align: middle;
}

input[type="text"]:focus, select:focus {
    border-color: #ff4d4d;
    outline: none;
}

input[readonly] {
    background-color: #121212;
    color: #ffffff; /* Keep stats highly visible */
    border-color: #222222;
}

/* --- Core Button Fixes (Min/Max, +/- Adjustments) --- */
button, input[type="button"] {
    background-color: #2a2a2a;
    color: #ffffff;
    border: 1px solid #555555;
    padding: 4px 12px;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    border-radius: 3px;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    vertical-align: middle;
}

/* Specific fix for wide tool buttons like Remove Rune */
form[name="runes"] input[type="button"],
input[type="button"][value="Remove Rune"] {
    width: 220px !important;  /* Keep the requested legacy width structural footprint */
    height: 28px;             /* Give it some clean vertical thickness */
    padding: 4px 12px !important;
    display: inline-block;    /* Break it out of flex alignment so text wraps/renders naturally */
    text-align: center;
}

/* Specific fix for the tiny +/- attribute stat buttons */
td form input[type="button"] {
    width: 22px !important;
    height: 22px !important;
    padding: 0 !important;
    font-weight: bold;
    font-size: 14px;
    line-height: 1;
}

/* Specific fix for Min/Max buttons to prevent compression */
td input[type="button"][value="Min"], 
td input[type="button"][value="Max"] {
    min-width: 40px;
    height: 22px;
    padding: 0 4px !important;
    font-size: 11px;
}

button:hover, input[type="button"]:hover {
    background-color: #ff4d4d;
    border-color: #ff8080;
}

/* --- Misc Section Uniformity (Radios & Checkboxes) --- */
input[type="radio"], input[type="checkbox"] {
    margin: 4px;
    vertical-align: middle;
    cursor: pointer;
    accent-color: #ff4d4d; /* Modern browser support to turn circles/squares red */
}

/* --- Custom Layout Headers --- */
.navhead { 
    display: block; 
    padding: 8px; 
    border: 1px solid #ff4d4d; 
    background: #1a0505; 
    color: #ffffff; 
    font-weight: bold; 
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.contenthead { 
    display: block; 
    padding: 12px; 
    border: 1px solid #2a2a2a; 
    background: #111111; 
    color: #ffffff; 
    font-weight: bold; 
    text-align: left;
    font-size: 16px;
}

/* --- Modern Tab Architecture --- */
ul#tabs { 
    list-style-type: none; 
    margin: 20px auto 0 auto; 
    padding: 0; 
    display: flex;
    gap: 4px;
    border-bottom: 2px solid #2a2a2a;
    max-width: 950px; /* Constrains the builder interface to a clean desktop view */
} 

ul#tabs li {
    margin: 0;
}

ul#tabs li a { 
    display: block;
    color: #888888; 
    background-color: #181818; 
    padding: 8px 16px; 
    text-decoration: none; 
    border: 1px solid #2a2a2a;
    border-bottom: none;
    border-top-left-radius: 4px;
    border-top-right-radius: 4px;
    transition: all 0.2s ease;
}

ul#tabs li a:hover { 
    background-color: #242424; 
    color: #ffffff;
}

ul#tabs li a.selected { 
    color: #ffffff; 
    font-weight: bold; 
    background-color: #242424;
    border-color: #ff4d4d;
    border-bottom: 2px solid #242424; /* Seamless blend with active panel */
    transform: translateY(2px);
}

div.tabContent { 
    max-width: 950px;
    margin: 0 auto;
    padding: 15px; 
    background-color: #242424;
    border: 1px solid #2a2a2a;
    border-top: none;
}

div.tabContent.hide { 
    display: none; 
}

/* --- Tooltips & Floating Containers --- */
.xstooltip, .xstooltip2 {
    visibility: hidden; 
    position: absolute; 
    top: 0;  
    left: 0; 	
    background-color: #181818;
    border: 1px solid #ff4d4d;
    padding: 12px;
    box-shadow: 0px 4px 15px rgba(0,0,0,0.7);
    z-index: 999;
}

/* --- Tighten Layout Spacing & Dead Space --- */

/* Force layout tables to fit content snugly instead of stretching across the screen */
div.tabContent table {
    width: auto !important;
    max-width: 100%;
    margin: 5px auto;
}

/* Eliminate excessive cell padding causing the giant vertical gaps */
div.tabContent td {
    padding: 4px 8px !important;
}

/* Target the Applied Runes form column specifically to eliminate the gap next to Stats */
form[name="runes"] {
    margin-top: 10px;
    display: inline-block;
}

/* Shrink the massive vertical footprint under the Disciplines and Traits areas */
div.tabContent { 
    max-width: 900px;
    min-height: auto !important; /* Overrides any massive hardcoded minimum heights */
    padding: 10px 15px; 
}

/* Tighten up select boxes and input lists so they pack together tightly */
#appliedrunes {
    width: 220px !important;
    height: 140px !important; /* Keeps the list box compact and professional */
    margin-bottom: 5px;
}

/* Collapse empty or spacer cells that the original developer used for formatting */
td[width="1%"], td:empty {
    display: none !important;
}

/* --- Force Legacy Grid Layout to Collapse and Snap Together --- */

/* Target the layout table rows inside the tabs and strip their rigid tabular behavior */
#statsTab tbody, 
#traitsTab tbody, 
#runesTab tbody, 
#disciplinesTab tbody {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px; /* Adds a tight, clean gap between elements instead of a massive void */
}

#statsTab tr, 
#traitsTab tr, 
#runesTab tr, 
#disciplinesTab tr {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
}

#statsTab td, 
#traitsTab td, 
#runesTab td, 
#disciplinesTab td {
    display: block; /* Turns off table cell stretching completely */
    background-color: transparent !important; /* Removes blocky nested table backgrounds */
    border: none !important;
    padding: 0 !important;
    width: auto !important;
    height: auto !important;
}

/* Re-apply the clean dark background styling strictly to the actual data calculation tables */
#statsTab table, 
#traitsTab table, 
#runesTab table, 
#disciplinesTab table,
#skillTable,
#powerTable {
    background-color: #181818 !important;
    border: 1px solid #2a2a2a !important;
    border-collapse: collapse !important;
    width: auto !important;
}

/* Ensure the sub-table cells keep their proper visual padding and borders */
#statsTab table td, 
#traitsTab table td, 
#runesTab table td, 
#disciplinesTab table td,
#skillTable td,
#powerTable td {
    display: table-cell !important; /* Keeps the actual calculations rendering beautifully */
    background-color: #181818 !important;
    border: 1px solid #2a2a2a !important;
    padding: 6px 10px !important;
}

/* Center and snug the layout elements under the Traits sub-navigation */
#traitTabs table {
    margin: 10px auto !important;
}

/* --- Safe UI Padding & Vertical Gap Crunching --- */

/* 1. Force all primary table cells to align contents to the top */
center table td, 
.tabContent td {
    vertical-align: top !important;
    height: auto !important;
}

/* 2. Target the specific tables used for layout inside the tabs */
.tabContent > table {
    height: auto !important;
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    border-spacing: 0 !important;
}

/* 3. Ensure the active tab contents shrink-wrap their children vertically */
div.tabContent {
    min-height: 0 !important;
    height: auto !important;
    padding-bottom: 10px !important;
}

/* 4. Tighten up the specific Applied Runes form box */
form[name="runes"] {
    margin: 0 !important;
    padding: 0 !important;
}

#appliedrunes {
    height: 130px !important; /* Locks the listbox footprint to a compact size */
}

/* 5. Force the main wrapper table cells to drop extra vertical room */
td[valign="top"] {
    padding-bottom: 0 !important;
}

/* --- Deep Vertical Space Reduction --- */

/* 1. Target the giant hidden container height in the Traits section */
#traitTabs {
    height: auto !important;
    min-height: 0 !important;
    padding-bottom: 0 !important;
    margin-bottom: 0 !important;
}

/* 2. Force the inner trait content containers to shrinkwrap tightly */
#traitTabs > div {
    height: auto !important;
    min-height: 0 !important;
    padding: 5px 0 !important;
}

/* 3. Force the parent layout row holding Stats & Applied Runes to drop extra height */
#statsTab > table,
#traitsTab > table,
#runesTab > table,
#disciplinesTab > table {
    height: auto !important;
    margin-bottom: 0 !important;
}

/* 4. Target the massive cell containers that house the modules */
.tabContent > table > tbody > tr > td {
    height: auto !important;
    padding-bottom: 0 !important;
    vertical-align: top !important;
}

/* 5. Clean up any lingering bottom margin/padding inside the main tab blocks */
div.tabContent {
    height: auto !important;
    min-height: 0 !important;
    padding-bottom: 5px !important;
}

/* --- Kill the 2003 Hardcoded Break Tag Spacers --- */

#traitButtons br,
#level75Buttons br,
ul#tabs br {
    display: none !important;
    content: "" !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Ensure the list items themselves stack cleanly without needing <br> tags */
#traitButtons li,
#level75Buttons li {
    display: block;
    margin-bottom: 2px; /* Controlled, clean gap between button links */
}

/* --- Final Polishing: Vertical Alignment & Controlled Gaps --- */

/* 1. Vertically center the Applied Runes column box within its row space */
td[colspan="3"][rowspan="2"] {
    vertical-align: middle !important; /* Changes from top alignment to dead center */
}

/* 2. Add controlled spacing exactly where those 17 <br> tags used to live */
#traitButtons,
#level75Buttons {
    margin-bottom: 12px !important; /* Creates a clean, crisp gap before the trait options display */
    padding-bottom: 4px;
    border-bottom: 1px dashed #2a2a2a; /* Optional: Adds a subtle separator line under the headers */
}

/* 3. Ensure the dynamic trait options container sits nicely below that gap */
#traitTabs {
    margin-top: 5px !important;
}