/* ==========================================================================
   Utility Classes & Error Styling
   ========================================================================== */

/* ---- Error Detection & Flagging ---- */
.flagged-error {
    position: relative;
    cursor: help;
    transition: var(--transition-fast);
    text-decoration: underline;
    text-decoration-color: var(--error-high);
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
    background-color: rgba(244, 67, 54, 0.6);
    padding: 2px 4px;
    border-radius: var(--border-radius-sm);
    color: inherit;
    font-weight: 500;
}

.flagged-error:hover {
    background-color: rgba(244, 67, 54, 0.8);
    text-decoration-color: var(--error-critical);
    text-decoration-thickness: 3px;
    box-shadow: 0 0 0 1px rgba(244, 67, 54, 0.3);
}

/* ---- Error Severity Variants ---- */
.flagged-error.low {
    text-decoration-color: #f57c00;
    background-color: rgba(245, 124, 0, 0.6);
}

.flagged-error.low:hover {
    background-color: rgba(245, 124, 0, 0.8);
    text-decoration-color: #e65100;
    box-shadow: 0 0 0 1px rgba(245, 124, 0, 0.3);
}

.flagged-error.medium {
    text-decoration-color: #e64a19;
    background-color: rgba(230, 74, 25, 0.6);
}

.flagged-error.medium:hover {
    background-color: rgba(230, 74, 25, 0.8);
    text-decoration-color: #d84315;
    box-shadow: 0 0 0 1px rgba(230, 74, 25, 0.3);
}

.flagged-error.high {
    text-decoration-color: var(--error-high);
    background-color: rgba(244, 67, 54, 0.6);
}

.flagged-error.high:hover {
    background-color: rgba(244, 67, 54, 0.8);
    text-decoration-color: var(--error-critical);
    box-shadow: 0 0 0 1px rgba(244, 67, 54, 0.3);
}

.flagged-error.critical {
    text-decoration-color: #c62828;
    background-color: rgba(198, 40, 40, 0.7);
    text-decoration-thickness: 3px;
    font-weight: 600;
}

.flagged-error.critical:hover {
    background-color: rgba(198, 40, 40, 0.9);
    text-decoration-color: var(--error-critical);
    text-decoration-thickness: 4px;
    box-shadow: 0 0 0 2px rgba(198, 40, 40, 0.4);
}

/* ---- Inline Editing Override ---- */
.inline-edit-form .flagged-error {
    background: transparent;
    text-decoration: none;
    box-shadow: none;
}

/* ---- Table Utilities ---- */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-striped tbody tr:nth-of-type(odd) {
    background-color: var(--surface-secondary);
}

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

/* ---- Status Indicators ---- */
.status-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--text-muted);
}

.status-indicator.active {
    background-color: var(--success-green);
    animation: pulse 2s infinite;
}

.status-indicator.paused {
    background-color: var(--error-medium);
}



.status-indicator.generating {
    background-color: var(--secondary-green);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

/* ---- Loading States ---- */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

.spinner {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ---- Loading Content & Indicators ---- */
.loading-indicator {
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.loading-indicator:before {
    content: '';
    display: inline-block;
    width: 0.75rem;
    height: 0.75rem;
    border: 2px solid var(--text-muted);
    border-top: 2px solid var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-lg);
    padding: var(--spacing-xl);
    text-align: center;
    color: var(--text-secondary);
}

.loading-spinner {
    width: 2rem;
    height: 2rem;
    border: 3px solid var(--text-muted);
    border-top: 3px solid var(--accent-blue);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-content p {
    margin: 0;
    font-size: 0.875rem;
    color: var(--text-secondary);
    font-weight: 500;
    line-height: 1.6;
    font-family: var(--font-family-primary);
}

/* ---- Button Utilities ---- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--border-radius-sm);
    border: 1px solid transparent;
    padding: 0.5rem 1rem;
    cursor: pointer;
    transition: var(--transition-normal);
    text-align: center;
    outline: none;
    text-decoration: none;
    background: transparent;
    color: inherit;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---- Template/Macro Context Button Overrides ---- */
.templates-container .btn-primary {
    background: var(--success-green);
    border-color: var(--success-green);
    color: white;
    font-weight: 500;
}

.templates-container .btn-primary:hover:not(:disabled) {
    background: var(--success-green-hover);
    border-color: var(--success-green-hover);
    color: white;
}

/* ---- Refined Add Button (Templates & Macros) ---- */
.btn-add-template {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    font-weight: 500;
    transition: all 0.15s ease;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    border-radius: var(--border-radius-sm);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

.btn-add-template:hover:not(:disabled) {
    background: var(--accent-blue);
    color: white;
    border-color: var(--accent-blue);
    box-shadow: 0 4px 12px rgba(90, 124, 138, 0.15);
}

.btn-add-template:active:not(:disabled) {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.btn-add-template .oi {
    font-size: 0.875rem;
    transition: transform 0.15s ease;
}

.btn-add-template:hover .oi {
    transform: scale(1.1);
}

.btn-transparent {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    background: transparent;
    color: var(--text-secondary);
    font-weight: 400;
    padding: 0.5rem 0.75rem;
    border: none;
    cursor: pointer;
    border-radius: var(--border-radius-sm);
    transition: var(--transition-normal);
    text-align: center;
    outline: none;
    font-family: inherit;
    font-size: 0.875rem;
    text-decoration: none;
    position: relative;
    z-index: 1;
    pointer-events: auto;
}

.btn-transparent:hover {
    background: var(--surface-hover);
    color: var(--text-primary);
    transform: none;
}

.btn-transparent.active {
    background: var(--surface-hover);
    color: var(--text-primary);
}

/* ---- Debug: Ensure Template/Macro buttons are visible and clickable ---- */
button[class*="btn-transparent"] {
    pointer-events: auto !important;
    cursor: pointer !important;
    position: relative !important;
    z-index: 10 !important;
}

/* ---- Specific fix for Template and Macro buttons ---- */
.controls-right .btn-transparent {
    min-width: auto;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.controls-right .btn-transparent:last-child {
    margin-right: var(--spacing-lg);
}

.btn-transparent.invisible {
    visibility: hidden;
    pointer-events: none;
}

/* ---- Templates & Macros Overlay ---- */
/* Z-index scale: Base (1-10), Dropdowns (100-200), Overlays (1000-2000), Modals (2000-3000) */
.templates-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: var(--bg-primary);
    z-index: 1500;
    opacity: 0;
    visibility: hidden;
    display: flex;
    flex-direction: column;
    height: 100vh; /* Ensure full viewport height */
    transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out;
}

.templates-overlay.open { 
    opacity: 1; 
    visibility: visible; 
}

/* ---- Template Component Styles ---- */
.templates-content {
    flex: 1;
    min-height: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Constrain content to enable scrolling in children */
}

.templates-container {
    display: flex; 
    flex-direction: column;
    flex: 1;
    height: 100%;
    background: var(--bg-primary);
    color: var(--text-primary);
}

.templates-header {
    background: var(--bg-secondary);
    padding: var(--spacing-xl) 1.5rem;
    border-bottom: 1px solid var(--border-container);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 80px;
    gap: 1.5rem;
    flex-shrink: 0; /* Prevent header from shrinking */
}

.templates-header-left {
    display: flex;
    align-items: center;
    gap: 2rem;
    flex: 1;
}

.templates-title { 
    display: flex; 
    align-items: center; 
    gap: 0.75rem;
}

.templates-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    background: var(--accent-blue);
    color: white;
    border-radius: 8px;
    font-size: 1.25rem;
}

.templates-icon .oi {
    font-size: 1.25rem;
}

.templates-title-content {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.templates-title h2 { 
    font-size: 1.125rem; 
    font-weight: 600; 
    margin: 0; 
    letter-spacing: -0.01em; 
    color: var(--text-primary);
}

.templates-subtitle {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.templates-stats {
    display: flex;
    align-items: center;
    gap: 1.5rem;
    padding-left: 1rem;
    border-left: 1px solid var(--border-color);
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
}

.stat-label {
    color: var(--text-secondary);
    font-weight: 500;
}

.stat-value {
    color: var(--text-primary);
    font-weight: 600;
    background: var(--bg-tertiary);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    min-width: 2rem;
    text-align: center;
}

.templates-controls { 
    display: flex; 
    align-items: center; 
    gap: 1.5rem; 
    flex-shrink: 0; 
}

.templates-actions { 
    display: flex; 
    align-items: center; 
    gap: 1rem; 
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
}

/* Stack Add and Import buttons vertically on smaller screens */
@media (max-width: 900px) {
    .templates-actions {
        flex-direction: column;
        align-items: stretch;
        width: 100%;
    }
    
    .templates-actions .btn-add-template {
        width: 100%;
        justify-content: center;
    }
    
    .templates-actions .search-container {
        width: 100%;
    }
    
    .templates-actions .search-container .search-input {
        width: 100%;
        min-width: 0;
    }
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
}

.search-icon {
    position: absolute;
    left: 0.75rem;
    color: var(--text-secondary);
    font-size: 0.875rem;
    pointer-events: none;
    z-index: 1;
}

.search-container .search-input {
    padding-left: 2.5rem;
    min-width: 280px;
}

.close-templates-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.25rem;
    height: 2.25rem;
    background: var(--bg-tertiary);
    border: none;
    border-radius: 6px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, box-shadow 0.15s;
    margin-left: 0.75rem;
    font-size: 1.25rem;
    outline: none;
}

.close-templates-btn:hover,
.close-templates-btn:focus {
    background: var(--surface-hover);
    color: var(--accent-blue);
    box-shadow: 0 2px 8px rgba(90, 124, 138, 0.08);
}

.close-templates-btn:active {
    background: var(--surface-hover);
    color: var(--accent-blue);
    box-shadow: 0 1px 4px rgba(90, 124, 138, 0.12);
}

.templates-layout { 
    display: flex; 
    flex: 1;
    height: 100%;
    min-height: 0; /* Ensure flex children can shrink */
    overflow: hidden; /* Prevent content from overflowing */
}

.templates-list-panel {
    width: 32%; 
    border-right: 1px solid var(--border-color);
    display: flex; 
    flex-direction: column; 
    background: var(--bg-secondary);
    height: 100%;
    max-height: 100vh; /* Explicit viewport height constraint */
    min-height: 0; /* Allow flex shrinking */
    overflow: hidden; /* Constrain content */
}

.templates-details-panel {
    width: 68%; 
    padding: 1.25rem; 
    background: var(--bg-primary);
    overflow-y: auto; 
    display: flex; 
    flex-direction: column; 
    height: 100%;
}

.category-filter {
    display: flex; 
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    padding: 0.75rem 1rem;
    gap: 0.5rem;
    flex-shrink: 0; /* Prevent compression */
}

.category-btn {
    background: transparent; 
    color: var(--text-secondary);
    padding: 0.5rem 1rem; 
    border: none;
    border-radius: var(--border-radius-md);
    text-align: center; 
    font-size: 0.8125rem; 
    font-weight: 500;
    transition: all 0.2s ease; 
    cursor: pointer; 
    position: relative;
    outline: none;
    white-space: nowrap;
    flex: 1; /* Make buttons fill width evenly */
    min-width: 0; /* Allow flex shrinking */
}

.category-btn:hover { 
    color: var(--text-primary); 
    background: var(--surface-hover);
}

.category-btn.active { 
    color: var(--accent-blue); 
    background: var(--bg-secondary);
    font-weight: 600;
}

.items-list { 
    flex: 1; 
    overflow-y: auto !important; 
    overflow-x: hidden;
    padding: 0; 
    min-height: 0; /* Allow flex shrinking */
    max-height: calc(100vh - 200px); /* Force height constraint for scrolling */
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on mobile */
    scrollbar-width: none; /* Firefox - hide scrollbar */
    -ms-overflow-style: none; /* IE and Edge - hide scrollbar */
}

/* Hide scrollbar for items-list (WebKit browsers) */
.items-list::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

.list-item {
    padding: 0.75rem 1.25rem; 
    border-bottom: 1px solid var(--border-color);
    cursor: pointer; 
    transition: all 0.15s ease; 
    background: var(--bg-secondary);
    position: relative;
}

.list-item:hover { 
    background: var(--surface-hover); 
    transform: translateX(2px);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.list-item.selected { 
    background: var(--accent-blue); 
    color: white; 
    box-shadow: 0 2px 8px rgba(90, 124, 138, 0.3);
}

.list-item.selected::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent-blue);
}

.list-item.selected .list-item-category,
.list-item.selected .list-item-preview,
.list-item.selected .list-item-description {
    color: rgba(255, 255, 255, 0.85);
}

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

.list-item-header h4 { 
    margin: 0; 
    font-size: 0.875rem; 
    font-weight: 500; 
    line-height: 1.3; 
    flex: 1; 
    letter-spacing: -0.01em; 
}

.list-item-category {
    font-size: 0.75rem; 
    color: var(--text-secondary); 
    background: var(--bg-tertiary);
    padding: 0.25rem 0.5rem; 
    border-radius: 12px; 
    font-weight: 500;
    white-space: nowrap; 
    margin-left: 0.5rem;
}

.list-item-preview, .list-item-description {
    font-size: 0.8rem; 
    color: var(--text-secondary); 
    line-height: 1.4;
    display: -webkit-box; 
    -webkit-line-clamp: 2; 
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.details-header {
    display: flex; 
    justify-content: space-between; 
    align-items: center;
    margin-bottom: 1.5rem; 
    padding: 1rem 1.5rem; 
    background: linear-gradient(135deg, var(--bg-secondary) 0%, var(--bg-tertiary) 100%);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), 0 1px 3px rgba(0, 0, 0, 0.12);
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
    height: 72px; /* Fixed height to prevent layout shift between modes */
    box-sizing: border-box;
}

.details-header:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.16);
}

.details-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--accent-blue) 0%, var(--accent-blue-hover) 100%);
    border-radius: 12px 12px 0 0;
}

.details-header h3 { 
    margin: 0; 
    font-size: 1rem; 
    font-weight: 600; 
    letter-spacing: -0.02em;
    color: var(--text-primary);
    line-height: 1.3;
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    height: 40px; /* Fixed height to match editing-header content */
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 0 0 auto;
}

.exam-code-badge {
    display: inline-flex;
    align-items: center;
    height: 40px; /* Match h3 height */
    padding: 0 0.5rem;
    font-size: 0.75rem;
    color: var(--text-secondary);
    opacity: 0.8;
}

.details-header h3::before {
    content: '📄';
    font-size: 1.1rem;
    opacity: 0.8;
}

.details-actions { 
    display: flex; 
    gap: 0.5rem; 
    align-items: center;
    position: relative;
    z-index: 1;
    height: 40px; /* Fixed height to match editing-header */
}

.details-content { 
    display: flex; 
    flex-direction: column; 
    height: 100%; 
    overflow-y: auto; 
    flex: 1; 
    min-height: 0;
    scrollbar-width: none; /* Firefox - hide scrollbar */
    -ms-overflow-style: none; /* IE and Edge - hide scrollbar */
}

/* Hide scrollbar for details-content (WebKit browsers) */
.details-content::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

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

/* Reduce vertical margin for exam code field */
.detail-group.exam-code-field {
    margin-bottom: 0.5rem;
    margin-top: 0;
}

/* Exam, Scope, and Exam Code in a single row */
.exam-scope-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
    align-items: flex-end; /* Align inputs/selects at the bottom */
}

.exam-scope-row .detail-group {
    flex: 1;
    margin-bottom: 0;
    min-width: 0; /* Allow flex shrinking */
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

/* Ensure inputs and selects in exam-scope-row have consistent styling */
.exam-scope-row .edit-exam-code-input,
.exam-scope-row .edit-category-select {
    width: 100%;
    height: 2.5rem; /* Consistent height */
    padding: 0.5rem 0.75rem;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 0.875rem;
    color: var(--text-primary);
    outline: none;
    transition: var(--transition-fast);
    box-sizing: border-box;
    margin-left: 0 !important; /* Override margin-left: auto from edit-category-select */
}

.exam-scope-row .edit-category-select {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23aeaeb2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
}

.exam-scope-row .edit-exam-code-input:focus,
.exam-scope-row .edit-category-select:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--form-focus-shadow);
}

.exam-scope-row .edit-category-select:hover {
    border-color: var(--border-hover);
}

.detail-group label {
    font-size: 0.8rem; 
    font-weight: 600; 
    color: var(--text-secondary);
    text-transform: uppercase; 
    letter-spacing: 0.5px;
}

.detail-group span { 
    font-size: 0.9rem; 
    line-height: 1.4; 
}

.content-detail-group {
    display: flex;
    flex-direction: column;
    height: 100%;
    flex: 1;
    min-height: 0;
    gap: 1rem;
}

.content-preview {
    font-size: 0.9rem; 
    line-height: 1.6; 
    background: var(--bg-primary);
    padding: 1.5rem; 
    border-radius: 8px; 
    border: 1px solid var(--border-color);
    overflow-y: auto; 
    white-space: pre-wrap; 
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    font-weight: 400; 
    letter-spacing: -0.01em;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08), inset 0 1px 2px rgba(0, 0, 0, 0.05);
    flex: 1;
    min-height: 200px;
    max-height: calc(100vh - 300px);
    height: auto;
}

/* Fix HTML content spacing in content preview */
.content-preview p {
    margin: 0 0 1rem 0;
    display: block;
}

.content-preview p:last-child {
    margin-bottom: 0;
}

.content-preview br {
    display: block;
    margin: 0.5rem 0;
    content: "";
}

.search-input {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    outline: none;
    transition: var(--transition-fast);
}

.search-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px rgba(90, 124, 138, 0.1);
}

.search-input::placeholder {
    color: var(--text-secondary);
}

/* ---- Edit Form Elements ---- */
.editing-header {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    width: 100%;
    height: 40px; /* Fixed height to match h3 in viewing mode */
    flex: 1;
}

.templates-header-right-text {
    display: flex;
    align-items: center;
    height: 40px; /* Match the height of editing-header */
    min-width: 0;
}

.editing-actions {
    display: flex;
    gap: var(--spacing-sm);
    align-items: center;
}

.edit-name-input {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    outline: none;
    transition: var(--transition-fast);
    max-width: 300px;
    flex: 0 0 auto;
    height: 36px; /* Fixed height for consistency */
    box-sizing: border-box;
}

.edit-name-input:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--form-focus-shadow);
}

.edit-name-input::placeholder {
    color: var(--text-placeholder);
}

.edit-category-select {
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text-primary);
    outline: none;
    transition: var(--transition-fast);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23aeaeb2' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    background-size: 1rem;
    padding-right: 2.5rem;
    min-width: 150px;
    flex: 0 0 auto;
    margin-left: auto; /* Push to the right side */
    height: 36px; /* Fixed height to match edit-name-input */
    box-sizing: border-box;
}

.edit-category-select:focus {
    border-color: var(--accent-blue);
    box-shadow: 0 0 0 3px var(--form-focus-shadow);
}

.edit-category-select:hover {
    border-color: var(--border-hover);
}

.edit-category-select option {
    background: var(--bg-secondary);
    color: var(--text-primary);
    padding: 0.5rem;
}

.templates-header-right-text {
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-left: auto; /* Push to the right */
    white-space: nowrap;
}

/* ---- Empty State Styling ---- */
.empty-state {
    display: flex; 
    flex-direction: column; 
    align-items: center;
    justify-content: center; 
    height: 100%; 
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

.empty-state-icon { 
    font-size: 3rem; 
    margin-bottom: 1.5rem; 
    opacity: 0.4;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.2s ease;
}

.empty-state-icon .oi {
    font-size: 3rem;
    color: var(--text-secondary);
}

.empty-state:hover .empty-state-icon {
    opacity: 0.6;
}

.empty-state h3 { 
    margin: 0 0 0.75rem 0; 
    font-size: 1.1rem; 
    font-weight: 600; 
    color: var(--text-primary); 
}

.empty-state p { 
    margin: 0; 
    font-size: 0.9rem; 
    line-height: 1.5; 
    max-width: 300px; 
    color: var(--text-secondary);
}

/* ---- Text Utilities ---- */
.text-muted {
    color: var(--text-muted);
}

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

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

.text-error {
    color: var(--error-high);
}

.text-success {
    color: var(--success-green);
}

/* ---- Spacing Utilities ---- */
.gap-sm { gap: var(--spacing-sm); }
.gap-md { gap: var(--spacing-md); }
.gap-lg { gap: var(--spacing-lg); }
.gap-xl { gap: var(--spacing-xl); }

.m-0 { margin: 0; }
.mt-1 { margin-top: var(--spacing-sm); }
.mb-1 { margin-bottom: var(--spacing-sm); }
.mx-auto { margin-left: auto; margin-right: auto; }

.p-0 { padding: 0; }
.p-1 { padding: var(--spacing-sm); }
.p-2 { padding: var(--spacing-md); }
.p-3 { padding: var(--spacing-lg); }

/* ---- Display Utilities ---- */
.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-grid { display: grid; }

.flex-column { flex-direction: column; }
.flex-row { flex-direction: row; }
.justify-content-center { justify-content: center; }
.justify-content-between { justify-content: space-between; }
.align-items-center { align-items: center; }
.align-items-start { align-items: flex-start; }
.margin-center {margin: 0 auto;}

/* ---- Position Utilities ---- */
.position-relative { position: relative; }
.position-absolute { position: absolute; }
.position-fixed { position: fixed; }
.position-sticky { position: sticky; }

/* ---- Overflow Utilities ---- */
.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }
.overflow-x-auto { overflow-x: auto; }
.overflow-y-auto { overflow-y: auto; }

/* ---- Border Utilities ---- */
.border { border: 1px solid var(--border-color); }
.border-top { border-top: 1px solid var(--border-color); }
.border-bottom { border-bottom: 1px solid var(--border-color); }
.border-left { border-left: 1px solid var(--border-color); }
.border-right { border-right: 1px solid var(--border-color); }

.rounded { border-radius: var(--border-radius-md); }
.rounded-sm { border-radius: var(--border-radius-sm); }
.rounded-lg { border-radius: var(--border-radius-lg); }

/* ---- Shadow Utilities ---- */
.shadow { box-shadow: var(--shadow-md); }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-lg { box-shadow: var(--shadow-lg); }
.shadow-none { box-shadow: none; }

/* ---- Background Utilities ---- */
.bg-primary { background-color: var(--bg-primary); }
.bg-secondary { background-color: var(--bg-secondary); }
.bg-tertiary { background-color: var(--bg-tertiary); }

/* ---- Width & Height Utilities ---- */
.w-100 { width: 100%; }
.h-100 { height: 100%; }
.mw-100 { max-width: 100%; }
.mh-100 { max-height: 100%; }

/* ---- Dictation Controls Container ---- */
.dictation-controls {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    flex-wrap: nowrap;
}

/* ---- Dictation Control Buttons ---- */
.dictation-btn {
    background: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    font-weight: 500;
    transition: var(--transition-fast);
    position: relative;
    overflow: hidden;
    min-width: 70px;
    width: 70px;
    height: 36px;
    padding: 0.375rem 0.5rem;
    font-size: 0.8rem;
    border-radius: var(--border-radius-sm);
    white-space: nowrap;
    box-sizing: border-box;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    cursor: pointer;
}

.dictation-btn:hover:not(:disabled) {
    background: var(--surface-hover);
    border-color: var(--accent-blue);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.dictation-btn:active:not(:disabled) {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.dictation-btn.recording {
    /*background: var(--accent-blue);*/
    color: white;
    border-color: var(--accent-blue);
    animation: pulse-recording 2s infinite;
}

.dictation-btn.recording:hover {
    background: var(--accent-blue-hover);
    border-color: var(--accent-blue-hover);
    box-shadow: 0 4px 12px rgba(90, 124, 138, 0.3);
}

.dictation-btn.recording.paused {
    background: var(--surface-secondary);
    color: var(--text-primary);
    border-color: var(--border-color);
    animation: none;
}

.dictation-btn.generate-report {
    min-width: 130px;
    width: 130px;
    padding: 0.375rem 0.75rem;
}

.dictation-btn.generate-report .oi-document {
    font-size: 0.75rem;
}

.dictation-btn.pause, 
.dictation-btn.resume, 
.dictation-btn.stop {
    background: var(--bg-primary);
    color: var(--text-secondary);
    border-color: var(--border-color);
    min-width: 70px;
    width: 70px;
}

.dictation-btn.pause:hover, 
.dictation-btn.resume:hover, 
.dictation-btn.stop:hover {
    background: var(--surface-hover);
    border-color: var(--accent-blue);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.dictation-btn:disabled {
    opacity: 0.5;
    background: var(--bg-primary);
    color: var(--text-muted);
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    border-color: var(--border-color);
}

.dictation-btn:disabled:hover {
    background: var(--bg-primary);
    border-color: var(--border-color);
    color: var(--text-muted);
    transform: none;
    box-shadow: none;
}

/* ---- Dictation Button Animation ---- */
@keyframes pulse-recording {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(90, 124, 138, 0.4);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(90, 124, 138, 0);
    }
}

/* ---- Dictation Button Icons ---- */
.dictation-btn .oi {
    font-size: 0.875rem;
    line-height: 1;
}

.dictation-btn .oi:only-child {
    margin: 0;
}

/* ---- Recording Indicator ---- */
.recording-indicator {
    display: inline-block;
    width: 8px;
    height: 8px;
    background: currentColor;
    border-radius: 50%;
    margin-right: 0.25rem;
    animation: pulse-recording-dot 1.5s infinite;
}

@keyframes pulse-recording-dot {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.6;
        transform: scale(0.8);
    }
}

/* ---- Responsive Utilities ---- */
@media (max-width: 768px) {
    .d-sm-none { display: none; }
    .d-sm-block { display: block; }
    .d-sm-flex { display: flex; }
    
    .dictation-controls {
        gap: 0.375rem;
    }
    
    .dictation-btn {
        min-width: 60px;
        width: 60px;
        height: 32px;
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
    
    .recording-indicator {
        width: 6px;
        height: 6px;
        margin-right: 0.125rem;
    }
}

@media (max-width: 576px) {
    .d-xs-none { display: none; }
    .d-xs-block { display: block; }
    .d-xs-flex { display: flex; }
} 

/* ---- Error Detection Overlay Styles ---- */
.error-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
}

/* error-badge styling moved to shared location in telerik-overrides.css */

.error-detail {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-left: 0.5rem;
}

.error-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ---- Enhanced Button Styles ---- */
.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
    border-radius: var(--border-radius-sm);
    font-weight: 500;
    line-height: 1;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--accent-blue-hover);
    border-color: var(--accent-blue-hover);
    color: white;
    box-shadow: 0 2px 4px rgba(90, 124, 138, 0.2);
}

.btn-success {
    background: var(--success-green);
    border-color: var(--success-green);
    color: white;
    font-weight: 500;
}

.btn-success:hover:not(:disabled) {
    background: var(--success-green-hover);
    border-color: var(--success-green-hover);
    color: white;
    box-shadow: 0 2px 4px rgba(76, 175, 80, 0.2);
}

.btn-secondary {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
    font-weight: 500;
}

.btn-secondary:hover:not(:disabled) {
    background: var(--surface-hover);
    border-color: var(--accent-blue);
    color: var(--text-primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-danger {
    background: var(--error-high);
    border-color: var(--error-high);
    color: white;
    font-weight: 500;
}

.btn-danger:hover:not(:disabled) {
    background: var(--error-critical);
    border-color: var(--error-critical);
    color: white;
    box-shadow: 0 2px 4px rgba(244, 67, 54, 0.2);
}

.btn-info {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
    font-weight: 500;
}

.btn-info:hover:not(:disabled) {
    background: var(--accent-blue-hover);
    border-color: var(--accent-blue-hover);
    color: white;
    box-shadow: 0 2px 4px rgba(90, 124, 138, 0.2);
}

.btn-analyze {
    background: var(--bg-primary);
    border-color: var(--border-color);
    color: var(--text-primary);
    font-weight: 500;
    transition: var(--transition-normal);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
}

.btn-analyze:hover:not(:disabled) {
    background: var(--surface-hover);
    border-color: var(--accent-blue);
    color: var(--text-primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.btn-analyze.analyzing {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
    animation: analyzing-pulse 2s infinite;
}

@keyframes analyzing-pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

.btn-item-action {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 6px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    outline: none;
    position: relative;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    min-height: 32px;
}

.btn-item-action:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.btn-item-action:active {
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.btn-item-action .oi {
    font-size: 0.875rem;
    transition: transform 0.2s ease;
}

.btn-item-action:hover .oi {
    transform: scale(1.1);
}

.btn-item-action.btn-primary {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
    box-shadow: 0 2px 6px rgba(90, 124, 138, 0.3);
}

.btn-item-action.btn-primary:hover {
    background: var(--accent-blue-hover);
    border-color: var(--accent-blue-hover);
    box-shadow: 0 4px 16px rgba(90, 124, 138, 0.4);
}

.btn-item-action.btn-primary.active {
    background: var(--success-green);
    border-color: var(--success-green);
    box-shadow: 0 2px 6px rgba(76, 175, 80, 0.3);
    cursor: default;
}

.btn-item-action.btn-primary.active:hover {
    transform: none;
    background: var(--success-green);
    box-shadow: 0 2px 6px rgba(76, 175, 80, 0.3);
}

.btn-item-action.btn-secondary {
    background: var(--bg-tertiary);
    border-color: var(--border-color);
    color: var(--text-primary);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.btn-item-action.btn-secondary:hover {
    background: var(--surface-hover);
    border-color: var(--accent-blue);
    color: var(--accent-blue);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
}

.btn-item-action.btn-danger {
    background: var(--error-high);
    border-color: var(--error-high);
    color: white;
    box-shadow: 0 2px 6px rgba(244, 67, 54, 0.3);
}

.btn-item-action.btn-danger:hover {
    background: var(--error-critical);
    border-color: var(--error-critical);
    box-shadow: 0 4px 16px rgba(244, 67, 54, 0.4);
}

.btn-item-action.btn-success {
    background: var(--success-green);
    border-color: var(--success-green);
    color: white;
    box-shadow: 0 2px 6px rgba(76, 175, 80, 0.3);
}

.btn-item-action.btn-success:hover {
    background: var(--success-green-hover);
    border-color: var(--success-green-hover);
    box-shadow: 0 4px 16px rgba(76, 175, 80, 0.4);
}

/* ---- Alert Styles ---- */
.alert {
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: var(--border-radius-md);
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 0.875rem;
    line-height: 1.5;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.alert-danger {
    background-color: var(--bg-secondary);
    border: 1px solid rgba(244, 67, 54, 0.2);
    border-left: 3px solid var(--error-high);
    color: var(--text-primary);
}

.alert-success {
    background-color: var(--bg-secondary);
    border: 1px solid rgba(76, 175, 80, 0.2);
    border-left: 3px solid var(--success-green);
    color: var(--text-primary);
}

.alert-info {
    background-color: var(--bg-secondary);
    border: 1px solid rgba(90, 124, 138, 0.2);
    border-left: 3px solid var(--accent-blue);
    color: var(--text-primary);
}

.alert-warning {
    background-color: var(--bg-secondary);
    border: 1px solid rgba(255, 193, 7, 0.2);
    border-left: 3px solid #ffc107;
    color: var(--text-primary);
}

.alert-secondary {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-left: 3px solid var(--text-secondary);
    color: var(--text-primary);
}

/* ---- Button Close (X button) ---- */
.btn-close {
    background: transparent;
    border: none;
    font-size: 1rem;
    font-weight: 500;
    line-height: 1;
    color: var(--text-secondary);
    opacity: 0.5;
    cursor: pointer;
    padding: 0;
    width: 1em;
    height: 1em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.15s ease;
}

.btn-close:hover {
    opacity: 0.75;
    color: var(--text-primary);
}

.btn-close:focus {
    opacity: 1;
    outline: none;
    box-shadow: 0 0 0 0.2rem rgba(90, 124, 138, 0.25);
}

.btn-close::before {
    content: "×";
    font-family: inherit;
    font-size: inherit;
    line-height: 1;
}

/* ---- Flexbox Utilities ---- */
.d-flex {
    display: flex;
}

.justify-content-between {
    justify-content: space-between;
}

.align-items-start {
    align-items: flex-start;
}

.align-items-center {
    align-items: center;
}

/* ---- Enhanced Layout for Report Quadrant ---- */
.report-quad .quadrant-content {
    position: relative;
    padding: 0;
    overflow: hidden; /* Keep hidden for error overlays to work properly */
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.report-quad .quadrant-content .k-editor {
    border-radius: 0;
    border: none;
    height: 100%;
    min-height: 0;
    flex: 1;
}

/* Ensure proper padding inside the editor content area */
.report-quad .quadrant-content .k-editor-content,
.report-quad .quadrant-content .ProseMirror {
    padding: var(--quadrant-content-padding);
}

/* ---- Enhanced Layout for Dictation Quadrant ---- */
.dictation-quad .quadrant-content {
    position: relative;
    padding: 0;
    overflow: hidden; /* Consistent with report quadrant */
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.dictation-quad .quadrant-content .k-editor {
    border-radius: 0;
    border: none;
    height: 100%;
    min-height: 0;
    flex: 1;
}

/* Ensure proper padding inside the editor content area */
.dictation-quad .quadrant-content .k-editor-content,
.dictation-quad .quadrant-content .ProseMirror {
    padding: var(--quadrant-content-padding);
}

/* ---- Button Base Improvements ---- */ 

/* ---- Ensure Template Import modal is above overlay content ---- */
/* Note: Modals are now rendered outside the overlay, so these rules are no longer needed */
