/* Custom theme for Process cards and list view (mapped from Color.kt) */
:root {
    /* WeldPro palette (from Color.kt) - Desaturated for Corporate Look */
    --weld-orange: #D85A2B;
    --weld-orange-light: #E07A4A;
    --weld-orange-dark: #B54A2B;

    --steel-blue: #2C5F7C;
    --steel-blue-light: #3D7A9F;
    --steel-blue-dark: #1E4357;

    --background-dark: #121212;
    --surface-dark: #1E1E1E;
    --surface-variant: #2A2A2A;

    --accelerometer: #00E5FF;
    --magnetometer: #FFEA00;
    --audio: #76FF03;

    --success-green: #388E3C;
    --warning-amber: #FFA000;
    --error-red: #D32F2F;
    --info-blue: #1976D2;

    --text-primary: #FFFFFF;
    --text-secondary: #B0B0B0;
    --text-disabled: #5A5A5A;

    --divider: #404040;
    --border: #4A4A4A;
    --overlay-dark: rgba(0, 0, 0, 0.8);

    /* RGB variants for consistent rgba usage */
    --weld-orange-rgb: 255, 107, 53;
    --weld-orange-light-rgb: 255, 140, 90;
    --weld-orange-dark-rgb: 229, 90, 43;
    --steel-blue-rgb: 44, 95, 124;
    --steel-blue-light-rgb: 61, 122, 159;
    --steel-blue-dark-rgb: 30, 67, 87;
    --background-dark-rgb: 18, 18, 18;
    --surface-dark-rgb: 30, 30, 30;
    --surface-variant-rgb: 42, 42, 42;
    border-radius: 8px;
    color: var(--proc-value);
}

.proc-card .card-header {
    background: transparent;
    border-bottom: 1px solid rgba(var(--white-rgb), 0.04);
    padding-top: 14px;
    padding-bottom: 10px;
}

.proc-card .card-title {
    color: var(--weld-orange);
    font-size: 1.05rem;
}

.proc-badge {
    background: rgba(var(--steel-blue-dark-rgb), 0.7);
    color: var(--proc-label);
    border: 1px solid rgba(var(--white-rgb), 0.04);
}

.proc-info-panel {
    background: var(--surface-variant);
    border: 1px solid var(--divider);
    padding: 10px;
    border-radius: 6px;
    margin-bottom: 12px;
    color: var(--proc-value);
    font-size: 0.95rem;
}

.proc-info-panel .label {
    color: var(--proc-label);
    font-weight: 700;
}

.proc-info-panel .value {
    color: var(--proc-value);
    margin-left: 6px;
}

.proc-info-panel .muted {
    color: var(--proc-muted);
    font-weight: 600;
    margin-left: 6px;
}

.proc-metrics .metric {
    font-weight: 600;
}

.proc-footer {
    background: transparent;
    border-top: 1px solid rgba(var(--white-rgb), 0.03);
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.proc-footer .sessions-badge {
    background: rgba(var(--white-rgb), 0.03);
    color: var(--text-primary);
    border: 1px solid rgba(var(--white-rgb), 0.03);
}

/* Compact list/table view */
.proc-list {
    width: 100%;
}

.proc-list table {
    color: var(--proc-value);
}

.proc-list thead th {
    color: var(--steel-blue-light);
    border-bottom: 1px solid rgba(var(--white-rgb), 0.04);
}

.proc-list tbody tr:hover {
    background: rgba(var(--white-rgb), 0.02);
}

.view-toggle {
    margin-bottom: 12px;
}

.btn-ghost {
    background: transparent;
    border: 1px solid rgba(var(--white-rgb), 0.12);
    color: var(--text-primary);
}

.btn-ghost:hover {
    background: rgba(var(--white-rgb), 0.06);
    border-color: rgba(var(--white-rgb), 0.18);
}

.btn-ghost .bi {
    opacity: 0.85;
}

.badge-soft-success {
    background: rgba(var(--success-green-rgb), 0.12);
    color: var(--success-green);
    border: 1px solid rgba(var(--success-green-rgb), 0.2);
}

.badge-soft-warning {
    background: rgba(var(--warning-amber-rgb), 0.12);
    color: var(--warning-amber);
    border: 1px solid rgba(var(--warning-amber-rgb), 0.2);
}

.badge-soft-danger {
    background: rgba(var(--error-red-rgb), 0.12);
    color: var(--error-red);
    border: 1px solid rgba(var(--error-red-rgb), 0.2);
}

.badge-soft-secondary {
    background: rgba(var(--white-rgb), 0.06);
    color: var(--text-secondary);
    border: 1px solid rgba(var(--white-rgb), 0.08);
}

.badge-soft-info {
    background: rgba(var(--info-blue-rgb), 0.12);
    color: var(--info-blue);
    border: 1px solid rgba(var(--info-blue-rgb), 0.2);
}

.alert-soft {
    background: rgba(var(--white-rgb), 0.04);
    color: var(--text-primary);
    border: 1px solid rgba(var(--white-rgb), 0.08);
}

/* Consistência visual para grupos de ações em tabelas */
.ex-actions .btn-group.btn-group-sm .btn {
    min-width: 110px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

/* Small utility */
.muted-small {
    color: var(--proc-muted);
    font-size: 0.85rem;
}

/* Metric icon accents */
.metric-icon.primary {
    color: var(--accelerometer);
    font-size: 0.9rem;
}

.metric-icon.warning {
    color: var(--warning-amber);
    font-size: 0.9rem;
}

.metric-icon.danger {
    color: var(--error-red);
    font-size: 0.9rem;
}

.metric-icon.info {
    color: var(--info-blue);
    font-size: 0.9rem;
}

.metric-value {
    font-size: 1.05rem;
}

.metric-unit {
    font-size: 0.75rem;
    color: var(--proc-muted);
}

/* Utility classes moved from inline styles */
.sidebar-fixed {
    width: 280px;
    height: 100vh;
    position: fixed;
    overflow-y: auto;
}

.main-with-sidebar {
    margin-left: 280px;
    background-color: var(--background-dark);
    min-height: 100vh;
}

.sidebar-fixed {
    transition: width 0.2s ease, transform 0.25s ease;
}

.main-with-sidebar {
    transition: margin-left 0.2s ease;
}

.sidebar-toggle {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.sidebar-section-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    letter-spacing: 0.08rem;
    font-size: 0.75rem;
}

.sidebar .nav-link {
    display: flex;
    align-items: center;
    overflow: hidden;
}

.sidebar .nav-link .label {
    white-space: nowrap;
}

.sidebar .nav-link {
    padding: 0.5rem 0.75rem;
    border-left: 3px solid transparent;
}

.sidebar .nav-link:hover {
    background: rgba(var(--white-rgb), 0.04);
}

.sidebar .nav-link.active {
    border-left-color: var(--primary-color);
    background: transparent !important;
    border-radius: 0;
}

body.sidebar-collapsed .sidebar-fixed {
    width: 72px;
}

body.sidebar-collapsed .main-with-sidebar {
    margin-left: 72px;
}

body.sidebar-collapsed .sidebar .nav-link .label {
    display: none;
}

body.sidebar-collapsed .sidebar .fs-4.label {
    display: none;
}

body.sidebar-collapsed .sidebar .dropdown .label {
    display: none;
}

body.sidebar-collapsed .sidebar-section-title {
    display: none;
}

.sidebar-fixed.is-collapsed {
    width: 72px;
}

.sidebar .nav-link:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

.accent-line {
    border: 0;
    height: 2px;
    background: linear-gradient(to right, rgba(var(--weld-orange-rgb), 0.6), rgba(var(--steel-blue-light-rgb), 0.4));
}

.section-status .bi {
    color: var(--steel-blue-light);
}

.section-problem .bi {
    color: var(--warning-amber);
}

.section-action .bi {
    color: var(--weld-orange);
}

/* Footer calibration note (aligned to main content, not overlaying sidebar) */
.footer-calibration {
    position: fixed;
    bottom: 0;
    left: 280px;
    /* match sidebar width */
    width: calc(100% - 280px);
    background: rgba(17, 24, 39, 0.95);
    border-top: 1px solid rgba(255, 255, 255, 0.04);
    z-index: 1020;
}

@media (max-width: 991.98px) {
    .main-with-sidebar {
        margin-left: 0;
        padding-top: 0;
    }

    .sidebar-fixed {
        display: none !important;
    }

    .footer-calibration {
        left: 0;
        width: 100%;
    }
}

/* Small phones (≤480px) */
@media (max-width: 480px) {

    .container,
    .container-fluid {
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }

    .card,
    .metric-card {
        width: 100% !important;
        max-width: 100%;
        margin-left: 0 !important;
        margin-right: 0 !important;
        overflow: hidden;
    }

    .card .card-body,
    .metric-card .card-body {
        padding: 0.75rem;
    }

    .col-auto {
        flex: 0 0 100%;
        width: 100%;
    }

    .table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .list-group,
    .proc-list,
    .proc-card {
        max-width: 100%;
    }
}

/* Small tablets (≤768px) */
@media (max-width: 768px) {

    .card,
    .metric-card {
        width: 100%;
        max-width: 100%;
    }

    .col-auto {
        flex: 0 0 100%;
        width: 100%;
    }

    .table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

.big-icon {
    font-size: 3rem;
}

.icon-sm {
    font-size: 1.5rem;
}

.page-size-select {
    width: 100px;
    display: inline-block;
}

/* removed stray brace */


/* Footer calibration note (aligned to main content, not overlaying sidebar) */
/* removed duplicated footer and breakpoint block */

/* removed duplicated mobile breakpoint blocks */

.big-icon {
    font-size: 3rem;
}

.icon-sm {
    font-size: 1.5rem;
}

.page-size-select {
    width: 100px;
    display: inline-block;
}

.hidden {
    display: none;
}

.card-header-custom {
    background: transparent;
    border-bottom: 1px solid rgba(var(--white-rgb), 0.04);
    padding-top: 14px;
    padding-bottom: 10px;
}

.card-title-custom {
    color: var(--accelerometer);
    font-size: 1.05rem;
}

.small-muted {
    color: rgba(var(--white-rgb), 0.6);
    font-size: 0.9rem;
}

.mobile-navbar {
    position: sticky;
    top: 0;
    display: flex;
    height: 56px;
    background: var(--surface-dark);
    border-bottom: 1px solid var(--surface-variant);
    z-index: 1050;
}

.mobile-navbar .btn:active {
    transform: scale(0.98);
}

.mobile-navbar .fw-bold {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1035;
    display: none;
}

.proc-status-active {
    color: var(--success-green);
    font-weight: 700;
}

.proc-status-inactive {
    color: var(--text-secondary);
    font-weight: 600;
}

/* Collapsible process list styles */
.proc-list-collapsed {
    width: 100%;
}

.proc-item {
    border: 1px solid var(--proc-border);
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
    background: var(--proc-bg);
}

.proc-item .proc-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
}

.proc-item .proc-header:hover {
    background: rgba(var(--white-rgb), 0.01);
}

.proc-item .proc-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.proc-item .proc-title .badge {
    background: rgba(var(--white-rgb), 0.03);
    color: var(--text-secondary);
}

.proc-item .proc-body {
    padding: 12px 16px;
    border-top: 1px solid var(--divider);
}

.proc-toggle-icon {
    transition: transform 0.25s ease;
}

.proc-toggle-icon.collapsed {
    transform: rotate(0deg);
}

.proc-toggle-icon.expanded {
    transform: rotate(180deg);
}

.hidden-row {
    display: none !important;
}

/* Status pill styling for header */
.proc-status-active,
.proc-status-inactive {
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
}

.proc-status-active {
    background: rgba(var(--success-green-rgb), 0.12);
    color: var(--success-green);
}

.collapse { will-change: height; }
.collapsing { transition: height 0.25s ease-out; will-change: height; overflow: hidden; }
.collapse .card, .collapse .metric-card { animation: none !important; }
.proc-item .proc-body { transform: translateZ(0); }

.card-body form .d-flex.align-items-end.gap-2 { gap: 0.5rem !important; }
@media (max-width: 768px) {
  .card-body form .d-flex.align-items-end.gap-2 { flex-direction: column; }
  .card-body form .d-flex.align-items-end.gap-2 .btn { width: 100% !important; }
}
@media (min-width: 769px) {
  .card-body form .d-flex.align-items-end.gap-2 { flex-wrap: nowrap; }
  .card-body form .d-flex.align-items-end.gap-2 .btn { width: auto !important; flex: 0 1 auto; }
}

/* Compact pagination on mobile */
.pagination {
    flex-wrap: wrap;
    gap: 0.25rem;
}

.pagination .page-item {
    margin: 0;
}

.pagination .page-link {
    padding: 0.375rem 0.5rem;
    font-size: 0.875rem;
    min-width: 36px;
    text-align: center;
}

/* Make pagination text more compact */
.pagination .page-link i {
    margin: 0;
}

/* Ensure table content scrolls instead of page overflowing */
.table-responsive {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
}

/* Sessions page: allow columns to shrink and wrap on mobile */
.sessoes-table { table-layout: fixed; }
.sessoes-table th, .sessoes-table td { word-break: break-word; overflow-wrap: anywhere; }

@media (max-width: 768px) {
  .sessoes-filters .form-select,
  .sessoes-filters .form-control { width: 100%; }
}

.mobile-card-view thead {
    display: none;
}

.mobile-card-view tbody tr {
    display: block;
    background: var(--surface-variant);
    border: 1px solid var(--divider);
    border-radius: 8px;
    margin-bottom: 1rem;
    padding: 1rem;
}

.mobile-card-view tbody td {
    display: block;
    border: none;
    padding: 0.5rem 0;
    text-align: left;
    width: 100%;
}

.mobile-card-view tbody td:last-child {
    border-bottom: none;
    padding-bottom: 0;
    margin-top: 0.5rem;
    border-top: 1px solid var(--divider);
    padding-top: 1rem;
}

/* Override button widths on mobile */
.mobile-card-view .ex-actions .btn-group.btn-group-sm {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
}

.mobile-card-view .ex-actions .btn-group.btn-group-sm .btn {
    min-width: 0;
    flex: 1 1 auto;
    justify-content: center;
}

/* Fix any buttons in mobile card view */
.mobile-card-view .btn {
    white-space: normal;
    word-wrap: break-word;
}

/* removed stray closing brace */

/* Mobile menu card: ensure dropdown is visible and bounded on small screens */
.mobile-menu-card { overflow: visible; }
.mobile-menu-card .card-body { overflow: visible; }
.mobile-menu-card .dropdown-menu {
    z-index: 1080;
    max-width: calc(100vw - 16px);
    width: auto;
    left: auto !important;
    right: 0 !important;
    overflow-wrap: anywhere;
}

/* Reduce padding on mobile */
.container,
.container-fluid {
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

.card-body {
    padding: 1rem;
}

/* Ensure text truncation works in flex items */
.text-truncate {
    max-width: 100%;
}

/* Adjust badges and icons spacing */
.badge {
    margin-top: 2px;
    margin-bottom: 2px;
}
}

/* Mobile Card View for Tables */
@media (max-width: 768px) {

    /* Prevent card overflow */
    .card {
        overflow-x: hidden;
    }

    /* Reduce card body padding on mobile */
    .card-body {
        padding: 0.75rem !important;
    }

    /* Fix filter form button container */
    .card-body form .d-flex.align-items-end.gap-2 {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.5rem !important;
    }

    .card-body form .d-flex.align-items-end.gap-2 .btn {
        width: 100% !important;
    }

    /* Compact pagination on mobile */
    .pagination {
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .pagination .page-item {
        margin: 0;
    }

    .pagination .page-link {
        padding: 0.375rem 0.5rem;
        font-size: 0.875rem;
        min-width: 36px;
        text-align: center;
    }

    /* Make pagination text more compact */
    .pagination .page-link i {
        margin: 0;
    }

    /* Ensure table-responsive doesn't cause overflow */
    .table-responsive {
        overflow-x: visible !important;
    }

    .mobile-card-view thead {
        display: none;
    }

    .mobile-card-view tbody tr {
        display: block;
        background: var(--surface-variant);
        border: 1px solid var(--divider);
        border-radius: 8px;
        margin-bottom: 1rem;
        padding: 1rem;
    }

    .mobile-card-view tbody td {
        display: block;
        border: none;
        padding: 0.5rem 0;
        text-align: left;
        width: 100%;
    }

    .mobile-card-view tbody td:last-child {
        border-bottom: none;
        padding-bottom: 0;
        margin-top: 0.5rem;
        border-top: 1px solid var(--divider);
        padding-top: 1rem;
    }

    /* Override button widths on mobile */
    .mobile-card-view .ex-actions .btn-group.btn-group-sm {
        display: flex;
        flex-wrap: wrap;
        gap: 0.5rem;
        width: 100%;
    }

    .mobile-card-view .ex-actions .btn-group.btn-group-sm .btn {
        min-width: 0;
        flex: 1 1 auto;
        justify-content: center;
    }

    /* Fix any buttons in mobile card view */
    .mobile-card-view .btn {
        white-space: normal;
        word-wrap: break-word;
    }
}
