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

/* Error detection & flagging */
.flagged-error {
    position: relative;
    padding: 2px 4px;
    cursor: help;
    color: inherit;
    font-weight: 500;
    text-decoration: underline;
    text-decoration-thickness: 2px;
    text-underline-offset: 2px;
    border-radius: var(--border-radius-sm);
    transition: var(--transition-fast);
}

.flagged-error:hover {
    text-decoration-thickness: 3px;
}

/* 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 {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.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;
    padding: 0.5rem 1rem;
    border: 1px solid transparent;
    border-radius: var(--border-radius-sm);
    background: transparent;
    color: inherit;
    font-family: inherit;
    font-size: 0.875rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    cursor: pointer;
    outline: none;
    transition: var(--transition-normal);
}

.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);
}

/* ---- Template/Macro button fixes ---- */
button[class*="btn-transparent"] {
    pointer-events: auto !important;
    cursor: pointer !important;
    position: relative !important;
    z-index: 10 !important;
}

.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 */
.templates-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg-primary);
    z-index: 1500;
    opacity: 0;
    visibility: hidden;
    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 {
    display: flex;
    flex-direction: column;
    flex: 1;
    height: 100%;
    min-height: 0;
    overflow: hidden;
}

.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;
}

/* 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;
    overflow: hidden;
}

.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;
    min-height: 0;
    overflow: hidden;
}

.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;
}

.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;
    min-width: 0;
}

.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;
    max-height: calc(100vh - 200px);
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.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;
    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;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 0 0 auto;
}

.exam-code-badge {
    display: inline-flex;
    align-items: center;
    height: 40px;
    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;
}

.details-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    flex: 1;
    min-height: 0;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.details-content::-webkit-scrollbar {
    width: 0;
    height: 0;
    display: none;
}

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

.detail-group.exam-code-field {
    margin-bottom: 0.5rem;
    margin-top: 0;
}

.exam-scope-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 0.75rem;
    align-items: flex-end;
}

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

.exam-scope-row .edit-exam-code-input,
.exam-scope-row .edit-category-select {
    width: 100%;
    height: 2.5rem;
    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;
}

.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: var(--font-family-primary);
    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;
    flex: 1;
}

.templates-header-right-text {
    display: flex;
    align-items: center;
    height: 40px;
    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;
    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;
    height: 36px;
    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;
    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 {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    position: relative;
    min-width: 70px;
    width: 70px;
    height: 36px;
    padding: 0.375rem 0.5rem;
    background: var(--bg-primary);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
    overflow: hidden;
    box-sizing: border-box;
    transition: var(--transition-fast);
}

.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;
    margin-right: 0.25rem;
    background: currentColor;
    border-radius: 50%;
    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-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 {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.375rem 0.75rem;
    border-radius: var(--border-radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1;
}

/* Button variants */
.btn-primary,
.btn-info {
    background: var(--accent-blue);
    border-color: var(--accent-blue);
    color: white;
    font-weight: 500;
}

.btn-primary:hover:not(:disabled),
.btn-info:hover:not(:disabled) {
    background: var(--accent-blue-hover);
    border-color: var(--accent-blue-hover);
    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);
    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);
    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);
    box-shadow: 0 2px 4px rgba(244, 67, 54, 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 {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    position: relative;
    padding: 1rem;
    margin-bottom: 1rem;
    border: 1px solid transparent;
    border-radius: var(--border-radius-md);
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.875rem;
    line-height: 1.5;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

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

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

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

.alert-warning {
    border: 1px solid rgba(255, 193, 7, 0.2);
    border-left: 3px solid #ffc107;
}

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

/* Button close (X button) */
.btn-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1em;
    height: 1em;
    padding: 0;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1rem;
    font-weight: 500;
    line-height: 1;
    cursor: pointer;
    opacity: 0.5;
    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;
}

/* Enhanced layout for quadrants */
.report-quad .quadrant-content,
.dictation-quad .quadrant-content {
    display: flex;
    flex-direction: column;
    position: relative;
    padding: 0;
    min-height: 0;
    overflow: hidden;
}

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

.report-quad .quadrant-content .k-editor-content,
.report-quad .quadrant-content .ProseMirror,
.dictation-quad .quadrant-content .k-editor-content,
.dictation-quad .quadrant-content .ProseMirror {
    padding: var(--quadrant-content-padding);
}
