
/* =========================================================
   Pretty Result Table Formatting
========================================================= */

:root {
    --background: #f5f5f5;
    --background-danger: #9F6571;
    --surface: #ffffff;
    --surface-hover: #f0f0f0;
    --surface-header: #e0e0e0;

    --border: #dcdcdc;
    --border-subtle: #e6e6e6;

    --text: #333333;
    --text-strong: #000000;
    --text-muted: #666666;

    --accent: #4c8dff;

    --result-table-background: var(--surface);
    --result-table-header-background: var(--surface-header);
    --result-table-hover-background: var(--surface-hover);

    --result-table-border: var(--border);
    --result-table-header-border: var(--border-subtle);

    --result-table-text: var(--text);
    --result-table-header-text: var(--text-strong);
    --result-table-muted-text: var(--text-muted);

    --result-table-accent: var(--accent);
    --result-table-empty-text: var(--text-muted);
}

.header-link {
    width: 200px;
    padding: 10px;
    text-decoration: none;
    align-items: center;
    justify-content: center;
    background: var(--background);
    color: var(--text);
}

/* --- OpenFAB Index Page Styling --- */

.index-page {
    max-width: 1100px;
    margin: 0 auto;
    padding: 3rem 1.5rem;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    color: var(--text);
    line-height: 1.6;
}

/* Hero Section */
.index-page .hero {
    text-align: center;
    margin-bottom: 3.5rem;
}

.index-page .hero h1 {
    font-size: 2.75rem;
    font-weight: 800;
    color: var(--text);
    margin-bottom: 1rem;
    letter-spacing: -0.025em;
}

.index-page .tagline {
    font-size: 1.25rem;
    color: var(--text);
    max-width: 750px;
    margin: 0 auto 1.25rem auto;
}

.index-page .mission {
    font-size: 1rem;
    color: var(--text);
    max-width: 800px;
    margin: 0 auto;
    background: var(--surface);
    padding: 1rem 1.5rem;
    border-radius: 8px;
    border-left: 4px solid #3182ce;
    text-align: left;
}

.index-page .mission strong {
    color: var(--text);
}

/* Features Grid */
.index-page .features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-bottom: 4rem;
}

.index-page .feature {
    background: var(--surface);
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 2rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.index-page .feature:hover {
    background: var(surface_hover);
    transform: translateY(-3px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
}

.index-page .feature h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--accent);
    margin-bottom: 0.75rem;
}

.index-page .feature p {
    font-size: 0.95rem;
    color: var(--text);
    margin: 0;
}

/* Developer & Integration Resources Section */
.index-page .developer-resources {
    background: var(--surface);
    border: 1px solid #cbd5e0;
    border-radius: 12px;
    padding: 2.5rem;
    text-align: left;
}

.index-page .developer-resources h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 0.5rem;
}

.index-page .developer-resources p {
    color: var(--text);
    margin-bottom: 1.5rem;
}

.index-page .resource-links {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.index-page .resource-links li {
    font-size: 1rem;
}

.index-page .resource-links a {
    color: var(--text);
    text-decoration: none;
    font-weight: 500;
    transition: color 0.15s ease;
}

.index-page .resource-links a:hover {
    color: var(--accent);
    text-decoration: underline;
}

/* Responsive Adjustments */
@media (max-width: 768px) {
    .index-page {
        padding: 2rem 1rem;
    }

    .index-page .hero h1 {
        font-size: 2.25rem;
    }

    .index-page .tagline {
        font-size: 1.1rem;
    }
}

/* =========================================================
   Table
========================================================= */

.result-table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
    background-color: var(--result-table-background);
    color: var(--result-table-text);
    font-size: 0.95rem;
}


/* =========================================================
   Table Sections
========================================================= */

.result-table__head {
    background-color: var(--result-table-header-background);
}

.result-table__body {
    background-color: var(--result-table-background);
}


/* =========================================================
   Rows
========================================================= */

.result-table__row {
    border-bottom: 1px solid var(--result-table-border);
}

.result-table__body .result-table__row {
    transition: background-color 0.15s ease;
}

.result-table__body .result-table__row:hover {
    background-color: var(--result-table-hover-background);
}


/* =========================================================
   Primary Row Links
========================================================= */

.result-table__primary-link {
    color: var(--text-strong);
    font-weight: 500;
    text-decoration: none;
}

.result-table__primary-link:hover {
    color: var(--accent);
    text-decoration: underline;
}

.result-table__primary-link:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
    border-radius: 2px;
}


/* =========================================================
   Headers
========================================================= */

.result-table__header {
    padding: 0.75rem 1rem;
    border-bottom: 2px solid var(--result-table-header-border);
    color: var(--result-table-header-text);
    font-weight: 600;
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}


/* =========================================================
   Cells
========================================================= */

.result-table__cell {
    padding: 0.75rem 1rem;
    color: var(--result-table-text);
    vertical-align: middle;
    text-align: left;
}


/* =========================================================
   Column Alignment / Sizing
========================================================= */

.result-table__header--copies,
.result-table__cell--copies {
    width: 1%;
    text-align: center;
    white-space: nowrap;
}

.result-table__header--priority,
.result-table__cell--priority,
.result-table__header--state,
.result-table__cell--state,
.result-table__header--created,
.result-table__cell--created {
    white-space: nowrap;
}


/* =========================================================
   Time Values
========================================================= */

.result-table__time {
    color: var(--result-table-muted-text);
    white-space: nowrap;
}


/* =========================================================
   Empty State
========================================================= */

.result-table__row--empty {
    border-bottom: 0;
}

.result-table__cell--empty {
    padding: 2rem 1rem;
    color: var(--result-table-empty-text);
    text-align: center;
    font-style: italic;
}


/* =========================================================
   Responsive Behaviour
========================================================= */

@media (max-width: 768px) {
    .result-table {
        font-size: 0.875rem;
    }

    .result-table__header,
    .result-table__cell {
        padding: 0.6rem 0.75rem;
    }
}


/* =========================================================
   Result Table Actions
========================================================= */

.result-table__actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.result-table__action-form {
    display: inline;
    margin: 0;
}

.result-table__cell--actions {
    width: 1%;
    white-space: nowrap;
}

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


/* =========================================================
   Reset / Base
========================================================= */

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

html,
body {
    height: 100%;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", sans-serif;
    background: var(--background);
    color: var(--text);
}


/* =========================================================
   App Layout
========================================================= */

.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--background);
    color: var(--text);
}

.main {
    display: flex;
    flex: 1;
}

.content {
    display: flex;
    background: var(--background);
    flex: 1;
    flex-direction: column;
}

.page {
    flex: 1;
    padding: 20px;
}

.page-header {
    background: var(--surface);
    border: var(--border-subtle);
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 10px;
}


/* =========================================================
   Topbar
========================================================= */

.topbar {
    display: flex;
    align-items: center;
    height: 80px;
    background: var(--background);
    border-bottom: 1px solid var(--border);
    z-index: 10;
}

.topbar-inner {
    display: grid;
    /* Expanded the right column from 200px to 300px (or use 'auto' / 'minmax') */
    grid-template-columns: 200px 1fr 300px;
    align-items: center;
    width: 100%;
    padding: 0 16px;
    gap: 12px;
    /* border: 2px solid red; */ /* Uncomment for debugging */
}

.topbar-left,
.topbar-right {
    display: flex;
    align-items: center;
    /* border: 1px solid white; */
}

.topbar-left {
    justify-content: flex-start;
}

.topbar-right {
    justify-content: flex-end;
    gap: 12px; /* Adds spacing between multiple items in the right section */
}

.topbar-center {
    display: flex;
    justify-content: center;
    width: 100%; /* Let it scale nicely within the 1fr track */
    max-width: 400px;
    margin: 0 auto;
    /* border: 1px solid green; */
}

.logo {
    color: var(--text-strong);
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
}

.logo:hover {
    opacity: 0.8;
}


/* =========================================================
   Search
========================================================= */

.global-search {
    width: 100%;
    max-width: 420px;
    padding: 8px 12px;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    outline: none;
}

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

.global-search:focus {
    border-color: var(--accent);
}


/* =========================================================
   Sidebar
========================================================= */

.sidebar {
    width: 220px;
    padding: 16px 12px;
    background: var(--surface);
    border-right: 1px solid var(--border-subtle);
    overflow-y: auto;
}

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

.nav a {
    padding: 8px 10px;
    border-radius: 6px;
    color: var(--text-muted);
    font-size: 14px;
    text-decoration: none;
    transition: background 0.15s, color 0.15s;
}

.nav a:hover {
    background: var(--surface-hover);
    color: var(--text-strong);
}

.nav-section {
    margin-top: 12px;
    margin-bottom: 4px;
    padding: 4px 10px;
    color: var(--text-muted);
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}


/* =========================================================
   Context Bar
========================================================= */

.context-bar {
    display: flex;
    align-items: center;
    height: 44px;
    padding: 0 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-subtle);
    font-size: 14px;
}


/* =========================================================
   Utility Classes
========================================================= */

.hidden {
    display: none !important;
}

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

.flex {
    display: flex;
}

.flex-between {
    display: flex;
    align-items: center;
    justify-content: space-between;
}


/* =========================================================
   Buttons
========================================================= */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 12px;
    border: 1px solid transparent;
    border-radius: 8px;
    font-size: 14px;
    text-decoration: none;
    cursor: pointer;
}

.btn-primary {
    padding: 10px 16px;
    background: var(--accent);
    border: none;
    color: var(--text-strong);
}

.btn-danger {
    padding: 10px 16px;
    background: var(--background-danger);
    border: none;
    color: var(--text-strong);
}

.btn-primary:hover {
    opacity: 0.9;
}

.btn-secondary {
    background: var(--surface-hover);
    border-color: var(--border);
    color: var(--text-muted);
}

.btn-secondary:hover {
    background: var(--surface-header);
    color: var(--text-strong);
}


/* =========================================================
   Shared Page Header
========================================================= */

.asset-library-header,
.device-library-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 20px;
}

.asset-library-title,
.device-library-title {
    color: var(--text-strong);
    font-size: 24px;
    font-weight: 600;
    line-height: 1.2;
}

.asset-library-subtitle,
.device-library-subtitle {
    margin-top: 5px;
    color: var(--text-muted);
    font-size: 14px;
}

.asset-library-actions,
.device-library-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}


/* =========================================================
   Forms
========================================================= */

.device-form {
    max-width: 720px;
}

.form-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: var(--text-muted);
    font-size: 13px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text);
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--accent);
}

.form-group textarea {
    min-height: 90px;
    resize: vertical;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 12px;
}


/* =========================================================
   Advanced Form Section
========================================================= */

.advanced-section {
    margin-bottom: 18px;
    padding: 10px 12px;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
}

.advanced-summary {
    padding: 6px 4px;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    user-select: none;
}

.advanced-summary:hover,
details[open] .advanced-summary {
    color: var(--text-strong);
}

.advanced-content {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 12px;
}


/* =========================================================
   Shared Card
========================================================= */

.asset-card,
.device-card {
    display: flex;
    flex-direction: column;
    min-width: 0;

    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    transition: border-color 0.15s, background 0.15s, transform 0.15s;
}

.asset-card:hover,
.device-card:hover {
    background: var(--surface-hover);
    border-color: var(--border);
    transform: translateY(-1px);
}


/* =========================================================
   Asset Library
========================================================= */

.asset-library {
    width: 100%;
}

.asset-grid,
.device-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 16px;
}


/* =========================================================
   Asset Card Preview
========================================================= */

.asset-card-preview,
.device-card-header {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--surface-hover), var(--surface));
    border-bottom: 1px solid var(--border-subtle);
}

.asset-card-preview, .asset-preview {
    position: relative;
    height: 150px;
}

.device-card-header {
    position: relative;
    min-height: 130px;
    padding: 20px;
    justify-content: space-between;
}

.asset-file-icon,
.device-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 14px;
    font-size: 30px;
}


/* =========================================================
   Badges
========================================================= */

.asset-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    padding: 4px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
}

.asset-badge-public {
    background: rgba(40, 167, 69, 0.15);
    border: 1px solid rgba(40, 167, 69, 0.3);
    color: #77d69a;
}

.asset-badge-private {
    background: var(--surface-hover);
    border: 1px solid var(--border);
    color: var(--text-muted);
}


/* =========================================================
   Device Status
========================================================= */

.device-card-header .status-badge {
    align-self: flex-start;
    padding: 4px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 500;
    white-space: nowrap;
}

.status-online,
.status-connected {
    background: rgba(40, 167, 69, 0.15);
    border: 1px solid rgba(40, 167, 69, 0.3);
    color: #77d69a;
}

.status-printing {
    background: rgba(76, 141, 255, 0.15);
    border: 1px solid rgba(76, 141, 255, 0.3);
    color: #79adff;
}

.status-idle {
    background: var(--surface-hover);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.status-offline {
    background: rgba(220, 53, 69, 0.15);
    border: 1px solid rgba(220, 53, 69, 0.3);
    color: #e58b95;
}

.status-error {
    background: rgba(255, 123, 0, 0.15);
    border: 1px solid rgba(255, 123, 0, 0.3);
    color: #f0a17b;
}


/* =========================================================
   Card Body
========================================================= */

.asset-card-body,
.device-card-body {
    display: flex;
    flex: 1;
    flex-direction: column;
    min-width: 0;
    padding: 14px;
}

.asset-card-title,
.device-card-title {
    color: var(--text);
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.asset-card:has(details[open]),
.device-card:has(details[open]) {
    z-index: 10;
    position: relative; /* Required for z-index to take effect on grid items */
}

.asset-card-meta,
.device-card-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 7px;
    color: var(--text-muted);
    font-size: 12px;
}

.asset-card-meta {
}

.asset-card-meta span {
    white-space: nowrap;
    text-overflow: ellipsis;
}


/* =========================================================
   Device Metadata
========================================================= */

.device-card-meta {
    justify-content: space-between;
}

.device-card-meta span:first-child {
    color: var(--text-muted);
}

.device-card-meta span:last-child {
    min-width: 0;
    color: var(--text-muted);
    white-space: nowrap;
    text-overflow: ellipsis;
}


/* =========================================================
   Asset License
========================================================= */

.asset-license {
    display: flex;
    align-items: center;
    gap: 7px;
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid var(--border-subtle);
    color: var(--text-muted);
    font-size: 12px;
}

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


/* =========================================================
   Card Footers
========================================================= */

.asset-card-footer,
.device-card-footer {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    padding-top: 12px;
    border-top: 1px solid var(--border-subtle);
}

.asset-card-footer {
    justify-content: space-between;
    padding-top: 0;
    border-top: none;
}

.device-card-footer {
    justify-content: flex-end;
}

.asset-date {
    min-width: 0;
    color: var(--text-muted);
    font-size: 11px;
    white-space: nowrap;
    text-overflow: ellipsis;
}

.asset-card-actions {
    display: contents;
    align-items: center;
    flex-shrink: 0;
    gap: 6px;
}


/* =========================================================
   Empty States
========================================================= */

.asset-empty,
.device-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    padding: 40px;
    background: var(--surface);
    border: 1px dashed var(--border);
    border-radius: 10px;
    text-align: center;
}

.asset-empty-icon,
.device-empty-icon {
    margin-bottom: 12px;
    font-size: 36px;
}

.asset-empty h2,
.device-empty h2 {
    color: var(--text);
    font-size: 18px;
    font-weight: 600;
}

.asset-empty p,
.device-empty p {
    margin-top: 6px;
    margin-bottom: 18px;
    color: var(--text-muted);
    font-size: 14px;
}

.device-empty p {
    max-width: 420px;
}


/* =========================================================
   Scrollbars
========================================================= */

::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--surface-header);
}


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

@media (max-width: 700px) {
    .asset-library-header,
    .device-library-header {
        align-items: flex-start;
        flex-direction: column;
    }

    .asset-library-actions,
    .device-library-actions {
        width: 100%;
    }

    .asset-library-actions .btn,
    .device-library-actions .btn {
        width: 100%;
    }

    .asset-grid,
    .device-grid {
        grid-template-columns: 1fr;
    }
}


/* =========================================================
   Asset Detail
========================================================= */

.asset-detail {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: 24px;
}

.asset-detail-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
}

.asset-detail-preview .asset-preview {
    width: 100%;
    height: auto;
    max-height: 600px;
    object-fit: contain;
}

.asset-detail-info {
    min-width: 0;
}

.asset-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.asset-detail-header h2 {
    color: var(--text);
    font-size: 18px;
    font-weight: 600;
}

.asset-detail-fields {
    display: flex;
    flex-direction: column;
}

.asset-detail-field {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.asset-detail-field:first-child {
    padding-top: 0;
}

.asset-detail-field dt {
    color: var(--text-muted);
    font-size: 13px;
}

.asset-detail-field dd {
    min-width: 0;
    color: var(--text);
    font-size: 14px;
    word-break: break-word;
}

@media (max-width: 800px) {
    .asset-detail {
        grid-template-columns: 1fr;
    }

    .asset-detail-preview {
        min-height: 300px;
    }
}

@media (max-width: 500px) {
    .asset-detail-field {
        grid-template-columns: 1fr;
        gap: 4px;
    }
}


/* =========================================================
   Device Detail
========================================================= */

.device-detail {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(280px, 1fr);
    gap: 24px;
}

.device-detail-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    padding: 24px;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
}

.device-preview {
    display: block;
    width: 100%;
    height: auto;
    max-height: 600px;
    object-fit: contain;
}

.device-detail-preview .device-card-icon {
    width: 96px;
    height: 96px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 18px;
    font-size: 42px;
}

.device-detail-info {
    min-width: 0;
}

.device-detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
}

.device-detail-header h2 {
    color: var(--text);
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
}

.device-detail-fields {
    display: flex;
    flex-direction: column;
}

.device-detail-field {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.device-detail-field:first-child {
    padding-top: 0;
}

.device-detail-field:last-child {
    border-bottom: none;
}

.device-detail-field dt {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.5;
}

.device-detail-field dd {
    min-width: 0;
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.device-detail-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.device-detail-list li {
    padding: 4px 8px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-strong);
    font-size: 12px;
    line-height: 1.3;
}

@media (max-width: 800px) {
    .device-detail {
        grid-template-columns: 1fr;
    }

    .device-detail-preview {
        min-height: 300px;
    }

    .device-preview {
        max-height: 450px;
    }
}

@media (max-width: 500px) {
    .device-detail-field {
        grid-template-columns: 1fr;
        gap: 4px;
    }

    .device-detail-field dt {
        font-size: 12px;
    }

    .device-detail-field dd {
        font-size: 14px;
    }

    .device-detail-preview {
        min-height: 240px;
        padding: 16px;
    }
}


/* =========================================================
   Settings Library Tables & Filament Colors
========================================================= */

.device-library-table-container {
    width: 100%;
    overflow-x: auto;
    overflow-y: visible;
}

.device-library-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: auto;
}

.device-library-table thead {
    border-bottom: 1px solid var(--border);
}

.device-library-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
}

.device-library-table tbody tr {
    border-bottom: 1px solid var(--border);
    transition: background-color 0.15s ease;
}

.device-library-table tbody tr:hover {
    background-color: var(--surface-hover);
}

.device-library-table td {
    padding: 0.85rem 1rem;
    vertical-align: middle;
    color: var(--text);
}

.device-library-table td:first-child {
    min-width: 180px;
}

.device-library-table td:first-child a {
    color: var(--text);
    text-decoration: none;
}

.device-library-table td:first-child a:hover {
    text-decoration: underline;
}

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

.device-library-table-actions {
    width: 1%;
    text-align: right;
    white-space: nowrap;
}

.device-library-table-actions .button {
    white-space: nowrap;
}

.filament-colour-cell {
    width: 56px;
    min-width: 56px;
    text-align: center;
}

.filament-colour-swatch {
    display: inline-block;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: 1px solid var(--border);
    vertical-align: middle;
    box-sizing: border-box;
}

.device-library-empty {
    padding: 0 !important;
}

.device-library-empty-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
}

.device-library-empty-content h3 {
    margin: 0 0 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text);
}

.device-library-empty-content p {
    margin: 0 0 1.5rem;
    color: var(--text-muted);
}

@media (max-width: 768px) {
    .device-library-table th,
    .device-library-table td {
        padding: 0.7rem 0.75rem;
    }

    .device-library-table th:nth-child(5),
    .device-library-table td:nth-child(5),
    .device-library-table th:nth-child(6),
    .device-library-table td:nth-child(6) {
        display: none;
    }
}

/* --- Main Container --- */
.profile-edit {
    max-width: 800px;
    margin: 0 auto;
    padding-bottom: 3rem;
}

/* --- Page Header --- */
.profile-edit-header {
    margin-bottom: 2rem;
}

.profile-edit-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary, #1e293b);
    margin: 0 0 0.35rem 0;
}

.profile-edit-subtitle {
    font-size: 0.95rem;
    color: var(--text-secondary, #64748b);
    margin: 0;
}

/* --- Form Layout & Sections --- */
.profile-edit-form {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

.profile-edit-section {
    background-color: var(--surface, #ffffff);
    border: 1px solid var(--border, #e2e8f0);
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
    overflow: hidden;
}

.profile-edit-section-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border, #e2e8f0);
    background-color: var(--background, #f8fafc);
}

.profile-edit-section-header h2 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-strong, #1e293b);
    margin: 0 0 0.2rem 0;
}

.profile-edit-section-header p {
    font-size: 0.85rem;
    color: var(--text-strong, #64748b);
    margin: 0;
}

.profile-edit-section-body {
    padding: 1.5rem;
}

/* --- Avatar Upload Row --- */
.profile-edit-avatar-row {
    display: flex;
    align-items: center;
    gap: 1.25rem;
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
}

.dashboard-avatar {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    overflow: hidden;
    background-color: var(--avatar-bg, #e2e8f0);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 600;
    color: var(--text-muted, #475569);
}

.dashboard-avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dashboard-avatar-initials {
    font-size: 1.1rem;
    text-transform: uppercase;
}

.profile-edit-avatar-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.profile-edit-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-strong, #1e293b);
}

.profile-edit-file {
    font-size: 0.85rem;
    color: var(--text-strong, #64748b);
}

.profile-edit-help {
    font-size: 0.775rem;
    color: var(--text-muted, #94a3b8);
    margin: 0;
}

/* --- Form Fields Grid & Inputs --- */
.profile-edit-fields {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-strong, #334155);
}

.form-group input {
    padding: 0.65rem 0.875rem;
    font-size: 0.95rem;
    border: 1px solid var(--border, #cbd5e1);
    border-radius: 6px;
    background-color: var(--background, #ffffff);
    color: var(--text-strong, #1e293b);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* --- Form Actions Footer --- */
.profile-edit-actions {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 1rem;
    padding-top: 0.5rem;
}

/* =========================================================
   Dashboard
========================================================= */

.dashboard {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
}

.dashboard-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 24px;
}

.dashboard-title {
    color: var(--text-strong);
    font-size: 26px;
    font-weight: 600;
    line-height: 1.2;
}

.dashboard-subtitle {
    margin-top: 6px;
    color: var(--text-muted);
    font-size: 14px;
    line-height: 1.5;
}

.dashboard-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* --- Actions Grid Layout --- */
.dashboard-actions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1rem;
}

/* --- Individual Action Card/Link --- */
.dashboard-action {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 1rem;
    background-color: var(--background, #f8fafc);
    border: 1px solid var(--border-subtle, #e2e8f0);
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s ease-in-out;
}

.dashboard-action:hover {
    background-color: var(--surface-hover, #f1f5f9);
    border-color: var(--accent, #3b82f6);
    transform: translateY(-1px);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

/* --- Action Icon Box --- */
.dashboard-action-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    background-color: var(--surface, #e2e8f0);
    border-radius: 8px;
    font-size: 1.25rem;
    flex-shrink: 0;
}

/* --- Action Text & Subtitle --- */
.dashboard-action strong {
    display: block;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-strong, #1e293b);
    margin-bottom: 0.125rem;
}

.dashboard-action span {
    display: block;
    font-size: 0.8125rem;
    color: var(--text-muted, #64748b);
    line-height: 1.3;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 18px;
}

.dashboard-card {
    min-width: 0;
    background: var(--surface);
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
}

.dashboard-card--wide {
    grid-column: 1 / -1;
}

.dashboard-card-header {
    padding: 18px 20px;
}

.dashboard-card-header h2 {
    color: var(--text);
    font-size: 16px;
    font-weight: 600;
}

.dashboard-card-header p {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 13px;
}

.dashboard-profile {
    overflow: hidden;
    padding: 20px;
}

.dashboard-profile-header {
    display: flex;
    overflow: hidden;
    align-items: center;
    gap: 16px;
}

.dashboard-avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 64px;
    height: 64px;
    background: var(--surface-hover);
    border: 1px solid var(--border);
    border-radius: 50%;
}

.dashboard-avatar-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.dashboard-avatar-initials {
    color: var(--text-strong);
    font-size: 20px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.dashboard-profile-name {
    min-width: 0;
}

.dashboard-profile-name h2 {
    
    color: var(--text-strong);
    font-size: 18px;
    font-weight: 600;
    line-height: 1.3;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dashboard-profile-name p {
    margin-top: 4px;
    color: var(--text-muted);
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.dashboard-card-divider {
    height: 1px;
    margin: 20px 0 4px;
    background: var(--border-subtle);
}

.dashboard-fields {
    display: flex;
    flex-direction: column;
    margin: 20px;
}

.dashboard-field {
    display: grid;
    grid-template-columns: 120px minmax(0, 1fr);
    align-items: center;
    gap: 16px;
    min-height: 48px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border-subtle);
}

.dashboard-field:last-child {
    border-bottom: none;
}

.dashboard-field dt {
    color: var(--text-muted);
    font-size: 13px;
    line-height: 1.5;
}

.dashboard-field dd {
    min-width: 0;
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.dashboard-field-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
    font-size: 12px !important;
    color: var(--text-muted) !important;
}

.dropdown-container {
    position: relative;
    background: var(--background);
}
.dropdown-container summary {
    list-style: none;
    cursor: pointer;
}
.dropdown-container summary::-webkit-details-marker {
    display: none;
}
.dropdown-menu {
    position: absolute;
    right: 0;
    top: 100%;
    margin-top: 4px;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 6px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    z-index: 50;
    min-width: 140px;
    padding: 4px 0;
}
.dropdown-item, .dropdown-item-btn {
    z-index: 50;
    display: block;
    padding: 8px 12px;
    text-align: left;
    background: none;
    border: none;
    font-size: 13px;
    color: var(--text);
    text-decoration: none;
    cursor: pointer;
}
.dropdown-item:hover, .dropdown-item-btn:hover {
    background-color: var(--surface-hover);
}
.dropdown-form {
    margin: 0;
}

.bugreport-container {
    color: var(--text);
    background: var(--background);
}
.error-banner {
    border: 1px solid red;
    background: #ffdddd;
    color: red;
    padding: 10px;
}
.error_desc {
    rows: 200;
    cols: 50;
}

.group-badge-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem; /* 6px spacing between badges */
    align-items: center;
    padding: 0;
    margin: 0;
    list-style: none;
  }

  .group-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.55rem;
    font-size: 0.75rem;
    font-weight: 5rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    line-height: 1.25;
    color: #374151; /* Dark grey text */
    background-color: #f3f4f6; /* Light grey pill background */
    border: 1px solid #e5e7eb;
    border-radius: 9999px; /* Pill shape */
    text-decoration: none;
    transition: all 0.15s ease-in-out;
  }

  /* Interactive Hover State */
  .group-badge:hover {
    color: #1d4ed8; /* Darker blue on hover */
    background-color: #eff6ff; /* Soft blue fill on hover */
    border-color: #bfdbfe;
    text-decoration: none;
    transform: translateY(-1px); /* Slight lift */
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  }

  .group-badge:active {
    transform: translateY(0);
  }

  /* Optional: Placeholder state when user belongs to no groups */
  .no-groups {
    font-size: 0.75rem;
    color: #9ca3af;
    font-style: italic;
  }