/* ================================================= */
/* == STYLESHEET FOR GCRIPT DOCUMENT PROCESSOR    == */
/* == Approach: Desktop First, Responsive        == */
/* ================================================= */

/* ================================================= */
/* == 0. ROOT & THEME VARIABLES                   == */
/* ================================================= */
:root {
    /* Base Colors */
    --color-white: #ffffff;
    --color-black: #000000;
    --color-gray-text: #6c757d;
    /* Bootstrap's standard muted gray */
    --color-gray-page-bg: #f8f9fa;
    /* Page background */
    --color-gray-card-bg: #ffffff;
    /* Card background */
    --color-gray-border: #dee2e6;
    /* Standard border color */
    --color-gray-light-bg: #f8f9fa;
    /* Light bg for elements */
    --color-text-default: #212529;
    /* Bootstrap's default text */

    /* Primary Accent (Blue) */
    --accent-primary: #007bc0;
    --rgb-accent-primary: 0, 123, 192;
    --accent-primary-darker: #00629A;
    --accent-primary-lighter: #E6F2FA;
    /* Adjusted for subtlety */
    --accent-primary-border-tint: #B8D6FF;

    /* Semantic Colors */
    --color-success: #00884a;
    --rgb-color-success: 0, 136, 74;
    --color-success-darker: #005F32;
    --color-success-lighter: #E2F5E9;
    --color-danger: #ed0007;
    --rgb-color-danger: 237, 0, 7;
    --color-danger-darker: #B30005;
    --color-danger-lighter: #FDEDED;

    /* Font Sizes (Base: 16px) */
    --font-size-base: 1rem;
    --font-size-sm: 0.875rem;
    /* 14px */
    --font-size-xs: 0.75rem;
    /* 12px */
    --font-size-lg: 1.125rem;
    /* 18px */
    --font-size-h1: 1.5rem;
    /* 24px */
    --font-size-h2: 1.25rem;
    /* 20px */

    /* Other Variables */
    --line-height-base: 1.5;
    --default-border-radius: 0.375rem;
    /* Bootstrap 5 default */
    --default-box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* ================================================= */
/* == 1. GENERAL BODY & TYPOGRAPHY                == */
/* ================================================= */
body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
    font-size: 0.95rem;
    line-height: var(--line-height-base);
    color: var(--color-text-default);
    background-color: var(--color-gray-page-bg);
    margin: 0;
    padding-top: 50px;
    /* Add padding to prevent content hiding behind sticky header */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
h5,
h6 {
    margin-top: 0;
    margin-bottom: 0.5rem;
    font-weight: 600;
    line-height: 1.3;
    color: var(--color-text-default);
}

h1.app-title {
    font-size: var(--font-size-h1);
    color: var(--accent-primary);
    font-weight: 600;
    margin: 0;
}

h2 {
    font-size: var(--font-size-h2);
    font-weight: 600;
}

p {
    margin-top: 0;
    margin-bottom: 1rem;
}

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

.small,
small {
    font-size: var(--font-size-sm);
}

a {
    color: var(--accent-primary);
    text-decoration: none;
}

a:hover {
    color: var(--accent-primary-darker);
    text-decoration: underline;
}

.form-text {
    font-size: var(--font-size-sm);
    color: var(--color-gray-text);
    line-height: 1.4;
    white-space: normal;
    /* Ensure wrapping is allowed */
    overflow-wrap: break-word;
    /* Break long words if necessary */
    word-wrap: break-word;
    /* Older browser compatibility for overflow-wrap */
}


/* ================================================= */
/* == 2. LAYOUT & CONTAINER                       == */
/* ================================================= */
.container {
    max-width: 1320px;
    padding: 1rem;
    margin-top: 1.5rem;
    margin-bottom: 1.5rem;
}

.row {
    --bs-gutter-x: 1.5rem;
    /* Default Bootstrap gutter */
    --bs-gutter-y: 1.5rem;
    /* Add vertical gutter */
    align-items: flex-start;
}

/* Ensure columns have space when stacking */
.row>* {
    margin-bottom: 1.5rem;
}

.row>*:last-child {
    margin-bottom: 0;
}

@media (min-width: 768px) {
    .row>* {
        margin-bottom: 0;
    }
}


/* ================================================= */
/* == 3. HEADER                                   == */
/* ================================================= */
.app-header {
    background-color: var(--color-white);
    border-bottom: 1px solid var(--color-gray-border);
    padding: 0.6rem 1rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    position: fixed;
    /* Changed to fixed for better persistence */
    top: 0;
    left: 0;
    right: 0;
    z-index: 1030;
}

.app-header .container-fluid {
    padding-left: 1rem;
    padding-right: 1rem;
}

.logout-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary);
    background-color: transparent;
    padding: 0.375rem 0.75rem;
    font-size: var(--font-size-sm);
    font-weight: 500;
    border-radius: var(--default-border-radius);
    transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out;
}

.logout-btn:hover {
    background-color: var(--accent-primary);
    color: var(--color-white);
    text-decoration: none;
}

/* --- New Rules for Header Controls --- */
.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
    /* Spacing between toggle and button */
}

/* Override form-switch styles *only* within the header */
.header-controls .form-check.form-switch {
    margin-bottom: 0;
    /* Remove any bottom margin */
    padding-left: 0;
    /* Remove parent padding */
    flex-direction: row;
    /* Force horizontal layout */
    align-items: center;
    /* Center items vertically */
    min-height: auto;
    /* Allow natural height */
}

.header-controls .form-check.form-switch .form-check-input {
    position: static;
    /* Use static positioning */
    margin-left: 0;
    /* No negative margin */
    margin-right: 0.5em;
    /* Space after switch */
    top: auto;
    /* Reset 'top' */
    width: 2em;
    /* Standard size */
    height: 1em;
    /* Standard size */
}

.header-controls .form-check.form-switch .form-check-label {
    padding-left: 0;
    /* Remove padding */
    margin-bottom: 0;
    /* Remove margin */
    padding-top: 0;
    /* Remove padding */
    white-space: nowrap;
    /* Prevent label wrapping */
}

/* ================================================= */
/* == 4. CARDS                                    == */
/* ================================================= */
.card {
    border: 1px solid var(--color-gray-border);
    border-radius: var(--default-border-radius);
    box-shadow: var(--default-box-shadow);
    background-color: var(--color-gray-card-bg);
    display: flex;
    flex-direction: column;
    /*height: 100%;*/
    /* For equal height cards in a row */
    margin-bottom: 1.5rem;
    /* Spacing between stacked cards */
}

.card:last-child {
    margin-bottom: 0;
}

.card-header {
    background-color: var(--accent-primary-lighter);
    border-bottom: 1px solid var(--color-gray-border);
    padding: 0.75rem 1.25rem;
}

.card-header h2 {
    color: var(--accent-primary);
    font-size: 1.05rem;
    /* Slightly increased for clarity */
    margin: 0;
}

.card-body {
    padding: 0.85rem;
    flex-grow: 1;
}

.card .mb-3:last-child {
    margin-bottom: 0;
    /* Prevent extra space at card bottom */
}

/* Reduce bottom margin for the Processing Coverage card specifically
    .card:has(.coverage-slider-container) {
        margin-bottom: 0.rem;
    }*/

/* Reduce bottom margin for the Processing Coverage card specifically 
    .card:has(.coverage-slider-container) {
        margin-bottom: 0.rem;
    }*/

/* NEW RULE: Reduce bottom margin for the LLM Provider Settings card */
/* This targets the second card within the second column */
/*.row>.col-lg-4:nth-child(2)>.card:nth-of-type(2) {
        margin-bottom: 0.5rem !important;
        /* Was 1.5rem from general .card rule 
    }*/

/* ================================================= */
/* == 5. FORMS & BUTTONS                          == */
/* ================================================= */
.form-label {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    /* Standardized label weight */
    color: var(--color-text-default);
}

.form-control,
.form-select {
    font-size: var(--font-size-sm);
    border-radius: var(--default-border-radius);
    border: 1px solid var(--color-gray-border);
    padding: 0.5rem 0.75rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 0.2rem rgba(var(--rgb-accent-primary), 0.25);
}

/* --- Buttons --- */
.btn {
    font-size: var(--font-size-sm);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--default-border-radius);
    transition: all 0.15s ease-in-out;
    border: 1px solid transparent;
    cursor: pointer;
}

.btn-primary {
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
    color: var(--color-white);
}

.btn-primary:hover {
    background-color: var(--accent-primary-darker);
    border-color: var(--accent-primary-darker);
}

.btn-success {
    background-color: var(--color-success);
    border-color: var(--color-success);
    color: var(--color-white);
}

.btn-success:hover {
    background-color: var(--color-success-darker);
    border-color: var(--color-success-darker);
}

#process-btn {
    padding: 0.65rem 1.25rem;
    font-size: 1rem;
    font-weight: 600;
    margin-top: 0 !important;
    /* Overrides .mt-3, reduced space above */
    margin-bottom: 1rem !important;
    /* Ensures some space below, overrides .mb-3 */
}

/* --- Input Group --- */
/* --- Input Group (Compact) --- */
.input-group {
    position: relative;
    display: flex;
    flex-wrap: nowrap;
    align-items: stretch;
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 0.5rem;
    /* reduce space between fields */
}

.input-group .form-control {
    border-right: 0;
    position: relative;
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
    padding: 0.4rem 0.6rem;
    /* tighter padding */
    font-size: 0.875rem;
    /* slightly smaller font */
}

.input-group .btn,
.input-group .btn-primary {
    border-top-left-radius: 0;
    border-bottom-left-radius: 0;
    border-left: 1px solid var(--accent-primary);
    position: relative;
    z-index: 2;
    padding: 0.4rem 0.6rem;
    /* compact button padding */
    font-size: 0.875rem;
}

.input-group-text {
    display: flex;
    align-items: center;
    padding: 0.4rem 0.6rem;
    font-size: 0.875rem;
    font-weight: 400;
    line-height: 1.3;
    color: var(--accent-primary);
    text-align: center;
    white-space: nowrap;
    background-color: var(--accent-primary-lighter);
    border: 1px solid var(--color-gray-border);
    border-radius: var(--default-border-radius);
    cursor: pointer;
}

/* --- Form Switches (Toggle) --- */
.form-switch {
    padding-left: 3em;
    /* Ensure enough space for switch */
    display: flex;
    /* Use flex for better control */
    flex-direction: column;
    /* Stack label and help text */
    align-items: flex-start;
    position: relative;
    /* For input positioning */
    min-height: 2.5em;
    /* Ensure enough height */
}

.form-switch .form-check-input {
    width: 2em;
    height: 1em;
    margin-left: -3em;
    /* Position switch to the left */
    position: absolute;
    top: 0.25em;
    /* Adjust vertical alignment */
    background-position: left center;
}

.form-switch .form-check-label {
    margin-bottom: 0.25rem;
    /* Space between label and help text */
    padding-left: 0.5em;
    /* Space between switch and label */
    padding-top: 0.1em;
    /* Align vertically */
}

.form-switch .form-text {
    margin-left: 0;
    /* Align with label (already indented by parent) */
    padding-left: 0.5em;
    /* Align with label text */
    margin-top: 0;
    /* Reset top margin */
    display: block;
    /* Ensure it's a block */
}

.form-check-input:checked {
    background-color: var(--accent-primary) !important;
    border-color: var(--accent-primary) !important;
}

.form-check-input:focus {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 0.2rem rgba(var(--rgb-accent-primary), 0.25);
}

/* Specific fix for chunked upload help text icon */
#chunkedUploadToggle~.form-text i,
#chunkedUploadToggle~small i {
    color: var(--accent-primary);
    margin-right: 0.25em;
}

/* Ensure the 'small' tag used in the first example is also covered */
.form-switch small.form-text {
    padding-left: 0.5em;
    /* Align with label text */
    margin-top: 0;
    /* Reset top margin */
    display: block;
    /* Ensure it's a block */
}

/* Ensure JS-added switches get styled */
#token-optimization-container .form-switch .form-text {
    padding-left: 0.5em;
    /* Align with label text */
    margin-top: 0;
    /* Reset top margin */
    display: block;
    /* Ensure it's a block */
}

/* == AGGRESSIVE OVERRIDE for chunked upload help text ==
       Attempting to force left alignment by counteracting parent padding.
    */
#chunkedUploadToggle~.form-text,
#chunkedUploadToggle~small.form-text {
    padding-left: 0 !important;
    margin-left: -3rem !important;
    /* Use 'rem' and !important */
    width: auto !important;
    /* Allow natural width but ensure margin works */
    display: block !important;
    position: relative !important;
    /* Ensure positioning context */
    left: 0 !important;
    /* Force left edge */
}

/* Reduce space below batch mode label */
.form-switch .form-check-label[for="chunkedUploadToggle"] {
    margin-bottom: 0.1rem !important;
    /* REDUCED space below label */
}

/* == AGGRESSIVE OVERRIDE for batch mode help text == */
#batch-mode-toggle~.form-text,
#batch-mode-toggle~div.form-text {
    padding-left: 0 !important;
    margin-left: -3rem !important;
    /* Use 'rem' and !important */
    margin-top: 0.1rem !important;
    width: auto !important;
    display: block !important;
    position: relative !important;
    left: 0 !important;
}

/* Reduce space below batch mode label */
.form-switch .form-check-label[for="batch-mode-toggle"] {
    margin-bottom: 0.1rem !important;
    /* REDUCED space below label */
}

/* ================================================= */
/* == 6. SPECIFIC UI COMPONENTS                   == */
/* ================================================= */

/* --- Upload Area --- */
.upload-area {
    border: 2px dashed var(--color-gray-border);
    border-radius: var(--default-border-radius);
    padding: 1rem;
    /* Reduced height */
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    background-color: var(--color-white);
    margin-bottom: 1rem;
}

.upload-area:hover,
.upload-area.dragover {
    border-color: var(--accent-primary);
    background-color: var(--accent-primary-lighter);
}

/*  Inline style in html for cloud icon is controlling this style="font-size: 48px; color: #0099ff;"
    .upload-area i {
        font-size: 32px;
        /* Reduced icon size slightly 
        color: var(--accent-primary);
        margin-bottom: 0.25rem;
        display: block;
    }
    */

.upload-area p {
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
    color: var(--color-gray-text);
}

/* --- Protected Words --- */
.protected-words-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
    min-height: 1.5rem;
    /* Give it some height even when empty */
}

.word-tag {
    display: inline-flex;
    align-items: center;
    background-color: var(--accent-primary-lighter);
    color: var(--accent-primary);
    border: 1px solid var(--accent-primary-border-tint);
    border-radius: var(--default-border-radius);
    padding: 0.25rem 0.6rem;
    font-size: var(--font-size-sm);

    /* Ensure tags don't overflow their container and text wraps */
    max-width: 100%;
    /* Prevent individual tags from exceeding parent width */
    overflow-wrap: break-word;
    /* Allows breaking long words */
    word-wrap: break-word;
    /* Older browser compatibility for overflow-wrap */
    word-break: break-word;
    /* Helps break words more effectively if needed */
    /* Consider 'break-all' if 'break-word' is not aggressive enough for some strings */
}

.word-tag .remove-word {
    background: none;
    border: none;
    color: var(--color-danger);
    cursor: pointer;
    font-size: 1.2em;
    line-height: 1;
    margin-left: 0.5rem;
    padding: 0;
    opacity: 0.7;
}

.word-tag .remove-word:hover {
    opacity: 1;
}

#no-words-msg {
    font-style: italic;
    color: var(--color-gray-text);
    font-size: var(--font-size-sm);
}

.protected-words-tags:not(:empty)+#no-words-msg {
    display: none;
}


/* --- Processing Coverage Slider --- */
.coverage-slider-container {
    position: relative;
    margin: 0.25rem 0 0.25rem 0;
    /* reduced vertical margins */
}

/* FIX 5: Ensure label has standard weight */
.coverage-slider-container~.form-label,
label[for="wordCountCoverage"] {
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.25rem;
}

.coverage-slider {
    display: flex;
    background: var(--color-gray-light-bg);
    border-radius: 18px;
    padding: 3px;
    border: 1px solid var(--color-gray-border);
}

.coverage-option {
    flex: 1;
    padding: 0.6rem 0.75rem;
    /* Increased padding slightly for taller feel */
    text-align: center;
    cursor: pointer;
    border-radius: 15px;
    transition: all 0.2s ease;
    background: transparent;
    border: none;
    font-weight: 500;
    color: var(--color-gray-text);
    font-size: 0.9rem;
    /* INCREASED text size */
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
}

.coverage-option.active {
    background: var(--accent-primary);
    color: var(--color-white);
    box-shadow: 0 2px 4px rgba(var(--rgb-accent-primary), 0.3);
}

.coverage-option:hover:not(.active) {
    background: var(--accent-primary-lighter);
    color: var(--accent-primary);
}

.coverage-description {
    margin-top: 1rem;
    /* Adjusted margin */
    padding: 0.5rem;
    background: var(--accent-primary-lighter);
    border-radius: var(--default-border-radius);
    border-left: 4px solid var(--accent-primary);
    transition: all 0.3s ease;
    margin-bottom: 0;
    /* Ensure no extra margin at bottom */
}

.description-title {
    font-weight: 600;
    color: var(--accent-primary);
    margin-bottom: 0.4rem;
    /* Adjusted margin */
    font-size: 0.9rem;
    display: block;
    /* Ensure full width */
    line-height: 1.3;
    /* Added for readability */
    white-space: normal;
    /* Ensure wrapping */
    overflow-wrap: break-word;
    /* Break long words */
    word-wrap: break-word;
}

.description-details {
    color: var(--color-gray-text);
    font-size: var(--font-size-sm);
    margin-bottom: 0;
    display: block;
    /* Ensure full width */
    line-height: 1.4;
    /* Added for readability */
    white-space: normal;
    /* Ensure wrapping */
    overflow-wrap: break-word;
    /* Break long words */
    word-wrap: break-word;
}

/* --- Tooltips --- */
.tooltip-trigger {
    position: relative;
    cursor: help;
}

.custom-tooltip {
    position: absolute;
    bottom: 110%;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 0.4rem 0.6rem;
    border-radius: 4px;
    font-size: var(--font-size-xs);
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s ease;
    z-index: 1050;
    margin-bottom: 6px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.custom-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #333;
}

/* --- FAQ Page Specific --- */
.faq-section .card-header {
    cursor: pointer;
}


.tooltip-trigger:hover .custom-tooltip {
    opacity: 1;
    visibility: visible;
}

/* --- Status & Messages --- */

#initial-status p {
    font-size: var(--font-size-sm);
}

/* ================================================= */
/* == ENHANCED MESSAGE TYPE STYLES - Phase 7      == */
/* ================================================= */

/* Base message styling - extends existing #message-container styles */
/*.message:last-child {
    margin-bottom: 0;
}*/


/* PRIORITY-BASED OPACITY for message management */

/* ================================================= */
/* == PROGRESS CONTEXT DISPLAY - Step 3           == */
/* ================================================= */

/* Responsive adjustments for progress context */
@media(max-width: 767.98px) {
    .progresscontext {
        font-size: var(--font-size-xs);
        padding: 0.3rem 0.5rem;
        margin-top: 0.4rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 0.3rem;
    }
}

/* Compact UI adjustments for progress context */
.compact-ui.progress-context {
    font-size: var(--font-size-xs);
    padding: 0.3rem 0.5rem;
    margin-top: 0.3rem;
}

.compact-ui.progress-context i {
    margin-right: 0.2rem;
    font-size: 0.9rem;
}

/* Special styling for different context states */
.progress-context.tableprocessing {
    border-left-color: #4a90e2;
    background-color: #f0f8ff;
}

/* ================================================= */
/* == TIMING INFORMATION SECTION - Step 4         == */
/* ================================================= */
#timing-section .form-label i {
    color: var(--accent-primary);
}

#timing-content .card-body {
    padding: 0.75rem;
}

/* Responsive adjustments for timing section */
@media (max-width: 767.98px) {

    /* Keep from previous */
    #toggle-timing-details {
        font-size: 0.7rem;
        padding: 0.2rem 0.4rem;
    }
}

.timing-display .row .col-6>* {
    line-height: 1.3;
}

.timing-display .row .col-6:hover,
.timing-display .row .col-4:hover {
    /* Added for potential 3-column layout */
    background-color: rgba(var(--rgb-accent-primary), 0.08);
    border-radius: calc(var(--default-border-radius) / 2);
    transition: all 0.2s ease;
    transform: translateY(-1px);
}

/* Fix for very long timing values */
.timing-display strong {
    word-break: break-word;
    max-width: 100%;
}

/* Subtle hover effects for timing metrics */

/* Detailed timing view specific styles - UPDATED */
.timing-display.detailed-view .row:not(:last-of-type) {
    /* Affects rows of metric pairs */
    margin-bottom: 0.5rem;
    /* REDUCED from 1rem for compactness between metric rows */
}



/* ================================================= */
/* == 7. COMPACT UI MODE                          == */
/* ================================================= */
.compact-ui body {
    font-size: 0.9rem;
}

.compact-ui .card-body {
    padding: 0.75rem;
}

.compact-ui .card-header {
    padding: 0.6rem 0.75rem;
}

.compact-ui .card-header h2 {
    font-size: 1.05rem;
}

.compact-ui .form-control,
.compact-ui .form-select {
    padding: 0.3rem 0.6rem;
    font-size: var(--font-size-sm);
}

.compact-ui .btn {
    padding: 0.3rem 0.7rem;
    font-size: var(--font-size-sm);
}

.compact-ui .form-label {
    font-size: var(--font-size-sm);
    margin-bottom: 0.3rem;
}

.compact-ui #message-container {
    max-height: 80px;
    font-size: var(--font-size-xs);
    padding: 0.5rem;
    border: 1px solid var(--color-gray-border);
    border-radius: var(--default-border-radius);
    background: var(--color-gray-light-bg);
    box-shadow: var(--default-box-shadow);
}

.compact-ui .upload-area {
    padding: 1rem;
}

.compact-ui .upload-area i {
    font-size: 32px;
}

.compact-ui .upload-area p {
    font-size: var(--font-size-sm);
}

.compact-ui .app-title {
    font-size: 1.3rem;
}

.compact-ui .coverage-option {
    padding: 0.4rem 0.6rem;
    font-size: var(--font-size-xs);
}

.compact-ui .coverage-description {
    padding: 0.75rem;
    margin-top: 1rem;
}


/* ================================================= */
/* == 8. RESPONSIVE MEDIA QUERIES                 == */
/* ================================================= */

/* Medium devices (tablets, < 992px) */
@media (max-width: 991.98px) {
    body {
        padding-top: 65px;
    }

    .app-title {
        font-size: 1.35rem;
    }

    .card-header h2 {
        font-size: 1.1rem;
    }

    .row>* {
        margin-bottom: 1rem;
    }

    /* Reduce stack margin */
}

/* Small devices (phones, < 768px) */
@media (max-width: 767.98px) {
    body {
        font-size: 0.925rem;
        padding-top: 110px;
    }

    /* Increase padding for stacked header */
    .container {
        margin-top: 1rem;
    }

    .app-header .d-flex.justify-content-between {
        flex-direction: column;
        text-align: center;
        align-items: center;
        /* <<< ADD: Centers the stacked items horizontally */
        gap: 1.25rem;
        /* <<< Optional: Adds space between the rows */
    }

    .header-controls {
        margin-top: 0;
        /* Use gap instead if added above */
        display: flex;
        /* Ensure it's flex */
        flex-direction: row;
        /* <<< IMPORTANT: Force to row */
        justify-content: space-between;
        /* Center toggle and button */
        align-items: center;
        /* Vertically align items */
        width: 100%;
        /*gap: 1rem;*/
        /* Space between toggle and button */
    }

    .app-title {
        font-size: 1.25rem;
    }

    .card-body {
        padding: 1rem;
    }

    .upload-area {
        padding: 1.25rem;
    }

    .form-switch {
        padding-left: 2.8em;
    }

    /* Adjust for smaller screens */
    .form-switch .form-check-input {
        margin-left: -2.8em;
    }
}

/* Extra small devices (< 576px) */
@media (max-width: 575.98px) {
    body {
        font-size: 0.875rem;
        padding-top: 105px;
    }

    .app-title {
        font-size: 1.15rem;
    }

    .card-header h2 {
        font-size: 1rem;
    }

    .card-body {
        padding: 0.85rem;
    }

    .upload-area {
        padding: 1rem;
    }

    .coverage-option {
        font-size: var(--font-size-xs);
    }

    .coverage-option .info-icon {
        display: none;
    }

    /* Hide tooltips on small screens */
    .coverage-description {
        padding: 0.75rem;
    }

    /*.header-controls {
            flex-direction: column;
            gap: 0.5rem;
        }*/

    /* Ensure the gap is still okay, or adjust if needed */
    .header-controls {
        gap: 0.5rem;
    }

    /* Stack header controls */
    .header-controls .form-check {
        margin-right: 0 !important;
    }
}

/* ================================================= */
/* == 9. LOGIN SCREEN STYLES                      == */
/* ================================================= */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--color-gray-page-bg);
    padding-top: 0;
    /* Remove app padding for login */
}

.login-container {
    background-color: var(--color-white);
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    width: 400px;
    max-width: 90%;
    position: relative;
    box-sizing: border-box;
}

.login-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    /* Consider changing #4db6ac to a theme color if possible */
    background: linear-gradient(90deg, var(--accent-primary), #4db6ac);
}

.login-logo {
    background-color: var(--accent-primary-lighter);
    padding: 15px 10px;
    /* reduced padding */
    text-align: center;
    border-bottom: 1px solid var(--color-gray-border);
}

.login-logo img {
    width: 60px;
    /* smaller logo */
    height: 60px;
    margin-bottom: 6px;
    /* less spacing below image */
}

.login-title {
    color: var(--accent-primary);
    font-size: 22px;
    /* slightly smaller */
    font-weight: 600;
    margin: 5px 0 0;
}

.login-subtitle {
    color: var(--color-gray-text);
    font-size: 14px;
    /* reduced size */
    margin: 2px 0 0;
    /* tighter spacing */
}

.login-form-container {
    padding: 20px;
    box-sizing: border-box;
}

.login-form-container h2 {
    color: var(--color-text-default);
    font-size: 20px;
    margin-bottom: 10px;
    text-align: center;
}

/* Wrapper for each field - ensure it takes full width */
.login-form-container .form-group {
    margin-bottom: 0.75rem;
    /* Adjust as needed for spacing between fields */
    width: 100%;
    box-sizing: border-box;
}

.login-form-container .input-group {
    box-sizing: border-box;
}

/* Icons/Text add-ons within the login page's input group */
.login-form-container .input-group .input-group-text {
    background-color: var(--accent-primary-lighter);
    flex-shrink: 0;
    /* IMPORTANT: Prevents icons from being squished */
    box-sizing: border-box;
    /* Bootstrap's .input-group-text default includes a border. This is important. */
}

.login-form-container .input-group .form-control {
    position: relative;
    flex: 1 1 auto;
    width: 1%;
    min-width: 0;
    box-sizing: border-box;
}

/* Add this NEW rule to restore the right border and radius for .form-control
   when it's the LAST element in an .input-group (e.g., Email, Department fields) */
.login-form-container .input-group>.form-control:last-child {
    border-right: 1px solid var(--color-gray-border);
    border-top-right-radius: var(--default-border-radius);
    border-bottom-right-radius: var(--default-border-radius);
}

/* Specifically for the right-hand clickable icon (e.g., question mark) */
.login-form-container .input-group .input-group-text.cursor-pointer {
    min-width: 2.5rem;
    /* Ensures enough space for the icon */
}

.login-form-container form[action="/login"] .form-group:has(input#password) {
    margin-bottom: 1.5rem !important;
    /* Example: Increased to 1.25rem. Adjust this value as needed.
    You could try 1.5rem, 1.75rem, 2rem, etc. */
}

/* 1. Reduce margin-bottom for the 'Password' field's group
to bring 'Retype Password' closer. */
.login-form-container form[action="/register"] .form-group:has(input#password) {
    margin-bottom: 1.5rem;
}

.login-form-container form[action="/register"] .form-group:has(input#confirm-password) {
    margin-bottom: 1.5rem;
    /* This will create 1.75rem space before the Register button's group */
}


.login-form-container .form-control {
    box-sizing: border-box;
    min-width: 0;
    flex: 1 1 auto;
}

.login-form-container .text-end {
    margin-top: -0.75rem;
    margin-bottom: 0.75rem;
}

.login-button {
    width: 100%;
    background-color: var(--accent-primary);
    border-color: var(--accent-primary);
    color: var(--color-white);
    font-weight: 500;
    padding: 0.5rem 1rem;
    font-size: 1rem;
    line-height: 1.5;
    border-radius: 0.25rem;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: none;
}

.login-button:hover {
    background-color: var(--accent-primary-darker);
    border-color: var(--accent-primary-darker);
}

body.login-active {
    padding-top: 0 !important;
    /* Override the default padding */
}


/* Ensure form groups don't overflow */
.login-form-container .form-group {
    margin-bottom: 1rem;
    width: 100%;
    box-sizing: border-box;
}



#password-message {
    max-width: 400px;
    display: none;
    margin-top: 5px;
    font-size: var(--font-size-sm);
    color: var(--color-danger);
}

@media (max-width: 480px) {
    .login-container {
        width: 95%;
    }

    .login-form-container {
        padding: 20px;
        /* Adjust padding as needed for smaller screens */
    }
}

/* Register/Secondary Link Button */
.register-button {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--accent-primary);
    text-decoration: none;
    font-weight: 500;
    margin: 1.5rem auto 0 auto;
    /* Top margin, auto left/right for centering */
    padding: 0.5rem 0.75rem;
    transition: color 0.15s ease-in-out;
    /* Center the link within its container */
    text-align: center;
    justify-content: center;
    width: fit-content;
    /* Only as wide as needed */
}

.register-button:hover {
    color: var(--accent-primary-darker);
    text-decoration: underline;
}

/* CSP Compliance - Minimal additions */
.upload-icon i {
    font-size: 32px !important;
    color: var(--accent-primary) !important;
}

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

.js-width-0 {
    width: 0% !important;
}

.cursor-pointer {
    cursor: pointer;
}

.d-none {
    display: none !important;
}


/* === END DEBUGGING === */

/* ================================================= */
/* == ENHANCED PROCESSING STATUS    == */
/* ================================================= */

/* Progress context - single line */
.progress-context-simple {
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--color-gray-text);
    text-align: center;
}

/* Rich Progress Context Line - Step 2 Enhancement */
.progress-context-rich {
    margin-top: 0.5rem;
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
    transition: all 0.3s ease;
    /*border-left: 2px solid transparent;*/
}

.progress-context-rich small {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
    line-height: 1.4;
}

/* SPACE EFFICIENCY: Tighter spacing between sections */
.progress-context-rich+.mb-3 {
    margin-top: 0.75rem;
    /* REDUCED from 1rem */
}

#context-icon {
    font-size: 1rem;
    flex-shrink: 0;
}

#context-text {
    flex-grow: 1;
    font-weight: 500;
}

/* Context states */
/* Context states - subtle color coding */
/*.progress-context-rich.processing {
    border-left-color: var(--accent-primary);
}

.progress-context-rich.processing small {
    color: var(--accent-primary) !important;
}*/

.progress-context-rich.processing small {
    color: var(--color-gray-text) !important;
}

/*.progress-context-rich.completed {
    border-left-color: var(--color-success);
}*/

.progress-context-rich.completed small {
    color: var(--color-success) !important;
}

/*.progress-context-rich.error {
    border-left-color: var(--color-danger);
}*/

.progress-context-rich.error small {
    color: var(--color-danger) !important;
}

/*.progress-context-rich.table-processing {
    border-left-color: #4a90e2;
}*/

.progress-context-rich.table-processing small {
    /*color: #4a90e2 !important;*/
    color: var(--color-gray-text) !important;
}

/* Better spacing after Status section removal */
.progress-context-rich+.mb-3 {
    margin-top: 1rem;
    /* Add space between context line and stats */
}

/* Mobile responsive */
@media (max-width: 767.98px) {
    .progress-context-rich {
        font-size: 0.8rem;
        padding: 0.2rem 0.4rem;
    }

    .progress-context-rich small {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.25rem;
    }
}

/* Compact UI adjustments */
.compact-ui .progress-context-rich {
    font-size: 0.75rem;
    padding: 0.3rem 0.5rem;
    margin-top: 0.3rem;
}

/* 4-column desktop, 2x2 mobile stats grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.75rem;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
    /* Added bottom margin for separation */
}

/*.stat-item {
    text-align: center;
    padding: 0.75rem 0.5rem;
    background: var(--color-gray-light-bg);
    border-radius: var(--default-border-radius);
    border: 1px solid var(--color-gray-border);
    transition: all 0.2s ease;
}*/

.stats-grid .stat-item {
    text-align: center;
    padding: 0.75rem 0.5rem;
    background: var(--color-gray-light-bg);
    border-radius: var(--default-border-radius);
    /* MATCHING BORDER STYLE */
    border: 1px solid var(--color-gray-border);
    transition: all 0.2s ease;
    /* MATCHING BOX SHADOW */
    box-shadow: var(--default-box-shadow);
}

.stat-item:hover {
    background: var(--accent-primary-lighter);
    border-color: var(--accent-primary);
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.stat-item[title] {
    cursor: help;
    transition: background-color 0.2s ease;
}

.stat-item[title]:hover {
    background-color: rgba(0, 123, 255, 0.05);
    border-radius: 4px;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--color-gray-text);
    margin-bottom: 0.25rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
}

.stat-label i {
    font-size: 0.8rem;
    color: var(--accent-primary);
}

.stat-value {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--accent-primary);
    line-height: 1.2;
    word-break: break-word;
}

/* Mobile responsive - 2x2 grid */
@media (max-width: 767.98px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.6rem;
    }

    .stat-item {
        padding: 0.6rem 0.4rem;
    }

    .stat-label {
        font-size: 0.7rem;
        gap: 0.2rem;
    }

    .stat-label i {
        font-size: 0.75rem;
    }

    .stat-value {
        font-size: 0.85rem;
    }
}

/* Extra small devices - ensure readability */
@media (max-width: 575.98px) {
    .stats-grid {
        gap: 0.5rem;
    }

    .stat-item {
        padding: 0.5rem 0.3rem;
    }

    .stat-label {
        font-size: 0.65rem;
        flex-direction: column;
        gap: 0.1rem;
    }

    .stat-label i {
        font-size: 0.8rem;
        margin-bottom: 0.1rem;
    }
}

/* Simplified message container
.message-container-simple {
    max-height: 120px;
    overflow-y: auto;
    border: 1px solid var(--color-gray-border);
    border-radius: var(--default-border-radius);
    background: var(--color-gray-light-bg);
    padding: 0;
    margin-top: 0.5rem;
}*/

.message-container-simple {
    max-height: 90px;
    overflow-y: auto;
    /* CONSISTENT BORDER: Uniform on all sides matching stats grid styling */
    border: 1px solid var(--color-gray-border);
    border-radius: var(--default-border-radius);
    background: var(--color-gray-light-bg);
    padding: 0;
    margin-top: 0.5rem;
    /* ADDED: Box shadow to match other card elements for visual consistency */
    box-shadow: var(--default-box-shadow);
    transition: border-color 0.2s ease;
}

.message-container-simple:hover {
    border-color: var(--accent-primary-border-tint);
}

/* Simple message styles - 4 types only */
/*.message {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--color-gray-border);
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    line-height: 1.4;
}*/

.message {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--color-gray-border);
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    line-height: 1.3;
    background: transparent;
    /* NEUTRAL: Clean white background for info messages */
    transition: background-color 0.15s ease;
}

.message:hover {
    background-color: rgba(var(--rgb-accent-primary), 0.03);
}

.message:last-child {
    border-bottom: none;
}

.message i {
    margin-right: 0.4rem;
    flex-shrink: 0;
    font-size: 0.8rem;
}

.message-success {
    /*background: #d4edda;*/
    background: var(--color-success-lighter);
    /*color: #155724;*/
    color: var(--color-success-darker);
    font-weight: 500;
}

.message-success:hover {
    background: #c3e6cb;
    /* Slightly darker green on hover */
}

/*
.message-info {
    background: #d1ecf1;
    color: #0c5460;
}*/

/*
.message-info i {
    color: var(--accent-primary);     /* Keep blue icons for info 
}
*/

.message-success i {
    color: #155724;
    /* Green for success */
}

.message-error i {
    color: #721c24;
    /* Red for errors */
}

.message-warning i {
    color: #856404;
    /* Yellow/orange for warnings */
}

.message-warning {
    background: #fff3cd;
    color: #856404;
}

.message-warning:hover {
    background: #ffeaa7;
    /* Slightly darker yellow on hover */
}

.message-error {
    /*background: #f8d7da;*/
    background: var(--color-danger-lighter);
    /*color: #721c24;*/
    color: var(--color-danger-darker);
    font-weight: 500;
}

.message-error:hover {
    background: #f5c6cb;
    /* Slightly darker red on hover */
}

.message-success i,
.message-error i {
    font-size: 0.85rem;
    /* Slightly larger icons for important messages */
}

/* Enhanced message container scrolling */
.message-container-simple::-webkit-scrollbar {
    width: 3px;
}

.message-container-simple::-webkit-scrollbar-track {
    background: var(--color-gray-light-bg);
}

.message-container-simple::-webkit-scrollbar-thumb {
    background: var(--color-gray-border);
    border-radius: 2px;
}

.message-container-simple::-webkit-scrollbar-thumb:hover {
    background: var(--accent-primary);
}

@media (max-width: 767.98px) {
    .message-container-simple {
        max-height: 70px;
        /* Slightly reduced for mobile */
        margin-top: 0.4rem;
    }

    .message {
        padding: 0.3rem 0.5rem;
        font-size: 0.75rem;
        line-height: 1.2;
    }

    .message-info {
        background: transparent;
        color: var(--color-text-default)
    }

    .message i {
        margin-right: 0.3rem;
        font-size: 0.75rem;
    }
}

/* Extra small devices - maintain readability while maximizing space efficiency */
@media (max-width: 575.98px) {
    .message-container-simple {
        max-height: 65px;
    }

    .message {
        padding: 0.25rem 0.4rem;
        font-size: 0.7rem;
    }

    .message i {
        margin-right: 0.25rem;
        font-size: 0.7rem;
    }
}

/* Stats loading state */
.stat-value.loading {
    color: var(--color-gray-text);
    font-style: italic;
}

.stat-value.updating {
    animation: pulse 1s ease-in-out infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

/* Enhanced form labels with icons */
.form-label i {
    color: var(--accent-primary);
    margin-right: 0.25rem;
    font-size: 0.9rem;
    /* Slightly smaller icon in labels */
}

/* Compact UI adjustments for stats */
.compact-ui .stats-grid {
    gap: 0.5rem;
}

.compact-ui .stat-item {
    padding: 0.5rem 0.3rem;
}

.compact-ui .stat-label {
    font-size: 0.7rem;
}

.compact-ui .stat-value {
    font-size: 0.8rem;
}

.compact-ui .message {
    padding: 0.3rem 0.5rem;
    /*font-size: 075rem;*/
    line-height: 1.2;
    border-bottom: 1px solid var(--color-gray-border)
}

.compact-ui .message-container-simple {
    max-height: 60px;
    font-size: var(--font-size-xs);
    padding: 0;
}

.compact-ui .message i {
    margin-right: 0.3rem;
    font-size: 0.7rem;
}

.compact-ui .message-info {
    background: transparent;
    color: var(--color-text-default);
}

.compact-ui .message:hover {
    background-color: rgba(var(--rgb-accent-primary), 0.03);
}

/* Progress context responsive improvements */
@media (max-width: 767.98px) {
    .progress-context-simple {
        font-size: 0.8rem;
        margin-top: 0.4rem;
    }
}

.alert-info {
    background-color: #e7f3fe;
    color: #084298;
    border-color: #b6d4fe;
}

/* =================================================================== */
/* == FINAL, POLISHED STYLES FOR SECTION ITEM & TABLE PREVIEW       == */
/* =================================================================== */

/* --- 1. Fix for spacing issue on the main page --- */
#upload-card-body.js-no-bottom-padding {
    padding-bottom: 0.85rem;
}

/* --- 2. Styles for the "Configure Sections" button itself --- */
#section-config-container,
#anonymization-container,
#processing-coverage-container {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
    padding-top: 0;
    padding-bottom: 0.15rem;
}

#document-type-container {
    padding-left: 0.85rem;
    padding-right: 0.85rem;
    padding-top: 0.5rem;
    padding-bottom: 0.15rem;
}

#configure-sections-btn,
#configure-document-type-btn,
#configure-anonymization-btn,
#configure-processing-coverage-btn {
    width: 100%;
    background-color: transparent;
    border: 1px solid var(--accent-primary-border-tint);
    color: var(--accent-primary);
    font-weight: 500;
    text-align: left;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    /* Restores button padding */
    border-radius: var(--default-border-radius);
    /* Restores rounded corners */
    transition: all 0.2s ease;
}

#configure-sections-btn:hover,
#configure-document-type-btn:hover,
#configure-anonymization-btn:hover,
#configure-processing-coverage-btn:hover {
    background-color: var(--accent-primary-lighter);
    border-color: var(--accent-primary);
}

#configure-sections-btn::after,
#configure-document-type-btn::after,
#configure-anonymization-btn::after,
#configure-processing-coverage-btn::after {
    content: '\F285';
    /* Bootstrap Icon for chevron-right */
    font-family: 'bootstrap-icons';
    font-weight: bold;
}


/* This adds the vertical space between each section card */
#sections-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

/* --- Content Type Badge Styling --- */
.content-type-badge {
    display: inline-block;
    padding: .25em .5em;
    font-size: .7em;
    font-weight: 600;
    line-height: 1;
    text-align: center;
    white-space: nowrap;
    vertical-align: baseline;
    border-radius: .25rem;
    color: var(--color-gray-text);
    background-color: #e9ecef;
    /* A light gray background */
}

/* Styles the individual section card */
.section-item {
    border: 1px solid var(--color-gray-border);
    border-radius: var(--default-border-radius);
    background-color: var(--color-white);
    transition: all 0.2s ease;
    box-shadow: var(--default-box-shadow);
}

.card-body-clipper {
    overflow: hidden;
    border-radius: inherit;
    /* Inherit the rounded corners from the parent */
}

.section-item.skipped {
    background-color: var(--accent-primary-lighter);
    border-left: 4px solid var(--accent-primary);
}

/* When the item is skipped, make the badge stand out more */
.section-item.skipped .content-type-badge {
    color: var(--color-white);
    background-color: var(--accent-primary);
}

.section-item .card-body {
    padding: 0.75rem 1rem;
}

/* --- Default Layout (for WIDE screens) --- */
.section-item-grid {
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto 1fr;
    gap: 0 1rem;
    align-items: baseline;
}

.section-toggle-area {
    grid-column: 1 / 2;
    grid-row: 1 / -1;
}

.section-title-area {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
}

.section-content-area {
    grid-column: 2 / 3;
    /* Fix #2: Constrains content to the second column */
    grid-row: 2 / 3;
    align-self: start;
    min-width: 0;
}


/* --- Responsive Layout (for NARROW screens) --- */
@media (max-width: 991.98px) {


    /* ADD THIS NEW RULE to fix the scrollbar on narrow screens */
    .table-preview {
        display: block;
    }

    .section-item-grid {
        grid-template-rows: auto auto;
        gap: 0.5rem 1rem;
        align-items: baseline;
    }

    .section-toggle-area {
        grid-row: 1 / 2;
        padding-top: 0;
    }

    .section-title-area {
        grid-row: 1 / 2;
    }

    .section-content-area {
        grid-row: 2 / 3;
        /* Move to the second row */
        grid-column: 1 / -1;
        /* Make it span the full width */
        min-width: 0;
    }
}


/* --- Styling for all child elements --- */
.section-item .form-check-label {
    font-weight: 600;
}

.section-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--accent-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.section-content-area .section-preview,
.section-content-area .content-summary {
    padding-left: 0;
}

.content-summary {
    font-size: var(--font-size-sm);
    color: var(--color-gray-text);
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.table-preview {
    display: inline-block;
    max-width: 100%;
    overflow-y: auto;
    max-height: 250px;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--default-border-radius);
    background-color: var(--color-gray-light-bg);
    border: 1px solid var(--color-gray-border);
    border: 1px solid var(--color-gray-border);
    border-radius: var(--default-border-radius);
    background-color: var(--color-gray-light-bg);
}

/* This class will be added by JavaScript only when needed */
.table-preview.is-overflowing {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-preview table {
    border-collapse: collapse;
}


.table-preview table {
    border-collapse: collapse;
    border: 1px solid var(--color-gray-border);
    /* The table itself gets the outer border */
}

/* The cells are now grid items */
.table-preview td {
    padding: 0.4rem 0.6rem;
    border-bottom: 1px solid var(--color-gray-border);
    border-right: 1px solid var(--color-gray-border);
    vertical-align: top;
    white-space: nowrap;
    /* This is still key to force the overflow */
}

.table-preview tr td:last-child {
    border-right: none;
    /*border-bottom: none;*/
}

/* ================================================= */
/* == FAQ PAGE STYLES                             == */
/* ================================================= */

.faq-page .card-header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.faq-page .card-header {
    transition: background-color 0.2s ease;
}

.faq-page .card-header:hover {
    background-color: var(--accent-primary-lighter);
}

/* FAQ specific list formatting */
.faq-answer ul,
.faq-answer ol {
    margin: 1rem 0 1.5rem 0;
    padding-left: 1.5rem;
    line-height: 1.7;
}

.faq-answer li {
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

.faq-answer li:last-child {
    margin-bottom: 0.5rem;
}

/* FAQ section card body list formatting */
.faq-section .card-body ul,
.faq-section .card-body ol {
    margin: 1rem 0 1.5rem 0;
    padding-left: 1.5rem;
    line-height: 1.7;
}

.faq-section .card-body li {
    margin-bottom: 0.75rem;
    line-height: 1.6;
}

.faq-section .card-body li:last-child {
    margin-bottom: 0.5rem;
}

/* FAQ nested lists */
.faq-answer ul ul,
.faq-answer ol ol,
.faq-answer ul ol,
.faq-answer ol ul {
    margin: 0.25rem 0;
    padding-left: 1.2rem;
}

/* FAQ question styling */
.faq-section .fw-bold {
    font-size: 1.05rem;
    line-height: 1.4;
}

/* FAQ answer text formatting */
.faq-answer {
    line-height: 1.6;
    color: var(--color-text-default);
}

/* Spacing between paragraphs and lists */
.faq-answer p+ul,
.faq-answer p+ol {
    margin-top: 0.2rem;
}

/* Group introductory text tightly with following lists */
.faq-answer p:has(+ ul),
.faq-answer p:has(+ ol) {
    margin-bottom: 0.4rem;
}

/* For browsers that don't support :has(), use adjacent sibling combinator */
.faq-answer ul+p,
.faq-answer ol+p {
    margin-top: 1rem;
    /* Retaining the latest value from original CSS (was 0.25rem then 1rem) */
}

/* Better spacing between Q&A pairs */
.faq-section .mb-4 {
    margin-bottom: 2rem !important;
}

.faq-section .mb-4:last-child {
    margin-bottom: 1rem !important;
}

/* Override Bootstrap mb-2 class for questions */
.faq-section .card-body .fw-bold.text-primary.mb-2 {
    margin-bottom: 1.6rem !important;
}

/* FAQ strong/bold text in lists */
.faq-answer strong,
.faq-section .card-body strong {
    color: var(--accent-primary);
    font-weight: 600;
}

/* FAQ collapse icon animation */
.collapse-icon {
    transition: transform 0.3s ease;
}

/* Enhanced spacing for strong/bold elements in lists */
.faq-answer li strong,
.faq-section .card-body li strong {
    display: inline-block;
    margin-bottom: 0.25rem;
}

/* FAQ paragraph spacing - Updated for better grouping */
.faq-answer p {
    margin-bottom: 0.8rem;
    line-height: 1.7;
}

.faq-answer p:last-child {
    margin-bottom: 0;
}

/* Tighter spacing for introductory paragraphs */
.faq-answer p:first-child {
    margin-bottom: 0.4rem;
}

/* Even tighter for first paragraph followed by lists */
.faq-answer p:first-child+ul,
.faq-answer p:first-child+ol {
    margin-top: 0.1rem;
}

/* Tighter spacing between question and answer */
.faq-section .fw-bold.text-primary {
    margin-bottom: 0.85rem;
}

/* Handle category subheadings within answers (like "Fully Supported:", "Limitations:") */
.faq-answer p strong:only-child,
.faq-answer p:has(strong:only-child) {
    margin-bottom: 0.3rem;
}

/* Keep category headers close to their lists */
.faq-answer p:contains("Supported:")+ul,
.faq-answer p:contains("Limitations:")+ul,
.faq-answer p:contains("Footnotes:")+ul,
.faq-answer p:contains("Reinsertion:")+ul,
.faq-answer p:contains("Required:")+ul,
.faq-answer p:contains("Development:")+ul {
    margin-top: 0.15rem;
}

/* Alternative approach for category headers */
.faq-answer strong:contains(":") {
    display: block;
    margin-bottom: 0.2rem;
    margin-top: 0.6rem;
}

.faq-answer strong:contains(":"):first-child {
    margin-top: 0;
}

/* Style category headers within answers */
.faq-answer p:has(strong:contains("Fully Supported")),
.faq-answer p:has(strong:contains("Limitations")),
.faq-answer p:has(strong:contains("Hyperlinks")),
.faq-answer p:has(strong:contains("Failed")),
.faq-answer p:has(strong:contains("User Action")),
.faq-answer p:has(strong:contains("Future")) {
    margin-bottom: 0.25rem;
    margin-top: 0.75rem;
}

/* First category header shouldn't have top margin */
.faq-answer p:first-of-type:has(strong:contains("Fully Supported")) {
    margin-top: 0;
}

/* FAQ search highlighting (if you add highlighting later) */
/* FAQ search highlighting */
.faq-highlight {
    background-color: #fff3cd;
    color: #856404;
    padding: 0.1rem 0.3rem;
    border-radius: 4px;
    font-weight: 500;
    border: 1px solid #ffeaa7;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
    transition: all 0.2s ease;
}

.faq-highlight:hover {
    background-color: #ffeaa7;
    transform: translateY(-1px);
}

/* Multiple highlights in same element */
.faq-answer .faq-highlight+.faq-highlight {
    margin-left: 0.1rem;
}

/* FAQ no results styling */
#no-results .card-body {
    padding: 3rem 2rem;
}

/* Enhanced mobile responsive adjustments for FAQ */
@media (max-width: 767.98px) {

    .faq-answer ul,
    .faq-answer ol,
    .faq-section .card-body ul,
    .faq-section .card-body ol {
        padding-left: 1.2rem;
        margin: 0.75rem 0 1.25rem 0;
    }

    .faq-answer li,
    .faq-section .card-body li {
        margin-bottom: 0.6rem;
    }

    /* Mobile paragraph spacing - matches desktop relationships */
    .faq-answer p {
        margin-bottom: 1rem;
        line-height: 1.6;
    }

    .faq-answer p:first-child {
        margin-bottom: 0.3rem;
    }

    /* Mobile paragraph-to-list spacing */
    .faq-answer p+ul,
    .faq-answer p+ol {
        margin-top: 0.2rem;
    }

    .faq-answer p:first-child+ul,
    .faq-answer p:first-child+ol {
        margin-top: 0.15rem;
    }

    /* Mobile question-to-answer spacing */
    .faq-section .fw-bold.text-primary {
        font-size: 1rem;
        margin-bottom: 0.7rem;
    }

    .faq-section .mb-4 {
        margin-bottom: 1.5rem !important;
    }

    /* Mobile category header spacing */
    .faq-answer p:has(strong:contains("Supported")),
    .faq-answer p:has(strong:contains("Limitations")) {
        margin-bottom: 0.2rem;
        margin-top: 0.6rem;
    }

    .faq-section .card-body .fw-bold.text-primary.mb-2 {
        margin-bottom: 1.2rem !important;
    }
}

/***************************************/
/* Document Context Section Styling */
/**************************************/
.document-context-section {
    background-color: var(--color-gray-light-bg);
    border: 1px solid var(--color-gray-border);
    border-radius: var(--default-border-radius);
    padding: 1rem;
}

.document-context-section h6 {
    color: var(--accent-primary);
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.document-context-section .form-label {
    font-weight: 500;
    color: var(--color-text-default);
}

.document-context-section .form-text {
    font-size: 0.8rem;
    color: var(--color-gray-text);
}

.context-preview-container .alert {
    border-left: 4px solid var(--accent-primary);
    background-color: var(--accent-primary-lighter);
    border-color: var(--accent-primary-border-tint);
}

.context-preview-container .alert i {
    color: var(--accent-primary);
}

/* Character counter styling */
#domain-char-count {
    font-weight: 500;
}

#domain-char-count.warning {
    color: var(--color-danger);
}

/* Tooltip styling for info icons */
.form-label .bi-info-circle {
    font-size: 0.9rem;
    color: var(--color-gray-text);
    cursor: help;
}

.form-label .bi-info-circle:hover {
    color: var(--accent-primary);
}

/***************************************/
/* Modal Styling */
/**************************************/

/* Modal headers should match card headers - blue background and text */
#documentTypeModal .modal-header,
#sectionConfigModal .modal-header,
#anonymizationModal .modal-header,
#processingCoverageModal .modal-header {
    background-color: var(--accent-primary-lighter);
    border-bottom: 1px solid var(--color-gray-border);
    color: var(--accent-primary);
}

#documentTypeModal .modal-title,
#sectionConfigModal .modal-title,
#anonymizationModal .modal-title,
#processingCoverageModal .modal-title {
    color: var(--accent-primary);
    font-weight: 600;
}

/* Ensure modal title icons also have blue color */
#documentTypeModal .modal-title i,
#sectionConfigModal .modal-title i,
#anonymizationModal .modal-title i,
#processingCoverageModal i {
    color: var(--accent-primary);
}

/* Modal card headers should match main page cards */
#documentTypeModal .card-header {
    background-color: var(--accent-primary-lighter);
    border-bottom: 1px solid var(--color-gray-border);
    color: var(--accent-primary);
}

#documentTypeModal .card-header h2 {
    color: var(--accent-primary);
    margin: 0;
    font-size: 1.05rem;
}

/* Ensure modal cards match main page styling */
#documentTypeModal .card {
    border: 1px solid var(--color-gray-border);
    box-shadow: var(--default-box-shadow);
    background-color: var(--color-gray-card-bg);
}

/* Scrolling for protected words container in modal */
#anonymizationModal #word-container {
    max-height: 150px;
    overflow-y: auto;
    word-wrap: break-word;
    word-break: break-word;
}

/* Add styling only when container has words */
#anonymizationModal #word-container:not(:empty) {
    border: 1px solid var(--color-gray-border);
    border-radius: var(--default-border-radius);
    padding: 0.5rem;
    background-color: var(--color-gray-light-bg);
    margin-top: 0.5rem;
}

/* Ensure modal body itself can scroll if needed */
#anonymizationModal .modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

/* Enhanced modal centering and positioning */
.modal-dialog-centered {
    min-height: calc(100vh - 3rem);
}

.modal-dialog-centered .modal-content {
    max-height: calc(100vh - 6rem);
    overflow-y: auto;
}

/* Ensure modals work well on small screens */
@media (max-width: 576px) {
    .modal-dialog-centered {
        min-height: calc(100vh - 1rem);
        margin: 0.5rem;
    }

    .modal-dialog-centered .modal-content {
        max-height: calc(100vh - 1rem);
    }
}

/* Processing Coverage Modal - specific styling */
#processingCoverageModal .coverage-slider {
    display: flex;
    background: var(--color-gray-light-bg);
    border-radius: 18px;
    padding: 3px;
    border: 1px solid var(--color-gray-border);
    margin-bottom: 1rem;
}

#processingCoverageModal .coverage-option {
    flex: 1;
    padding: 0.6rem 0.75rem;
    text-align: center;
    cursor: pointer;
    border-radius: 15px;
    transition: all 0.2s ease;
    background: transparent;
    border: none;
    font-weight: 500;
    color: var(--color-gray-text);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

#processingCoverageModal .coverage-option.active {
    background: var(--accent-primary);
    color: var(--color-white);
    box-shadow: 0 2px 4px rgba(var(--rgb-accent-primary), 0.3);
}

#processingCoverageModal .coverage-option:hover:not(.active) {
    background: var(--accent-primary-lighter);
    color: var(--accent-primary);
}

#processingCoverageModal .coverage-description {
    padding: 0.5rem;
    background: var(--accent-primary-lighter);
    border-radius: var(--default-border-radius);
    border-left: 4px solid var(--accent-primary);
    margin-top: 1rem;
}

/* Consistent spacing for all modal button containers */
#modal-buttons-container .mb-3 {
    margin-bottom: 0.75rem !important;
}

/* Ensure hidden config-status divs don't affect spacing */
.config-status.d-none {
    display: none !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* ================================================= */
/* == 10. USER PROFILE PAGE                       == */
/* ================================================= */

/* Custom Page Background */
body.profile-page {
    background-color: #f4f6f9;
}

.profile-card {
    border: none;
    border-radius: 12px;
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.08);
    overflow: hidden;
    background-color: var(--color-white);
}

.profile-card-header {
    background: linear-gradient(45deg, var(--accent-primary), var(--accent-primary-darker));
    color: var(--color-white);
    /* CHANGE: Reduced vertical padding from 1.5rem to 1rem */
    padding: 1rem 1.5rem;
    font-weight: 500;
}

.profile-section-title {
    color: #495057;
    font-weight: 600;
    font-size: 1.1rem;
    margin-bottom: 1.25rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid #e9ecef;
}

.detail-label {
    font-weight: 500;
    color: var(--color-gray-text);
}

.detail-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-text-default);
}

.api-key-box {
    background-color: #e7f1ff;
    border: 1px solid #b6d4fe;
    border-radius: var(--default-border-radius);
    padding: 1.5rem;
}

.api-key-input {
    font-family: 'Roboto Mono', monospace, Courier New;
    font-size: 1.1rem;
    background-color: #ffffff !important;
    color: #0a58ca;
    border-color: #b6d4fe;
    letter-spacing: 1px;
}

.btn-generate {
    padding: 0.75rem 1.5rem;
    font-weight: 500;
    font-size: 1.05rem;
}

/* Mobile Optimizations for Profile */
@media (max-width: 767.98px) {
    .profile-card-header {
        padding: 1rem;
        font-size: 1.25rem;
    }

    .profile-card .card-body {
        padding: 1.25rem;
    }

    .detail-row {
        display: flex;
        flex-direction: column;
        gap: 0.25rem;
        margin-bottom: 1rem;
    }

    .detail-value {
        font-size: 1.2rem;
    }

    .btn-generate {
        width: 100%;
    }
}

/* ================================================= */
/* == AUDIT LOGS - DUAL-LAYER BADGE SYSTEM        == */
/* ================================================= */

/* Category Badge Colors (Neutral/Distinct) */
.badge.badge-auth,
span.badge-auth {
    background-color: #d3d3d3 !important;
    /* Very light gray for auth */
    color: #212529 !important;
}

.badge.badge-key,
span.badge-key {
    background-color: #fd7e14 !important;
    /* Orange for keys */
    color: #ffffff !important;
}

.badge.badge-security,
span.badge-security {
    background-color: #ffc107 !important;
    /* Yellow for security */
    color: #000000 !important;
}

.badge.badge-admin,
span.badge-admin {
    background-color: #C535BC !important;
    /* Bosch Purple 50 for admin */
    color: #ffffff !important;
}

/* Status Border Indicators */
.badge.badge-success-border,
span.badge-success-border {
    border-left: 6px solid #198754 !important;
    /* Green border for success */
    padding-left: 0.5em !important;
}

.badge.badge-failure-border,
span.badge-failure-border {
    border-left: 6px solid #dc3545 !important;
    /* Red border for failure */
    padding-left: 0.5em !important;
}

/* Legacy purple badge support */
.bg-purple {
    background-color: #C535BC !important;
    color: #ffffff !important;
}