/* ==========================================================================
   STYLE SHEET FOR BAR FINDER
   ==========================================================================
   This stylesheet is organized into the following sections:
   1. VARIABLES & THEMING
   2. GLOBAL & BASE STYLES
   3. LAYOUT & CONTAINERS
   4. COMPONENTS
      4.1 Forms & Inputs
      4.2 Buttons & Links
      4.3 Cards
      4.4 Lists & Tables
      4.5 Images & Illustrations
      4.6 Interactive UI (Sidebar, Tabs, etc.)
      4.7 Controls & Toggles
      4.8 Utility & Helper Classes
   5. RESPONSIVE DESIGN
   ========================================================================== */

/* ==========================================================================
   1. VARIABLES & THEMING
   ========================================================================== */

:root {
    /* Light Mode Color Palette (Default) */
    --color-primary: #007bff;
    --color-primary-dark: #005ea5;
    --color-primary-deep: #0056b3;
    --color-secondary: #6c757d;
    --color-secondary-dark: #5a6268;

    --color-text-default: #555;
    --color-text-medium: #495057;
    --color-text-strong: #333;
    --color-text-dark: #343a40;
    --color-text-white: white;

    --color-background-body: #f8f9fa;
    --color-background-card: #fff;
    --color-background-offset: #f7f9fc;
    --color-background-subtle: #e9ecef;
    --color-background-sidebar: #f4f4f4;
    --color-background-active: #e7f1ff;

    --color-border-main: #e0e5ec;
    --color-border-subtle: #dee2e6;
    --color-border-light: #f0f0f0;
    --color-border-input: #ced4da;
    --color-border-generic: #ccc;
    --color-border-autocomplete: #ddd;

    /* Shadows */
    --shadow-light: 0 2px 5px rgba(0,0,0,0.05);
    --shadow-medium: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-sidebar: 2px 0 8px rgba(0,0,0,0.07);

    /* Typography */
    --font-family-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;

    /* Sizing & Spacing */
    --border-radius-main: 8px;
    --border-radius-small: 6px;
    --border-radius-form: 4px;
}

/* Dark Mode Color Palette */
html[data-theme='dark'] {
    --color-primary: #0d8eff;
    --color-primary-dark: #3aa0ff;
    --color-primary-deep: #0d8eff;
    --color-secondary: #8b949e;
    --color-secondary-dark: #a2acb8;

    --color-text-default: #c9d1d9;
    --color-text-medium: #c9d1d9;
    --color-text-strong: #f0f6fc;
    --color-text-dark: #f0f6fc;

    --color-background-body: #0d1117;
    --color-background-card: #161b22;
    --color-background-offset: #21262d;
    --color-background-subtle: #30363d;
    --color-background-sidebar: #1a2028;
    --color-background-active: #283950;

    --color-border-main: #30363d;
    --color-border-subtle: #414850;
    --color-border-light: #2a2f37;
    --color-border-input: #484f58;
    --color-border-generic: #555;
    --color-border-autocomplete: #30363d;

    --shadow-light: 0 2px 5px rgba(0,0,0,0.2);
    --shadow-medium: 0 5px 15px rgba(0,0,0,0.35);
    --shadow-sidebar: 2px 0 8px rgba(0,0,0,0.25);
}

/* ==========================================================================
   2. GLOBAL & BASE STYLES
   ========================================================================== */

* {
    box-sizing: border-box;
}

/* Custom Scrollbar Styles */
html {
    scrollbar-width: thin;
    scrollbar-color: var(--color-secondary) transparent;
}

::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background-color: var(--color-secondary);
    border-radius: 6px;
    border: 2px solid transparent;
    background-clip: padding-box;
    transition: background-color 0.2s ease;
}

::-webkit-scrollbar-thumb:hover {
    background-color: var(--color-secondary-dark);
}

body {
    font-family: var(--font-family-sans);
    margin: 0;
    background-color: var(--color-background-body);
    color: var(--color-text-strong);
    transition: background-color 0.2s, color 0.2s;
}

a {
    color: var(--color-primary);
}

h1 {
    color: var(--color-text-dark);
    margin-bottom: 0.1em;
}

h2.subtitle {
    margin-top: 0;
    font-weight: normal;
    font-size: 1.2em;
    color: var(--color-secondary);
}

/* ==========================================================================
   3. LAYOUT & CONTAINERS
   ========================================================================== */

.container {
    max-width: 900px;
    margin: 1em auto;
    background-color: var(--color-background-card);
    padding: 2em;
    border-radius: var(--border-radius-main);
    box-shadow: var(--shadow-medium);
    position: relative;
}

.results-container {
    max-width: 950px;
    margin: 0 auto;
    padding: 2em;
    padding-bottom: 80px;
}

.header {
    text-align: center;
    margin-bottom: 1.5em;
}

.dimension-search-layout {
    display: flex;
    gap: 2em;
    align-items: flex-start;
}

.dimension-form-fields {
    flex: 2;
}

.dimension-form-fields > form {
    margin-top: 0;
}

.dimension-images {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.75em;
}

.interactive-container {
    display: flex;
    height: 100vh;
}

.sidebar {
    min-width: 400px;
    max-width: 65%;
    background-color: var(--color-background-sidebar);
    box-shadow: var(--shadow-sidebar);
    z-index: 10;
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 20px;
    position: relative;
}

.main-content {
    flex-grow: 1;
    padding: 25px;
    overflow-y: auto;
}

.detail-container {
    max-width: 1100px;
    margin: 2em auto;
    padding: 2em;
    padding-bottom: 3em;
    background-color: var(--color-background-card);
    border-radius: var(--border-radius-main);
    box-shadow: var(--shadow-medium);
    position: relative;
}

.detail-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid var(--color-border-main);
    padding-bottom: 1em;
    margin-bottom: 1.5em;
}

.detail-header-right {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.3em;
    white-space: nowrap;
}

.detail-header h1 {
    margin: 0;
}

.detail-section {
    padding-top: 2em;
}

.detail-section h3 {
    margin-top: 0;
    margin-bottom: 1em;
    color: var(--color-primary-deep);
}

.detail-section > h3 {
    border-bottom: 1px solid var(--color-border-light);
    padding-bottom: 0.5em;
}

.section-header-with-toggle {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--color-border-light);
    padding-bottom: 0.5em;
    margin-bottom: 0.5em;
}

.section-header-with-toggle h3 {
    margin-bottom: 0;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2.5em;
}

/* Establishes the two-column layout for the detail page grid on desktop */
.detail-specs {
    margin-top: -1em;
    grid-column: 2;
    grid-row: 1;
}

.detail-dimensions-table {
    grid-column: 2;
    grid-row: 2;
    margin-top: -2em;
}


/* ==========================================================================
   4. COMPONENTS
   ========================================================================== */

/* --- 4.1 Forms & Inputs --- */

.search-section {
    position: relative;
    margin-bottom: 1.5em;
    padding: 1.25em;
    border: 1px solid var(--color-border-main);
    border-radius: var(--border-radius-main);
    background-color: var(--color-background-card);
}

.search-section h2 {
    margin-top: 0;
    color: var(--color-primary-deep);
}

.search-section p {
    color: var(--color-text-default);
    font-size: 0.95em;
}

.sidebar-search-form input[type="text"] {
    background-color: var(--color-background-body);
}

.sidebar-search-form input[type="submit"] {
    width: 100%;
    padding: 12px;
    font-weight: bold;
}

form label {
    display: block;
    font-weight: bold;
    margin-bottom: 0.5em;
}

form input[type="text"],
form input[type="password"],
select {
    padding: 10px;
    border: 1px solid var(--color-border-input);
    border-radius: var(--border-radius-form);
    box-sizing: border-box;
    width: 100%;
    background-color: var(--color-background-body);
    color: var(--color-text-strong);
    font-family: var(--font-family-sans);
    font-size: 1em;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

form input[type="text"]:focus,
form input[type="password"]:focus,
select:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

/* Authentication form inputs - consistent styling */
.auth-input {
    padding: 10px !important;
    border: 1px solid var(--color-border-input) !important;
    border-radius: var(--border-radius-form) !important;
    box-sizing: border-box !important;
    width: 100% !important;
    background-color: var(--color-background-body) !important;
    color: var(--color-text-strong) !important;
    font-family: var(--font-family-sans) !important;
    font-size: 1em !important;
    transition: border-color 0.2s ease, box-shadow 0.2s ease !important;
}

.auth-input:focus {
    outline: none !important;
    border-color: var(--color-primary) !important;
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25) !important;
}

.dimension-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.9em 1.5em;
    align-items: center;
}

.dimension-grid label {
    font-weight: normal;
    margin-bottom: 0;
}

.input-with-tolerance {
    display: flex;
    align-items: center;
    gap: 8px;
}

.input-with-tolerance input[type="text"]:not(.tolerance-input) {
    flex-grow: 1;
}

.unit-indicator {
    font-weight: bold;
    font-size: 0.9em;
    color: var(--color-secondary);
    min-width: 25px;
    text-align: left;
}

.tolerance-input {
    min-width: 80px;
    flex-basis: 110px;
    flex-grow: 0;
}

.tolerance-symbol {
    font-weight: bold;
}

.autocomplete-wrapper {
    position: relative;
}

.autocomplete-suggestions {
    position: absolute;
    border: 1px solid var(--color-border-autocomplete);
    border-top: none;
    z-index: 99;
    top: 100%;
    left: 0;
    right: 0;
    max-height: 200px;
    overflow-y: auto;
    background-color: var(--color-background-card);
    display: none;
}

.autocomplete-item {
    display: block;
    padding: 10px;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
}

.autocomplete-item:hover {
    background-color: var(--color-background-active);
}

.page-controls {
    position: absolute;
    top: 1.5em;
    right: 1.5em;
    z-index: 10;
}

.controls-block {
    display: flex;
    gap: 1.5em;
    align-items: end;
    flex-grow: 1;
}

.control-group {
    flex: 1;
}

.control-group label {
    display: block;
    font-weight: bold;
    color: var(--color-text-strong);
    font-size: 0.9em;
    margin-bottom: 8px;
}

.results-count {
    font-size: 1.2em;
    color: var(--color-text-medium);
    margin-right: 2em;
    white-space: nowrap;
}

.results-count strong {
    font-size: 1.5em;
    font-weight: 600;
    color: var(--color-primary);
    margin-right: 0.25em;
}


/* --- 4.2 Buttons & Links --- */

form input[type="submit"] {
    background-color: var(--color-primary);
    color: var(--color-text-white);
    padding: 10px 20px;
    border: none;
    border-radius: var(--border-radius-form);
    cursor: pointer;
    font-size: 1em;
    margin-top: 1em;
}

form input[type="submit"]:hover {
    background-color: var(--color-primary-dark);
}

.form-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 1em;
}

.form-actions > input[type="submit"] {
    margin-top: 0;
    width: 100%;
}

.button-alt {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    font-size: 1em;
    font-weight: 500;
    text-decoration: none;
    border-radius: var(--border-radius-form);
    background-color: var(--color-background-subtle);
    color: var(--color-text-strong);
    border: 1px solid var(--color-border-subtle);
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.button-alt:hover {
    background-color: var(--color-border-subtle);
    border-color: var(--color-secondary);
}

.back-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5em;
    width: fit-content;
    padding: 12px 25px;
    background-color: var(--color-primary);
    color: var(--color-text-white);
    text-decoration: none;
    border-radius: 5px;
    font-weight: bold;
    transition: all 0.2s ease-in-out;
    font-size: large;
}

.back-button::before {
    content: '';
    display: block;
    width: 1em;
    height: 1em;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24' fill='none' stroke='white' stroke-width='3' stroke-linecap='round' stroke-linejoin='round'%3E%3Cline x1='19' y1='12' x2='5' y2='12'/%3E%3Cpolyline points='12 19 5 12 12 5'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.back-button:hover {
    background-color: var(--color-primary-dark);
}

.fixed-back-button {
    position: fixed;
    bottom: 20px;
    left: 20px;
    z-index: 1000;
}

.sidebar .back-button {
    flex-shrink: 0;
    margin-top: auto;
    width: 100%;
}

.detail-back-button {
    position: absolute;
    bottom: 2em;
    left: 2em;
}

a.bar-card-link {
    display: block;
    text-decoration: none;
    color: inherit;
    border-radius: var(--border-radius-main);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

a.bar-card-link:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-medium);
}

a.bar-card-link:hover .bar-card {
    border-color: var(--color-primary);
}

.control-link {
    text-decoration: none;
    border-radius: 4px;
    transition: color 0.2s ease, background-color 0.2s ease;
}

.control-link:hover {
    color: var(--color-primary);
    background-color: var(--color-background-active);
}


/* --- 4.3 Cards --- */

.bar-card {
    border: 1px solid var(--color-border-main);
    border-radius: var(--border-radius-main);
    margin-bottom: 1.5em;
    background-color: var(--color-background-card);
    box-shadow: var(--shadow-light);
    overflow: hidden;
}

.card-header {
    background-color: var(--color-background-offset);
    padding: 12px 20px;
    border-bottom: 1px solid var(--color-border-main);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-weight: bold;
    font-size: 1.15em;
    color: var(--color-text-strong);
}

.card-other-reference {
    font-size: 0.8em;
    font-weight: normal;
    color: var(--color-secondary);
    margin-left: 0.5em;
}

.card-material-text {
  font-size: 0.9em;
  font-weight: bold;
  color: var(--color-text-dark);
  background-color: var(--color-background-subtle);
  padding: 5px 10px;
  border-radius: var(--border-radius-small);
  border: 1px solid var(--color-border-subtle);
}

.card-body {
    display: flex;
    flex-direction: column;
    padding: 20px;
    gap: 20px;
}

.card-main-content {
    display: flex;
    gap: 20px;
    align-items: stretch;
}

.main-content h2 {
    margin-top: 1.25em;
    margin-bottom: 1.36em;
}

.card-notes {
    margin-top: 10px;
    padding-top: 20px;
    border-top: 1px solid var(--color-border-light);
}

.card-notes h4 {
    margin: 0 0 10px 0;
    color: var(--color-text-strong);
}

.card-notes p {
    margin: 0;
    font-size: 0.95em;
    color: var(--color-text-default);
    white-space: pre-wrap;
    line-height: 1.5;
}

.press-notes-card {
    background-color: var(--color-background-offset);
    border: 1px solid var(--color-border-main);
    border-radius: var(--border-radius-main);
    padding: 1.25em;
    margin-bottom: 1.5em;
}

.press-notes-card h4 {
    margin: 0 0 10px 0;
    color: var(--color-primary-deep);
}

.press-notes-card p {
    margin: 0;
    white-space: pre-wrap;
    line-height: 1.5;
    color: var(--color-text-default);
}

.controls-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5em;
    background-color: var(--color-background-offset);
    border: 1px solid var(--color-border-main);
    border-radius: var(--border-radius-main);
    margin-bottom: 2.5em;
}

.controls-card form {
    flex-grow: 1;
}

.controls-card label {
    font-size: 0.9em;
    margin-bottom: 0.6em;
}

.sidebar-card {
    background-color: var(--color-background-card);
    border: 1px solid var(--color-border-main);
    border-radius: var(--border-radius-main);
    padding: 20px;
    flex-shrink: 0;
}

.sidebar-card h3 {
    margin-top: 0;
    margin-bottom: 15px;
    font-size: 1.2em;
    color: var(--color-text-strong);
}


/* --- 4.4 Lists & Tables --- */

.dimensions-list {
    flex: 1 2 240px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.dimensions-list li {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    padding: 10px;
    border-bottom: 1px solid var(--color-border-light);
}

.dimensions-list li:last-child {
    border-bottom: none;
}

.dim-label {
    font-family: monospace;
    font-size: 1.2em;
    font-weight: bold;
    color: var(--color-text-strong);
}

.dim-values {
    font-size: 1.1em;
    font-weight: 500;
    color: var(--color-primary-deep);
    white-space: nowrap;
}

.press-list-widget {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--color-background-card);
    border: 1px solid var(--color-border-main);
    border-radius: var(--border-radius-main);
    overflow: hidden;
    min-height: 0;
    padding: 0;
}

.widget-header {
    padding: 20px;
    background-color: var(--color-background-offset);
    border-bottom: 1px solid var(--color-border-main);
    flex-shrink: 0;
}

.widget-header h3 {
    margin: 0 0 15px 0;
    font-size: 1.1em;
}

#press-list-container {
    overflow-y: auto;
    overflow-x: auto;
    flex-grow: 1;
}

.press-list-table {
    width: 100%;
    border-collapse: collapse;
}

.press-list-table th {
    padding: 12px 15px;
    text-align: left;
    font-size: 0.9em;
    color: var(--color-text-strong);
    font-weight: 600;
    border-bottom: 1px solid var(--color-border-main);
    position: sticky;
    top: 0;
    background-color: var(--color-background-offset);
    z-index: 1;
}

.press-list-table th .unit-indicator {
    font-weight: normal;
    color: var(--color-secondary);
}

#press-list-table {
    visibility: hidden;
}

.press-list-table td {
    padding: 12px 15px;
    border-bottom: 1px solid var(--color-border-light);
    vertical-align: middle;
    overflow-wrap: break-word;
}

.press-list-table .dimension-col {
    text-align: right;
    font-size: 0.9em;
    white-space: nowrap;
    min-width: 60px;
    overflow-wrap: break-word;
}

.press-list-table th:nth-child(1),
.press-list-table td:nth-child(1) {
    padding-right: 0;
}

.press-list-table th:nth-child(3),
.press-list-table th:nth-child(4) {
    text-align: right;
    font-size: 0.9em;
}

.press-list-table td:nth-child(2) {
    white-space: normal;
    font-size: 0.9em;
    padding-left: 4px;
    min-width: 90px;
}

.press-list-table th:nth-child(1),
.press-list-table td:nth-child(1),
.press-list-table th:nth-child(2),
.press-list-table td:nth-child(2) {
    max-width: 12vw; /* Changed from 175px to 12vw */
    overflow-wrap: break-word; 
}

tr.press-item {
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

tr.press-item:hover,
tr.press-item:focus {
    background-color: var(--color-background-active);
    outline: none;
}

tr.press-item.active {
    background-color: var(--color-background-active);
    border-left: 4px solid var(--color-primary);
    color: var(--color-primary);
    font-weight: bold;
}

tr.press-item.active td:first-child {
    padding-left: 11px;
}

.specs-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.specs-list li {
    display: flex;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--color-border-light);
}

.specs-list li:last-child {
    border-bottom: none;
}

.specs-list strong {
    color: var(--color-text-strong);
    padding-right: 1em;
}

.specs-list span {
    color: var(--color-text-default);
    text-align: right;
}

.dimensions-table {
    width: 100%;
    border-collapse: collapse;
    /* margin-top: 1em; */
}

.dimensions-table th, .dimensions-table td {
    padding: 11px 15px;
    text-align: left;
    border-bottom: 1px solid var(--color-border-main);
}

.dimensions-table thead {
    background-color: var(--color-background-offset);
}

.dimensions-table th {
    color: var(--color-text-strong);
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.dimensions-table td strong {
    font-family: monospace;
    font-size: 1.2em;
    color: var(--color-text-strong);
}

.dimensions-table tbody tr:hover {
    background-color: var(--color-background-active);
}

.dimensions-table .value-col {
    text-align: right;
}

.dimensions-table .dim-values {
    text-align: right;
    font-weight: 500;
}

.press-association-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.press-association-list li {
    border-bottom: 1px solid var(--color-border-light);
}

.press-association-list li:last-child {
    border-bottom: none;
}

.press-association-list li a {
    padding: 10px 0;
}

.press-association-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 15px;
    text-decoration: none;
    color: inherit;
    transition: background-color 0.2s ease;
}

.press-association-item:hover {
    background-color: var(--color-background-active);
}

.press-association-item .press-manufacturer {
    display: block;
    font-weight: bold;
    color: var(--color-text-strong);
}

.press-association-item .press-model {
    display: block;
    font-size: 0.9em;
    color: var(--color-secondary);
}

.press-association-item svg {
    color: var(--color-secondary);
    flex-shrink: 0;
    margin-left: 1em;
    transition: color 0.2s ease;
}

.press-association-item:hover svg {
    color: var(--color-primary);
}

.dimension-key-list {
    list-style: none;
    padding: 0;
    margin: 0;
    font-size: 0.9em;
}

.dimension-key-list li {
    display: flex;
    justify-content: space-between;
    margin-bottom: 6px;
    color: var(--color-text-default);
    padding: 4px 0;
}

.dimension-key-list li:last-child { margin-bottom: 0; }

.dimension-key-list strong {
    font-family: monospace;
    font-size: 1.1em;
    color: var(--color-text-strong);
    margin-right: 15px;
}


/* --- 4.5 Images & Illustrations --- */

.card-image-container {
    flex: 1 1 200px;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #ffffff;
    border-right: 1px solid var(--color-border-main);
    padding: 1em;
    min-height: 150px;
    border-radius: var(--border-radius-main);
    overflow: hidden;
}

html[data-theme='dark'] .card-image-container {
    background-color: #ffffff;
    border-right: 1px solid var(--color-border-subtle);
}

.detail-image-wrapper {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #ffffff;
    border: 1px solid var(--color-border-main);
    border-radius: var(--border-radius-main);
    padding: 2em;
    min-height: 250px;
    box-shadow: var(--shadow-light);
}

html[data-theme='dark'] .detail-image-wrapper {
    background-color: #ffffff;
    border-color: var(--color-border-subtle);
}

.dimension-images img {
    max-width: 100%;
    height: auto;
    border-radius: var(--border-radius-small);
}

.bar-illustration {
    max-width: 100%;
    max-height: 300px;
    height: auto;
    object-fit: contain;
}


/* --- 4.6 Interactive UI (Sidebar, Tabs, etc.) --- */

.pair-tabs {
    display: flex;
    margin-bottom: 1em;
    border-bottom: 1px solid var(--color-border-autocomplete);
}

.tab-button {
    padding: 10px 15px;
    cursor: pointer;
    border: none;
    background-color: transparent;
    border-bottom: 3px solid transparent;
    font-size: 1em;
    color: var(--color-text-default);
}

.tab-button.active {
    border-bottom-color: var(--color-primary);
    font-weight: bold;
    color: var(--color-text-strong);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

.collapsible-section summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    list-style: none;
    border-bottom: 1px solid var(--color-border-light);
    padding-bottom: 0.5em;
}

.collapsible-section summary h3 {
    margin-bottom: 0;
}

.collapsible-section summary::-webkit-details-marker {
    display: none;
}

.collapsible-section .chevron-icon {
    color: var(--color-secondary);
    transition: transform 0.2s ease-in-out;
}

.collapsible-section[open] > summary .chevron-icon {
    transform: rotate(180deg);
}

.collapsible-content {
    padding-top: 1em;
}

.resizer {
    background-color: var(--color-border-subtle);
    transition: background-color 0.2s ease;
    flex-shrink: 0;
    width: 5px;
    cursor: col-resize;
}

.resizer:hover {
    background-color: var(--color-primary);
}


/* --- 4.7 Controls & Toggles --- */

.theme-switcher {
    position: relative;
    display: flex;
    align-items: center;
}

.theme-switcher-label {
    margin-right: 10px;
    font-size: 0.9em;
    color: var(--color-secondary);
}

.theme-switcher input[type="checkbox"] {
    height: 0;
    width: 0;
    visibility: hidden;
}

.theme-switcher .switch-label {
    cursor: pointer;
    text-indent: -9999px;
    width: 50px;
    height: 26px;
    background: var(--color-secondary);
    display: block;
    border-radius: 100px;
    position: relative;
    flex-shrink: 0;
}

.theme-switcher .switch-label:after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 90px;
    transition: 0.3s;
}

.theme-switcher input:checked + .switch-label {
    background: var(--color-primary);
}

.theme-switcher input:checked + .switch-label:after {
    left: calc(100% - 3px);
    transform: translateX(-100%);
}

.theme-switcher .switch-label:active:after {
    width: 28px;
}

.unit-toggle {
    position: absolute;
    top: 1.5em;
    right: 1.5em;
}

.unit-switch {
    position: relative;
    display: inline-block;
}

.unit-switch-label {
    display: flex;
    width: 80px;
    height: 34px;
    background-color: var(--color-background-subtle);
    border-radius: 17px;
    border: 1px solid var(--color-border-main);
    cursor: pointer;
    position: relative;
    -webkit-user-select: none;
    user-select: none;

}

.unit-switch-label::before {
    content: '';
    position: absolute;
    width: 38px;
    height: 28px;
    background-color: var(--color-primary);
    border-radius: 14px;
    top: 2px;
    left: 2px;
    transition: transform 0.25s ease-in-out;
    z-index: 1;
}

.unit-label-text {
    flex: 1;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9em;
    font-weight: bold;
    color: var(--color-text-default);
    transition: color 0.25s ease-in-out;
}

.unit-switch input:not(:checked) + .unit-switch-label .unit-label-text:first-child {
    color: var(--color-text-white);
}

.unit-switch input:checked + .unit-switch-label::before {
    transform: translateX(36px);
}

.unit-switch input:checked + .unit-switch-label .unit-label-text:last-child {
    color: var(--color-text-white);
}

.unit-switch input:checked + .unit-switch-label .unit-label-text:first-child {
    color: var(--color-text-default);
}

.app-controls {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1002;
}

.app-controls .icon-button {
    display: none;
}

.settings-container {
    display: flex;
    flex-direction: column;
    gap: 5px;
    background-color: var(--color-background-card);
    padding-top: 8px;
    padding-bottom: 1px;
    padding-right: 12px;
    padding-left: 12px;
    border-radius: var(--border-radius-main);
    box-shadow: var(--shadow-medium);
    border: 1px solid var(--color-border-main);
    width: 150px;
    transition: width 0.3s ease-in-out;
}

.settings-container.is-expanded {
    width: 250px;
}

.control-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95em;
    color: var(--color-text-default);
}

.control-icon {
    color: var(--color-secondary);
}

.control-dropdown {
    font-size: 0.95em;
    color: var(--color-text-default);
}

.control-dropdown summary {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    padding: 4px 0;
    list-style: none;
}

.control-dropdown summary::-webkit-details-marker {
    display: none;
}

.control-dropdown summary svg {
    transition: transform 0.2s ease-in-out;
}

.control-dropdown[open] > summary svg {
    transform: rotate(180deg);
}

.dropdown-content {
    padding-top: 10px;
    border-top: 1px solid var(--color-border-light);
    margin-top: 8px;
}


/* --- 4.8 Utility & Helper Classes --- */

html[data-units="inch"] .dim-mm,
html[data-units="mm"] .dim-inch {
    display: none;
}

html[data-units="inch"] .unit-indicator::after {
    content: 'in';
}

html[data-units="mm"] .unit-indicator::after {
    content: 'mm';
}

.press-list-table th .unit-indicator::after {
    font-weight: normal;
    color: var(--color-secondary);
}

.loader {
    border: 4px solid var(--color-border-light);
    border-top: 4px solid var(--color-primary);
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 20px auto;
}

.loader-container {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    height: 100%;
    color: var(--color-secondary);
    gap: 1em;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.empty-state {
    text-align: center;
    padding: 40px 20px;
    margin: 20px;
    color: var(--color-secondary);
    background-color: var(--color-background-card);
    border: 2px dashed var(--color-border-main);
    border-radius: var(--border-radius-main);
}

.empty-state h4 {
    margin: 15px 0 5px 0;
    color: var(--color-text-dark);
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.detail-header-reference {
    margin: 0;
    font-size: 1.1em;
    color: var(--color-secondary);
    font-weight: 500;
}

.detail-material {
    font-size: 1em;
    font-weight: bold;
    color: var(--color-text-dark);
    background-color: var(--color-background-subtle);
    padding: 8px 14px;
    border-radius: var(--border-radius-small);
    border: 1px solid var(--color-border-subtle);
    white-space: nowrap;
    margin-left: 1em;
}

.detail-notes p {
    white-space: pre-wrap;
    line-height: 1.6;
    color: var(--color-text-default);
}


/* ==========================================================================
   5. RESPONSIVE DESIGN
   ========================================================================== */

@media (min-width: 992px) {
    .sidebar {
        padding-bottom: 80px;
    }

    .sidebar .back-button {
        /* This locks the button to the bottom of the sidebar on desktop */
        position: absolute;
        bottom: 20px;
        left: 20px;
        width: calc(100% - 40px); /* Account for left/right padding */
        margin-top: 0; 
    }

    .search-wrapper {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 1.5em;
    }

    .search-wrapper .search-section {
        margin-bottom: 0;
    }

    .search-wrapper .search-section:last-child {
        grid-column: 1 / span 2;
    }
}

@media (max-width: 992px) {
    .interactive-container {
        flex-direction: column;
        height: auto;
        overflow: visible;
    }

    .sidebar {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        box-shadow: 0 2px 8px rgba(0,0,0,0.07);
        overflow: auto;
    }

    .sidebar #press-list-container {
        max-height: 45vh;
    }

    .resizer {
        width: 100%;
        height: 5px;
        cursor: row-resize;
    }
    
    .settings-container {
        flex-direction: row;
        background: none;
        border: none;
        box-shadow: none;
        padding: 0;
        width: auto;
    }

    .control-row > span {
        display: none;
    }

    .control-row:not(.home-link) .control-icon {
        display: none;
    }

    .home-link {
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: var(--color-background-card);
        border-radius: 50%;
        width: 44px;
        height: 44px;
        box-shadow: var(--shadow-light);
        border: 1px solid var(--color-border-main);
        order: 1;
    }

    .home-link .control-icon {
        color: var(--color-primary);
        width: 24px;
        height: 24px;
    }

    .control-dropdown {
        display: none;
    }
}

@media (max-width: 768px) {
    .dimension-search-layout {
        flex-direction: column;
    }

    .dimension-images {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    .dimension-images img {
        width: 48%;
        height: auto;
    }

    .container {
        margin: 1em;
        padding: 1em;
    }
    
    .back-button {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        width: 100%;
        margin: 0;
        border-radius: 0;
        padding-top: 0.75em;
        padding-bottom: calc(0.75em + env(safe-area-inset-bottom));
    }

    .card-body {
        flex-direction: column;
        gap: 20px;
    }

    .card-main-content {
        flex-direction: column;
    }

    .card-body .card-images {
        width: 100%;
    }

    .controls-card {
        flex-direction: column;
        align-items: stretch;
        gap: 1.5em;
    }

    .controls-card .controls-grid {
        grid-template-columns: 1fr;
        gap: 1em;
    }

    .results-summary {
        text-align: center;
        margin-right: 0;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .detail-container {
        margin: 1em;
        margin-top: 5em;
        padding: 1.5em;
        padding-bottom: 25px;
        margin-bottom: 65px;
    }

    /* Re-orders the detail sections for a logical flow on mobile */
    .detail-grid {
        display: flex;
        flex-direction: column;
    }

    .detail-images { order: 1; }
    .detail-notes { order: 2; }
    .detail-specs { order: 3; }
    .detail-dimensions-table { 
        order: 4; 
        margin-top: -2em;
    }
    .detail-presses { order: 5; } /* This moves the press list to the bottom */

    .dimensions-table .value-col {
        flex-direction: column;
        align-items: flex-end;
        gap: 0.5em;
    }

    .dimensions-table .value-col > span {
        margin-bottom: 0.5em;
    }
}

@media (max-width: 600px) {
    .dimension-grid {
        grid-template-columns: 1fr;
    }

    .theme-switcher, .page-controls {
        top: 5px;
        right: 5px;
    }
    
    .detail-header {
        flex-direction: column;
        gap: 1em;
        align-items: flex-start;
    }

    .detail-header-right {
        align-items: flex-start;
    }

    .detail-material {
        margin-left: 0;
    }
}