/* Albion Craft Calculator - Dark Theme */
:root {
    --bg-page: #14141f;
    --bg-surface: #1e1e2e;
    --bg-surface-2: #262638;
    --bg-surface-hover: #2f2f44;
    --border: #34344a;
    --border-strong: #44445c;
    --text: #e4e4f0;
    --text-muted: #9c9cb0;
    --text-dim: #6c6c80;
    --accent: #5aa6e8;
    --accent-hover: #7ab8f0;
    --accent-bg-hover: #1c2f48;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    color: var(--text);
    background-color: var(--bg-page);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Site Layout */
.container {
    /* Centered, using most of wide screens: 85% but never narrower than
       1200px (or the screen). */
    width: max(85%, min(1200px, 100%));
    margin: 0 auto;
    padding: 20px;
    flex: 1;
}

/* ============================================
   NAVIGATION BAR
   ============================================ */
.site-header {
    background: linear-gradient(135deg, #1a5c9e 0%, #0d3b66 100%);
    color: white;
    padding: 1rem;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.4);
}

.main-nav {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.logo-link {
    font-size: 1.4rem;
    font-weight: bold;
    color: white;
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.logo-link:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.nav-item a {
    color: rgba(255, 255, 255, 0.85);
    text-decoration: none;
    padding: 0.5rem 0.75rem;
    border-radius: 4px;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.nav-item a:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.1);
}

/* Active nav item highlighting (for HTMX) */
.station-nav-active {
    border-bottom: 3px solid transparent !important;
}

/* Hero Section */
.hero-section {
    text-align: center;
    padding: 3rem 1rem;
    background: linear-gradient(180deg, var(--bg-surface) 0%, var(--bg-surface-2) 100%);
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
}

.hero-section h1 {
    font-size: 2.5rem;
    color: var(--accent);
    margin-bottom: 1rem;
}

.hero-section p {
    font-size: 1.2rem;
    color: var(--text-muted);
}

/* Card Grid */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.recipe-card {
    background: var(--bg-surface);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    cursor: pointer;
    border: 1px solid var(--border);
}

.recipe-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
    border-color: var(--accent);
    background: var(--bg-surface-hover);
}

.recipe-card h3 {
    color: var(--accent);
    margin-bottom: 0.5rem;
    font-size: 1.25rem;
}

.recipe-card p {
    color: var(--text-muted);
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
}

.recipe-card .recipe-item-name {
    font-weight: 600;
    color: var(--text);
}

.recipe-card .recipe-quantity {
    color: var(--accent);
    font-weight: 500;
    margin: 0.5rem 0;
}

.recipe-card .recipe-profit {
    font-size: 0.95rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
}

.recipe-loading {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
    font-size: 1.2rem;
}

/* Station headers (for station templates) */
.station-header {
    padding: 2rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
}

.station-title {
    color: var(--text);
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

.station-desc {
    color: var(--text-muted);
    max-width: 700px;
    line-height: 1.6;
    font-size: 1.1rem;
}

/* Crafting types grid (for home page) */
.crafting-types {
    margin-bottom: 2rem;
}

.crafting-types h2 {
    color: var(--accent);
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

/* Buttons */
.btn {
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.95rem;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.btn-primary {
    background-color: var(--accent);
    color: var(--bg-page);
    font-weight: 600;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
}

/* Info Section */
.info-section {
    margin-bottom: 2rem;
}

.info-section h2 {
    color: var(--accent);
    margin-bottom: 1.5rem;
    font-size: 1.8rem;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.info-card {
    background: var(--bg-surface);
    padding: 1.5rem;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
}

.info-card strong {
    color: var(--accent);
    display: block;
    margin-bottom: 0.5rem;
}

.info-card p {
    color: var(--text-muted);
    font-size: 0.95rem;
}

.info-card code {
    background: var(--bg-surface-2);
    color: var(--accent);
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    font-size: 0.85rem;
}

/* Home Footer */
.home-footer {
    text-align: center;
    padding: 2rem;
    background: #1a5c9e;
    color: white;
    margin-top: auto;
}

.home-footer nav a {
    color: white;
    text-decoration: underline;
    margin: 0 0.5rem;
    transition: color 0.3s ease;
}

.home-footer nav a:hover {
    color: #aaddff;
}

/* Settings panel */
.settings-panel {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 0.85rem 1rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}

.settings-panel .setting {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.settings-panel .setting label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.settings-panel .setting input[type="number"],
.settings-panel .setting select {
    background: var(--bg-page);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 0.35rem 0.5rem;
    font-size: 0.9rem;
    min-width: 6rem;
}

.settings-panel .setting input[type="number"]:focus,
.settings-panel .setting select:focus {
    outline: none;
    border-color: var(--accent);
}

.settings-panel .checkbox-label {
    flex-direction: row !important;
    align-items: center;
    gap: 0.4rem;
    color: var(--text);
    text-transform: none !important;
    letter-spacing: 0 !important;
    font-size: 0.9rem !important;
    margin-top: 1rem;
}

.settings-panel .checkbox-label input {
    margin: 0;
    accent-color: var(--accent);
}

.settings-panel .setting-actions {
    margin-top: 1rem;
}

.refresh-btn {
    background: var(--accent);
    color: var(--bg-page);
    border: none;
    border-radius: 4px;
    padding: 0.4rem 0.85rem;
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.refresh-btn:hover {
    background: var(--accent-hover);
}

.settings-panel .setting-status {
    margin-top: 1.3rem;
    margin-left: auto;
    font-size: 0.75rem;
}

.status-ok {
    color: var(--text-dim);
}

.status-error {
    color: #f87171;
    cursor: help;
    border-bottom: 1px dotted #f87171;
}

/* Compact table */
.recipe-table-compact th,
.recipe-table-compact td {
    padding: 0.55rem 0.75rem;
    font-size: 0.9rem;
}

.recipe-table-compact .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-family: monospace;
}

.details-btn {
    background: transparent;
    border: 1px solid var(--border-strong);
    color: var(--accent);
    border-radius: 4px;
    padding: 0.15rem 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    line-height: 1;
    transition: all 0.2s ease;
}

.details-btn:hover {
    background: var(--accent-bg-hover);
    border-color: var(--accent);
}

/* Details panel (expanded row) */
.details-row > td {
    padding: 0 !important;
    background: var(--bg-surface-2);
    border-bottom: 1px solid var(--border);
}

.details-panel {
    padding: 1rem 1.25rem;
}

.details-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.details-header strong {
    color: var(--accent);
    margin-right: 0.5rem;
}

.details-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
    padding: 0 0.5rem;
}

.details-close:hover {
    color: var(--text);
}

.details-grid {
    display: grid;
    grid-template-columns: 1.5fr 1fr;
    gap: 1.5rem;
}

.details-grid h4 {
    color: var(--accent);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
}

.ingredients-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.ingredients-table th,
.ingredients-table td {
    padding: 0.35rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.ingredients-table th {
    background: var(--bg-surface);
    color: var(--text-muted);
    font-weight: 500;
}

.ingredients-table .num {
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-family: monospace;
}


.badge-excluded {
    background: var(--bg-page);
    color: var(--text-muted);
    cursor: help;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.summary-list {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.3rem 1rem;
    font-size: 0.9rem;
}

.summary-list dt {
    color: var(--text-muted);
}

.summary-list dd {
    color: var(--text);
    text-align: right;
    font-variant-numeric: tabular-nums;
    font-family: monospace;
}

.summary-list dd.profit {
    color: #4ade80;
}

.summary-list dd.loss {
    color: #f87171;
}

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

.small {
    font-size: 0.8rem;
}

.summary-list dd code,
.muted code {
    background: var(--bg-page);
    color: var(--accent);
    padding: 0.05rem 0.3rem;
    border-radius: 3px;
    font-size: 0.8em;
}

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

    .settings-panel {
        gap: 0.75rem;
    }
}

/* Recipe Table */
.recipe-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--bg-surface);
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    color: var(--text);
}

.recipe-table th,
.recipe-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.recipe-table th {
    background: linear-gradient(135deg, #1a5c9e 0%, #0d3b66 100%);
    color: white;
    font-weight: 600;
}

.recipe-table tbody tr:hover {
    background: var(--bg-surface-hover);
}

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

/* Profit/Loss Color Coding */
.profit {
    color: #4ade80;
    font-weight: bold;
}

.loss {
    color: #f87171;
    font-weight: bold;
}

.neutral {
    color: var(--text-muted);
}

/* Loading State */
.recipe-loading {
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

/* Station page */
.station-page {
    margin-bottom: 2rem;
}

.station-header {
    padding: 1.5rem 2rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    background: linear-gradient(135deg, #1a5c9e 0%, #0d3b66 100%);
    color: white;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.station-header a {
    color: #cce4ff;
}

.station-header .station-desc {
    color: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    margin: 0.25rem 0 0;
}

.station-title {
    margin: 0;
    font-size: 2rem;
    color: white;
}

/* Sub-category tabs */
.subcategory-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border);
}

.subcategory-tab {
    padding: 0.45rem 0.9rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-strong);
    border-radius: 999px;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    cursor: pointer;
}

.subcategory-tab:hover {
    background: var(--accent-bg-hover);
    border-color: var(--accent);
    color: var(--accent-hover);
}

.subcategory-tab.active {
    background: var(--accent);
    color: var(--bg-page);
    border-color: var(--accent);
    font-weight: 600;
}

.subcategory-tab small {
    opacity: 0.75;
    font-size: 0.8em;
    margin-left: 0.25rem;
}

/* Recipe table tweaks */
.recipe-table-wrapper {
    overflow-x: auto;
    background: var(--bg-surface);
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    border: 1px solid var(--border);
}

.recipe-result strong {
    color: var(--accent);
    display: block;
}

.recipe-result.warning strong {
    color: #fbbf24;
}

.recipe-id {
    color: var(--text-dim);
    font-family: monospace;
    font-size: 0.75rem;
}

.ingredient-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.ingredient-list li {
    padding: 0.15rem 0;
    color: var(--text);
}

.ingredient-qty {
    display: inline-block;
    min-width: 2.5rem;
    color: var(--accent);
    font-weight: 600;
    font-family: monospace;
}

.enchant-badge {
    display: inline-block;
    background: #f4a300;
    color: #14141f;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
}

.src-history {
    display: inline-block;
    margin-left: 0.25rem;
    padding: 0 0.3rem;
    border-radius: 4px;
    background: var(--bg-panel, #2a2a3a);
    color: var(--accent, #f4a300);
    font-weight: bold;
    font-size: 0.85rem;
    cursor: help;
}

.empty-row {
    text-align: center;
    padding: 2rem;
    color: var(--text-dim);
    font-style: italic;
}

/* Responsive Design */
@media (max-width: 768px) {
    .hero-section h1 {
        font-size: 2rem;
    }

    .card-grid {
        grid-template-columns: 1fr;
    }

    .info-grid {
        grid-template-columns: 1fr;
    }
}

/* Footer */
.site-footer {
    text-align: center;
    padding: 1rem;
    background: #0d3b66;
    color: rgba(255, 255, 255, 0.85);
    margin-top: auto;
    border-top: 1px solid #1a5c9e;
}

.site-footer p {
    margin: 0.15rem 0;
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */
@media (max-width: 900px) {
    .main-nav {
        flex-direction: column;
        align-items: center;
    }

    .logo-link {
        font-size: 1.2rem;
        margin-bottom: 0.5rem;
    }

    .nav-item a {
        padding: 0.4rem 0.6rem;
        font-size: 0.85rem;
    }

    .station-title {
        font-size: 2rem;
    }

    .hero-section h1 {
        font-size: 2rem;
    }
}

@media (max-width: 600px) {
    .hero-section h1 {
        font-size: 1.5rem;
    }

    .card-grid,
    .item-grid,
    .info-grid {
        grid-template-columns: 1fr;
    }

    .crafting-types h2 {
        font-size: 1.4rem;
    }
}

/* Editable prices in the details panel */
.details-hint {
    margin: -0.25rem 0 0.75rem;
}

.price-cell {
    display: inline-flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.25rem;
}

.price-input {
    width: 6.5rem;
    background: var(--bg-page);
    color: var(--text);
    border: 1px solid var(--border-strong);
    border-radius: 4px;
    padding: 0.2rem 0.4rem;
    font-family: monospace;
    font-size: 0.85rem;
    text-align: right;
}

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

.price-input:focus {
    outline: none;
    border-color: var(--accent);
}

.price-input.overridden {
    border-color: #f4a300;
    color: #f4a300;
}

.reset-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.95rem;
    line-height: 1;
    padding: 0 0.15rem;
}

.reset-btn:hover {
    color: var(--text);
}

.src-manual {
    color: #f4a300;
    font-size: 0.85em;
    cursor: help;
}

.summary-heading {
    margin-top: 1rem;
}

.summary-list dt label {
    color: inherit;
    font: inherit;
}

.price-age {
    color: var(--text-dim);
    font-size: 0.75rem;
    min-width: 2rem;
    text-align: left;
}

.price-age.old {
    color: #fbbf24;
}

.price-age.stale {
    color: #f87171;
}

.home-city {
    justify-content: flex-start;
}

.home-city p {
    margin: 1rem 0 0;
}

/* Label on rows whose profit relies on a price older than a week */
.old-price-badge {
    display: inline-block;
    margin-top: 0.15rem;
    color: #fbbf24;
    font-size: 0.72rem;
}

/* Label on rows whose profit relies on a price older than 30 days: the row
   is not a candidate */
.stale-badge {
    display: inline-block;
    margin-top: 0.15rem;
    color: #f87171;
    font-size: 0.72rem;
}

/* Profit computed from prices too old to trust */
.untrusted {
    color: var(--text-dim);
    text-decoration: line-through;
}

/* Black Market page */
.bm-count {
    margin-bottom: 0.5rem;
}

.bm-table .bm-group-row th {
    padding-bottom: 0;
    border-bottom: none;
}

.bm-table .bm-group {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    border-bottom: 1px solid var(--border-strong);
}

.bm-table td.num {
    white-space: nowrap;
}

.bm-table.recipe-table-compact th,
.bm-table.recipe-table-compact td {
    padding: 0.5rem 0.55rem;
}

/* Ages and percentages sit under the number to keep columns narrow */
.bm-table td.num small,
.bm-table td.num .price-age {
    display: block;
    opacity: 0.8;
    font-size: 0.72rem;
    text-align: right;
}

.bm-table .bm-origin {
    display: block;
    font-size: 0.75rem;
}

.bm-row {
    cursor: pointer;
}

.bm-details-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr) minmax(0, 1fr);
    gap: 1.5rem;
}

.bm-details-grid h4 {
    color: var(--accent);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 0.5rem;
}

.bm-material-total {
    margin-top: 0.75rem;
}

@media (max-width: 1100px) {
    .bm-details-grid {
        grid-template-columns: 1fr;
    }
}

.best-badge {
    display: inline-block;
    padding: 0.1rem 0.45rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    color: #14141f;
}

.best-craft {
    background: #4ade80;
}

.best-flip {
    background: var(--accent);
}

/* Item qualities */
.quality-badge {
    display: inline-block;
    padding: 0 0.35rem;
    border-radius: 3px;
    font-size: 0.72rem;
    border: 1px solid currentColor;
}

.quality-badge.q1 { color: var(--text-muted); }
.quality-badge.q2 { color: #a3a3a3; }
.quality-badge.q3 { color: #60a5fa; }
.quality-badge.q4 { color: #c084fc; }
.quality-badge.q5 { color: #fbbf24; }

/* Expected value next to a floor profit */
.ev-hint {
    display: block;
    color: var(--text-dim);
    font-size: 0.72rem;
}

.quality-table {
    margin-top: 0.25rem;
}
