﻿/* -------------------------------------------------
   Base HTML / body
   ------------------------------------------------- */

html {
    font-size: 14px;
    position: relative;
    min-height: 100%;
}

@media (min-width: 768px) {
    html {
        font-size: 16px;
    }
}

body {
    margin-bottom: 60px;
}

/* Utility */
.hidden {
    display: none !important;
}

/* -------------------------------------------------
   Cookie banner (theme-aware)
   ------------------------------------------------- */

.cookie-banner {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 15px 20px;
    background: var(--bg-card);
    color: var(--text-colour);
    border-top: 1px solid var(--border-colour);
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 9999;
    font-size: 14px;
}

.cookie-text {
    max-width: 70%;
    line-height: 1.4;
}

.cookie-learnmore {
    margin-left: 8px;
}

.cookie-buttons {
    display: flex;
    gap: 12px;
}

    .cookie-buttons button {
        padding: 6px 14px;
        border: 1px solid var(--border-colour);
        background: var(--bg-colour);
        color: var(--text-colour);
        cursor: pointer;
    }

        .cookie-buttons button:hover {
            background: var(--bg-card);
        }

/* Mobile layout for cookie banner */
@media (max-width: 600px) {
    .cookie-banner {
        flex-direction: column;
        align-items: stretch;
        text-align: left;
        padding: 20px;
        gap: 14px;
    }

    .cookie-text {
        max-width: 100%;
    }

    .cookie-buttons {
        width: 100%;
        display: flex;
        justify-content: space-between;
    }

        .cookie-buttons button {
            flex: 1;
            padding: 10px;
        }
}

/* -------------------------------------------------
   Dark mode theme variables
   ------------------------------------------------- */

/* Base theme (light) */
:root {
    --bg-colour: #f5f5f5;
    --bg-card: #ffffff;
    --text-colour: #222222;
    --border-colour: #dddddd;
    --link-colour: #005bbb;
    --link-hover-colour: #003f80;
    --nav-bg: #ffffff;
    --nav-text: #222222;
    --header-bg: var(--nav-bg);
    --header-text: var(--nav-text);
}

    /* Dark theme overrides */
    :root[data-theme="dark"] {
        --bg-colour: #121212;
        --bg-card: #1e1e1e;
        --text-colour: #f1f1f1;
        --border-colour: #333333;
        --link-colour: #4da3ff;
        --link-hover-colour: #82c4ff;
        --nav-bg: #1a1a1a;
        --nav-text: #f1f1f1;
        --header-bg: var(--nav-bg);
        --header-text: var(--nav-text);
    }

/* If no explicit data-theme is set, follow system preference */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]):not([data-theme="dark"]) {
        --bg-colour: #121212;
        --bg-card: #1e1e1e;
        --text-colour: #f1f1f1;
        --border-colour: #333333;
        --link-colour: #4da3ff;
        --link-hover-colour: #82c4ff;
        --nav-bg: #1a1a1a;
        --nav-text: #f1f1f1;
        --header-bg: var(--nav-bg);
        --header-text: var(--nav-text);
    }
}

/* Apply variables */

body {
    background: var(--bg-colour);
    color: var(--text-colour);
}

header,
.navbar {
    background: var(--nav-bg);
    color: var(--nav-text);
}

a {
    color: var(--link-colour);
}

    a:hover {
        color: var(--link-hover-colour);
    }

/* -------------------------------------------------
   Navbar + theme toggle
   ------------------------------------------------- */

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    background: var(--nav-bg);
}

/* 🔹 Make navbar text follow the theme */
.app-navbar .navbar-brand,
.app-navbar .nav-link {
    color: var(--nav-text);
}

    .app-navbar .navbar-brand:hover,
    .app-navbar .nav-link:hover {
        color: var(--link-hover-colour);
    }

/* keep existing theme-toggle styles */
.theme-toggle {
    border: 1px solid var(--border-colour);
    background: transparent;
    color: var(--nav-text);
    border-radius: 999px;
    padding: 4px 10px;
    cursor: pointer;
    font-size: 0.9rem;
}

    .theme-toggle:hover {
        background: rgba(255, 255, 255, 0.08);
    }

/* -------------------------------------------------
   Generic tool table system
   ------------------------------------------------- */

.tool-table-wrapper {
    max-height: 400px;
    overflow-y: auto;
    overflow-x: auto;
    border: 1px solid var(--border-colour);
    border-radius: 4px;
    background: var(--bg-card);
    margin-top: 1rem;
    position: relative;
    -webkit-overflow-scrolling: touch;
}

.tool-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
    background: var(--bg-card);
    color: var(--text-colour);
    min-width: 100%;
}

    .tool-table th,
    .tool-table td {
        padding: 0.4rem 0.6rem;
        border-bottom: 1px solid var(--border-colour);
        text-align: right;
        white-space: nowrap;
    }

        .tool-table th:first-child,
        .tool-table td:first-child {
            text-align: left;
        }

    /* Sticky header */
    .tool-table thead {
        position: sticky;
        top: 0;
        background: var(--bg-card);
        z-index: 2;
    }

    /* Hover / zebra */
    .tool-table tbody tr:hover {
        background: rgba(255, 255, 255, 0.06);
    }

    .tool-table tbody tr:nth-child(even) {
        background: rgba(255, 255, 255, 0.02);
    }

/* Mobile tweaks for tables */
@media (max-width: 768px) {
    .tool-table-wrapper {
        max-height: none;
        margin-top: 0.75rem;
    }

    .tool-table {
        font-size: 0.8rem;
    }

        .tool-table th,
        .tool-table td {
            padding: 0.35rem 0.45rem;
            white-space: normal;
        }

    .tool-table-wrapper::after {
        content: "Scroll →";
        position: absolute;
        right: 8px;
        bottom: 4px;
        font-size: 0.75rem;
        opacity: 0.6;
        pointer-events: none;
    }
}

/* -------------------------------------------------
   Tool layout + cards
   ------------------------------------------------- */

/* Overall tool page container */
.tool-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 1.5rem 1rem 3rem;
}

/* Header band (more specific so it beats auto styles) */
section.tool-page .tool-header {
    margin-bottom: 1.5rem;
    background: var(--header-bg);
    color: var(--header-text);
    padding: 1rem 1rem;
    border: 1px solid var(--border-colour);
}

    section.tool-page .tool-header p {
        color: var(--header-text);
    }

/* Main layout row */
.tool-layout {
    display: flex;
    gap: 1.5rem;
}

/* Reusable stack behaviour */
.responsive-stack {
    flex-wrap: nowrap;
}

/* Sections / cards – MORE SPECIFIC so it overrides page-level .tool-section */
section.tool-page .tool-section,
section.tool-page .tool-card,
section.tool-page .tool-input,
section.tool-page .tool-output,
section.tool-page .tool-stats {
    background: var(--bg-card);
    color: var(--text-colour);
    border: 1px solid var(--border-colour);
    border-radius: 4px;
    padding: 1rem;
}


.tool-section-title {
    margin-top: 0;
    margin-bottom: 0.75rem;
}

/* Inputs / forms */
.form-row {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    margin-bottom: 0.75rem;
}

.form-label {
    font-size: 0.9rem;
}

.form-input,
.form-input-multiline {
    background: var(--bg-card);
    color: var(--text-colour);
    border: 1px solid var(--border-colour);
    padding: 4px 6px;
}

    .form-input:focus,
    .form-input-multiline:focus {
        outline: none;
        border-color: var(--link-colour);
    }

.form-action {
    margin-top: 0.5rem;
}

/* Results text */
.tool-result-list {
    padding-left: 1.1rem;
    margin-bottom: 0.75rem;
}

.tool-note {
    font-size: 0.85rem;
    opacity: 0.85;
}

/* Chart area */
.tool-chart-wrapper {
    position: relative;
    height: 260px;
}

/* MOBILE RESPONSIVE TWEAKS for tool layout */
@media (max-width: 768px) {
    .tool-layout,
    .responsive-stack {
        flex-direction: column;
    }

    .tool-page {
        padding: 1rem 0.75rem 2rem;
    }

    .tool-chart-wrapper {
        height: 220px;
    }
}

/* -------------------------------------------------
   Text formatter layout tweaks
   ------------------------------------------------- */

.tool-input,
.tool-output {
    flex: 1 1 0;
}

/* Matching textareas */
.form-input-multiline {
    min-height: 220px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.4;
}

/* Options area */
.tool-controls {
    margin-top: 1.5rem;
}

.tf-options {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    margin-bottom: 0.75rem;
}

/* Checkbox rows */
.checkbox-row {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    font-size: 0.9rem;
}

    .checkbox-row input[type="checkbox"] {
        margin-top: 2px;
    }

/* Buttons row */
.tf-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

    .tf-buttons button {
        padding: 0.4rem 0.9rem;
    }

/* Mobile tweaks for TF */
@media (max-width: 768px) {
    .form-input-multiline {
        min-height: 180px;
    }

    .tf-buttons {
        justify-content: flex-start;
    }

        .tf-buttons button {
            flex: 1 1 140px;
        }
}

/* -------------------------------------------------
   Tournament bracket layout
   ------------------------------------------------- */

.bracket-wrapper {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    -webkit-overflow-scrolling: touch;
}

.bracket-rounds {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    min-width: max(100%, 480px);
}

/* Each round is a column */
.bracket-round {
    flex: 0 0 200px;
}

.bracket-round-title {
    font-size: 0.9rem;
    margin-bottom: 0.5rem;
    opacity: 0.85;
}

/* Each match card */
.bracket-match {
    border: 1px solid var(--border-colour);
    border-radius: 4px;
    padding: 0.4rem;
    margin-bottom: 0.75rem;
    background: var(--bg-card);
    font-size: 0.85rem;
}

/* Player rows */
.bracket-player {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.4rem;
    margin-bottom: 0.25rem;
}

    .bracket-player:last-child {
        margin-bottom: 0;
    }

.bracket-player-name {
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Winner state */
.bracket-player.winner .bracket-player-name {
    font-weight: bold;
}

/* Buttons */
.bracket-player button {
    padding: 0.2rem 0.5rem;
    font-size: 0.8rem;
}

/* Disabled match (future round with no players yet) */
.bracket-match.empty .bracket-player-name {
    opacity: 0.5;
}

/* Final winner badge */
.bracket-final-winner {
    margin-top: 0.5rem;
    font-size: 0.9rem;
    font-weight: bold;
}

/* Mobile tweaks for bracket */
@media (max-width: 768px) {
    .bracket-round {
        flex: 0 0 180px;
    }

    .bracket-match {
        font-size: 0.8rem;
        padding: 0.35rem;
    }

    .bracket-player button {
        padding: 0.15rem 0.4rem;
        font-size: 0.75rem;
    }
}


/* -------------------------------------------------
   Landing page (home)
   ------------------------------------------------- */

/* Hero card at the top of the home page */
.home-page .tool-header {
    margin-bottom: 2rem;
    padding: 1.5rem 1.75rem 1.75rem;
    border-radius: 0.5rem;
    border: 1px solid var(--border-colour);
    background: var(--header-bg);
    color: var(--header-text);
}

    .home-page .tool-header h1 {
        margin-bottom: 0.75rem;
    }

    .home-page .tool-header p {
        max-width: 48rem;
        margin-bottom: 0.4rem;
    }

/* Breathing room between hero and categories */
.home-page #tool-categories.tool-section {
    margin-top: 1.5rem;
}

/* Category grid/cards */

.qt-category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.5rem;
    margin-top: 1.5rem;
}

.qt-category-card {
    display: flex;
    flex-direction: column;
}

/* Tool list */

.qt-tool-list {
    list-style: none;
    margin: 1rem 0 0;
    padding-left: 0;
}

.qt-tool-list-item + .qt-tool-list-item {
    margin-top: 0.5rem;
}

.qt-tool-link {
    display: block;
    text-decoration: none;
}

/* Match normal body text colours in both themes */
.qt-tool-name {
    font-weight: 600;
    display: block;
    color: var(--text-colour);
}

.qt-tool-tagline {
    font-size: 0.875rem;
    display: block;
    color: var(--text-colour);
    opacity: 0.85;
}

/* Simple hover – let theme handle colours */
.qt-tool-link:hover,
.qt-tool-link:focus-visible {
    text-decoration: underline;
}

