/**
 * components.css - Shared component styles
 *
 * Extracted from inline styles across multiple pages to eliminate duplication.
 * All styles use CSS variables defined in styles.css.
 */

/* ==========================================================================
   Back Link
   Used on: gear.html, crafting.html, table.html, weapons-table.html,
            weapon.html, horse.html, loadout.html, admin.html
   ========================================================================== */

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--rust);
    text-decoration: none;
    margin-bottom: 12px;
    font-size: 0.95rem;
    min-height: 44px;
    padding: 8px 0;
}

.back-link:hover {
    color: var(--red-primary);
    text-decoration: underline;
}

.back-link:active {
    opacity: 0.7;
}

/* ==========================================================================
   Header Full (Hub pages with auth)
   Positions auth container in top-right, back link left-aligned above title
   ========================================================================== */

.header-full {
    position: relative;
    text-align: center;
}

.header-full .auth-container {
    position: absolute;
    top: 0;
    right: 0;
}

.header-full .back-link,
.header-simple .back-link {
    display: block;
    text-align: left;
    margin-bottom: 8px;
}

/* Mobile: two-row header layout */
@media (max-width: 600px) {
    .header-full {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        text-align: center;
    }

    /* Row 1: back link (left) + avatar (right) */
    .header-full .back-link {
        order: 1;
        flex: 1;
        margin-bottom: 0;
        min-height: 44px;
        display: inline-flex;
        align-items: center;
    }

    .header-full .auth-container {
        order: 2;
        position: static;
        flex-shrink: 0;
        margin-left: auto;
    }

    /* Row 2: title centered, full width */
    .header-full h1 {
        order: 3;
        width: 100%;
        margin-top: 8px;
    }

    /* Row 3: subtitle if present */
    .header-full .subtitle {
        order: 4;
        width: 100%;
    }
}

/* ==========================================================================
   Search Input
   Used on: gear.html, crafting.html, table.html, weapons-table.html
   ========================================================================== */

.search-input {
    width: 100%;
    padding: 12px 16px;
    font-size: 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border-medium);
    border-radius: 6px;
    color: var(--text-cream);
    font-family: 'Crimson Text', serif;
    height: 48px;
    box-sizing: border-box;
}

.search-input:focus {
    outline: none;
    border-color: var(--rust);
}

.search-input::placeholder {
    color: var(--text-muted);
}

/* ==========================================================================
   Data Table (Base Styles)
   Used on: gear.html, crafting.html, table.html, weapons-table.html

   Apply .data-table to tables, or use existing class names which inherit
   these base patterns through the page-specific selectors.
   ========================================================================== */

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-card);
    border-radius: 8px;
    overflow: hidden;
}

.data-table th {
    background: var(--bg-elevated);
    color: var(--rust);
    font-family: 'Rye', cursive;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 10px;
    text-align: left;
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    border-bottom: 2px solid var(--border-medium);
}

.data-table th:hover {
    background: var(--bg-dark);
    color: var(--red-primary);
}

.data-table td {
    padding: 12px 10px;
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-cream);
    font-size: 0.95rem;
    vertical-align: middle;
    line-height: 1.4;
}

.data-table tr:hover {
    background: var(--bg-elevated);
}

.data-table tr:last-child td {
    border-bottom: none;
}

/* Sort indicators - works on any table header */
.sorted-asc::after {
    content: ' ▲';
    font-size: 0.7rem;
}

.sorted-desc::after {
    content: ' ▼';
    font-size: 0.7rem;
}

/* ==========================================================================
   Table Scroll Wrapper (Mobile Horizontal Scroll with Shadow)
   Used on: gear.html, crafting.html, table.html, weapons-table.html
   ========================================================================== */

.table-outer-wrapper {
    position: relative;
}

.table-scroll-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Fade shadow on right edge to indicate more content */
.table-outer-wrapper::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 30px;
    background: linear-gradient(to right, transparent, var(--bg-dark));
    pointer-events: none;
    z-index: 10;
    opacity: 1;
    transition: opacity 0.2s;
}

/* Hide shadow when scrolled to end */
.table-outer-wrapper.scrolled-end::after {
    opacity: 0;
}

/* ==========================================================================
   Sticky First Column (for tables on mobile)
   Apply .sticky-first-col to table for sticky first column behavior
   ========================================================================== */

.sticky-first-col th:first-child,
.sticky-first-col td:first-child {
    position: sticky;
    left: 0;
    z-index: 2;
    background: var(--bg-elevated);
}

.sticky-first-col td:first-child {
    background: var(--bg-card);
}

.sticky-first-col tr:hover td:first-child {
    background: var(--bg-elevated);
}

/* ==========================================================================
   Stat Box (Base → Max display with progress bars)
   Used on: weapon.html, horse.html, and card displays
   ========================================================================== */

.stat-box {
    text-align: center;
    padding: 15px 10px;
    background: var(--bg-dark);
    border-radius: 6px;
    border: 1px solid var(--border-subtle);
}

.stat-box .stat-name {
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.stat-box .stat-values {
    font-family: 'Rye', cursive;
}

.stat-box .stat-base {
    color: var(--text-muted);
    font-size: 1rem;
}

.stat-box .stat-arrow {
    color: var(--text-muted);
    margin: 0 3px;
    font-size: 0.8rem;
}

.stat-box .stat-max {
    color: var(--red-primary);
    font-size: 1.2rem;
}

.stat-bar-container {
    margin-top: 10px;
    height: 10px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 5px;
    overflow: hidden;
    position: relative;
}

.stat-bar-container::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow:
        inset 0 1px 0 rgba(255,255,255,0.18),
        inset 0 -1px 0 rgba(0,0,0,0.28);
    pointer-events: none;
    z-index: 10;
}

.stat-bar {
    position: absolute;
    inset: 0;
    display: block;
    background: linear-gradient(90deg, var(--red-dark), var(--gold));
    border-radius: 0;
    z-index: 2;
    margin: 0;
}

.stat-bar-max {
    background: linear-gradient(90deg, var(--rust), var(--gold));
    opacity: 0.4;
    z-index: 1;
}

/* ==========================================================================
   Info Grid (Two-column label/value layout)
   Used on: weapon.html, horse.html detail pages
   ========================================================================== */

.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.info-label {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.info-value {
    color: var(--text-cream);
    font-size: 1.05rem;
}

/* ==========================================================================
   Info Section (Card-like container for detail pages)
   Used on: weapon.html, horse.html
   ========================================================================== */

.info-section {
    background: var(--bg-card);
    border-radius: 8px;
    padding: 25px;
    margin-bottom: 20px;
    border: 1px solid var(--border-subtle);
}

.info-section h2 {
    font-family: 'Rye', cursive;
    color: var(--rust);
    font-size: 1.2rem;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-subtle);
}

/* ==========================================================================
   Results Count (Search results counter)
   Used on: gear.html, crafting.html, table.html, weapons-table.html
   ========================================================================== */

.results-count {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin-bottom: 10px;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media (max-width: 600px) {
    .info-grid {
        grid-template-columns: 1fr;
    }

    .stat-box {
        padding: 12px 8px;
    }

    .stat-box .stat-name {
        font-size: 0.65rem;
    }

    .stat-box .stat-base {
        font-size: 0.9rem;
    }

    .stat-box .stat-max {
        font-size: 1rem;
    }
}
