/* Surgical Logbook Styles */
:root {
    --primary: #1a5f7a;
    --primary-dark: #134b5e;
    --primary-light: #2980b9;
    --secondary: #16a085;
    --accent: #e74c3c;
    --bg-light: #f8f9fa;
    --bg-dark: #ecf0f1;
    --text-dark: #2c3e50;
    --text-light: #7f8c8d;
    --border: #bdc3c7;
    --white: #ffffff;
    --shadow: 0 2px 10px rgba(0,0,0,0.1);
    --shadow-hover: 0 4px 20px rgba(0,0,0,0.15);
    --radius: 8px;
    --transition: all 0.3s ease;
}

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

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: var(--white);
    padding: 1rem 2rem;
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

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

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--white);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 1.5rem;
}

.logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: -0.5px;
}

.logo h1 .personal-name {
    font-weight: 400;
    font-size: 1.1rem;
    opacity: 0.9;
}

.header-controls {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.language-selector {
    display: flex;
    background: rgba(255,255,255,0.15);
    border-radius: var(--radius);
    overflow: hidden;
}

.lang-btn {
    padding: 0.5rem 1rem;
    background: transparent;
    border: none;
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    font-weight: 500;
    transition: var(--transition);
}

.lang-btn:hover {
    background: rgba(255,255,255,0.1);
    color: var(--white);
}

.lang-btn.active {
    background: var(--white);
    color: var(--primary);
}

.lang-btn.logout-btn {
    margin-left: 0.5rem;
    border-left: 1px solid rgba(255,255,255,0.3);
    padding-left: 1rem;
    color: rgba(255,200,200,0.9);
}

.lang-btn.logout-btn:hover {
    background: rgba(255,100,100,0.2);
    color: #ffcccc;
}

/* Navigation */
.nav {
    background: var(--white);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
}

.nav-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    gap: 0;
    overflow-x: auto;
}

.nav-btn {
    padding: 1rem 1.5rem;
    background: transparent;
    border: none;
    color: var(--text-light);
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    border-bottom: 3px solid transparent;
    transition: var(--transition);
    white-space: nowrap;
}

.nav-btn:hover {
    color: var(--primary);
    background: var(--bg-light);
}

.nav-btn.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

/* Main Content */
.main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

.page {
    display: none;
    animation: fadeIn 0.3s ease;
}

.page.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cards */
.card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--bg-dark);
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--primary);
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.25rem;
}

.form-group {
    margin-bottom: 0;
}

.form-group.full-width {
    grid-column: 1 / -1;
}

.form-label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-dark);
    font-size: 0.9rem;
}

.form-label .hint {
    font-weight: 400;
    color: var(--text-light);
    font-size: 0.8rem;
    margin-left: 0.5rem;
}

.form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--white);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26, 95, 122, 0.1);
}

.form-control:disabled {
    background: var(--bg-dark);
    cursor: not-allowed;
}

select.form-control {
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%237f8c8d' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1rem center;
    padding-right: 2.5rem;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

/* Searchable Select */
.searchable-select {
    position: relative;
}

.searchable-select input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 1rem;
}

.searchable-select .dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    max-height: 300px;
    overflow-y: auto;
    z-index: 50;
    display: none;
    box-shadow: var(--shadow);
}

.searchable-select .dropdown.show,
.searchable-select .dropdown.active,
.ap-mel-dropdown.show,
.ap-ktdp-dropdown.show {
    display: block;
}

.searchable-select .dropdown-item,
.ap-mel-dropdown .dropdown-item,
.ap-ktdp-dropdown .dropdown-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--bg-dark);
}

.searchable-select .dropdown-item:hover,
.ap-mel-dropdown .dropdown-item:hover,
.ap-ktdp-dropdown .dropdown-item:hover {
    background: var(--bg-light);
}

.searchable-select .dropdown-item .code,
.ap-mel-dropdown .dropdown-item .code,
.ap-ktdp-dropdown .dropdown-item .code {
    font-weight: 600;
    color: var(--primary);
    margin-right: 0.5rem;
}

.searchable-select .dropdown-item .category {
    font-size: 0.8rem;
    color: var(--text-light);
    display: block;
    margin-top: 0.25rem;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--radius);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-hover);
}

.btn-secondary {
    background: var(--bg-dark);
    color: var(--text-dark);
}

.btn-secondary:hover {
    background: var(--border);
}

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

.btn-success:hover {
    background: #1abc9c;
}

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

.btn-danger:hover {
    background: #c0392b;
}

.btn-outline {
    background: transparent;
    color: var(--text-dark);
    border: 1px solid var(--border-color);
}

.btn-outline:hover {
    background: var(--bg-dark);
}

.btn-info {
    background: #3498db;
    color: var(--white);
}

.btn-info:hover {
    background: #2980b9;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

.btn-group {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Tables */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.95rem;
}

.table th,
.table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--bg-dark);
}

.table th {
    background: var(--bg-light);
    font-weight: 600;
    color: var(--text-dark);
    white-space: nowrap;
}

.table tbody tr {
    transition: var(--transition);
}

.table tbody tr:hover {
    background: var(--bg-light);
}

.table .actions {
    display: flex;
    gap: 0.5rem;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.badge-primary { background: rgba(26, 95, 122, 0.1); color: var(--primary); }
.badge-success { background: rgba(22, 160, 133, 0.1); color: var(--secondary); }
.badge-warning { background: rgba(243, 156, 18, 0.1); color: #f39c12; }
.badge-danger { background: rgba(231, 76, 60, 0.1); color: var(--accent); }
.badge-info { background: rgba(52, 152, 219, 0.15); color: #2980b9; }

/* Clavien-Dindo Badges */
.cd-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
}

.cd-I { background: #d4edda; color: #155724; }
.cd-II { background: #fff3cd; color: #856404; }
.cd-IIIa { background: #ffe0b2; color: #e65100; }
.cd-IIIb { background: #ffccbc; color: #bf360c; }
.cd-IVa { background: #f8d7da; color: #721c24; }
.cd-IVb { background: #f5c6cb; color: #721c24; }
.cd-V { background: #721c24; color: #fff; }

/* Complexity badges and fills */
.complexity-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.85rem;
    font-weight: 600;
    min-width: 1.5rem;
    text-align: center;
}

/* Vascular surgery complexity (1-5) */
.complexity-1, .complexity-badge.complexity-1 { background: #d4edda; color: #155724; }
.complexity-2, .complexity-badge.complexity-2 { background: #cce5ff; color: #004085; }
.complexity-3, .complexity-badge.complexity-3 { background: #fff3cd; color: #856404; }
.complexity-4, .complexity-badge.complexity-4 { background: #ffe0b2; color: #e65100; }
.complexity-5, .complexity-badge.complexity-5 { background: #f8d7da; color: #721c24; }

/* General surgery complexity (A-D) */
.complexity-A, .complexity-badge.complexity-A { background: #d4edda; color: #155724; }
.complexity-B, .complexity-badge.complexity-B { background: #cce5ff; color: #004085; }
.complexity-C, .complexity-badge.complexity-C { background: #fff3cd; color: #856404; }
.complexity-D, .complexity-badge.complexity-D { background: #f8d7da; color: #721c24; }

.complexity-fill-1 { background: linear-gradient(90deg, #28a745 0%, #20c997 100%); }
.complexity-fill-2 { background: linear-gradient(90deg, #007bff 0%, #17a2b8 100%); }
.complexity-fill-3 { background: linear-gradient(90deg, #ffc107 0%, #fd7e14 100%); }
.complexity-fill-4 { background: linear-gradient(90deg, #fd7e14 0%, #dc3545 100%); }
.complexity-fill-5 { background: linear-gradient(90deg, #dc3545 0%, #721c24 100%); }

/* General surgery complexity fills (A-D) */
.complexity-fill-A { background: linear-gradient(90deg, #28a745 0%, #20c997 100%); }
.complexity-fill-B { background: linear-gradient(90deg, #007bff 0%, #17a2b8 100%); }
.complexity-fill-C { background: linear-gradient(90deg, #ffc107 0%, #fd7e14 100%); }
.complexity-fill-D { background: linear-gradient(90deg, #dc3545 0%, #721c24 100%); }

/* Statistics */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    text-align: center;
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.stat-label {
    color: var(--text-light);
    font-size: 0.9rem;
}

.chart-container {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.chart-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 1rem;
}

/* Chart Bars */
.bar-chart {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.bar-item {
    display: grid;
    grid-template-columns: 200px 1fr 60px;
    align-items: center;
    gap: 1rem;
}

.bar-label {
    font-size: 0.9rem;
    color: var(--text-dark);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bar-track {
    height: 24px;
    background: var(--bg-dark);
    border-radius: 12px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 12px;
    transition: width 0.5s ease;
}

.bar-value {
    font-weight: 600;
    color: var(--text-dark);
    text-align: right;
}

/* Trend Chart (vertical bars) */
.trend-chart {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    height: 200px;
    gap: 4px;
    padding: 0 0.5rem;
}

.trend-bar-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    height: 100%;
}

.trend-bar {
    width: 100%;
    max-width: 40px;
    background: linear-gradient(180deg, var(--primary) 0%, var(--primary-light) 100%);
    border-radius: 4px 4px 0 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    min-height: 20px;
    transition: height 0.5s ease;
}

.trend-bar-duration {
    background: linear-gradient(180deg, #9b59b6 0%, #8e44ad 100%);
}

.trend-value {
    font-size: 0.7rem;
    font-weight: 600;
    color: white;
    padding-top: 4px;
}

.trend-label {
    font-size: 0.7rem;
    color: var(--text-light);
    margin-top: 4px;
    text-align: center;
}

/* Duration Range Visualization */
.duration-range {
    position: relative;
    height: 12px;
    background: var(--bg-dark);
    border-radius: 6px;
    overflow: visible;
}

.duration-range-bar {
    position: absolute;
    top: 3px;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(90deg, #3498db 0%, #9b59b6 50%, #e74c3c 100%);
    border-radius: 3px;
}

.duration-range-avg {
    position: absolute;
    top: -2px;
    width: 16px;
    height: 16px;
    background: var(--primary);
    border: 2px solid white;
    border-radius: 50%;
    transform: translateX(-50%);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
    cursor: help;
}

/* Modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.show {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hover);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    transform: scale(0.9);
    transition: var(--transition);
}

.modal-overlay.show .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--bg-dark);
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-light);
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text-dark);
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--bg-dark);
}

/* Export Modal */
#exportModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.export-modal-content {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hover);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.export-modal-content .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--bg-dark);
}

.export-modal-content .modal-header h2 {
    margin: 0;
    font-size: 1.25rem;
}

.export-field-actions {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.export-field-actions .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

.export-fields-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid var(--bg-dark);
    border-radius: var(--radius);
    padding: 0.75rem;
}

.export-fields-grid .checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    padding: 0.25rem;
}

.export-fields-grid .checkbox-label:hover {
    background: var(--bg-light);
    border-radius: 4px;
}

.export-fields-grid input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
}

@media (max-width: 480px) {
    .export-fields-grid {
        grid-template-columns: 1fr;
    }
}

/* Tooltips */
.tooltip-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
}

.tooltip-icon {
    width: 18px;
    height: 18px;
    background: var(--text-light);
    color: var(--white);
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    margin-left: 0.5rem;
    cursor: help;
}

.tooltip-text {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-dark);
    color: var(--white);
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    font-size: 0.85rem;
    width: 320px;
    max-width: 90vw;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 100;
    box-shadow: var(--shadow);
    line-height: 1.5;
    text-align: left;
}

.tooltip-wrapper:hover .tooltip-text {
    opacity: 1;
    visibility: visible;
}

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

/* Search & Filter */
.search-bar {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.search-input {
    flex: 1;
    min-width: 250px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 4rem 2rem;
    color: var(--text-light);
}

.empty-state-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state-text {
    font-size: 1.1rem;
    margin-bottom: 1.5rem;
}

/* Alerts */
.alert {
    padding: 1rem 1.25rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Catalog Browser */
.catalog-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--bg-dark);
    padding-bottom: 0.5rem;
}

.catalog-tab {
    padding: 0.5rem 1rem;
    border: none;
    background: var(--bg-light);
    border-radius: var(--radius) var(--radius) 0 0;
    cursor: pointer;
    font-weight: 500;
    color: var(--text);
    transition: all 0.2s;
}

.catalog-tab:hover {
    background: var(--bg-dark);
}

.catalog-tab.active {
    background: var(--primary);
    color: white;
}

.catalog-search {
    margin-bottom: 1rem;
}

.catalog-results {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--bg-dark);
    border-radius: var(--radius);
}

.catalog-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--bg-dark);
    cursor: pointer;
    transition: background 0.2s;
}

.catalog-item:hover {
    background: var(--bg-light);
}

.catalog-item:last-child {
    border-bottom: none;
}

.catalog-item-code {
    font-weight: 600;
    color: var(--primary);
    font-family: monospace;
    margin-right: 0.5rem;
}

.catalog-item-name {
    color: var(--text);
}

.catalog-item-category {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 0.25rem;
}

.catalog-item-langs {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.25rem;
    display: flex;
    gap: 1rem;
}

.catalog-item-langs span {
    background: var(--bg-light);
    padding: 0.1rem 0.4rem;
    border-radius: 3px;
}

/* Operations by type table */
.operations-by-type {
    max-height: 400px;
    overflow-y: auto;
}

.table-compact {
    font-size: 0.9rem;
}

.table-compact th,
.table-compact td {
    padding: 0.5rem 0.75rem;
}

.table-compact tbody tr:hover {
    background: var(--bg-light);
}

/* Category badges */
.cat-badge {
    display: inline-block;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    margin-right: 0.3rem;
    text-transform: uppercase;
}

.cat-mel {
    background: #e3f2fd;
    color: #1565c0;
}

.cat-ktdp {
    background: #e8f5e9;
    color: #2e7d32;
}

/* Clear code button */
.code-input-wrapper {
    position: relative;
}

.clear-code-btn {
    position: absolute;
    right: 8px;
    top: 8px;
    width: 24px;
    height: 24px;
    border: none;
    background: var(--bg-dark);
    color: var(--text);
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0.6;
    transition: opacity 0.2s, background 0.2s;
    z-index: 5;
}

.clear-code-btn:hover {
    opacity: 1;
    background: var(--danger);
    color: white;
}

/* Additional procedure item */
.additional-procedure-item {
    position: relative;
    background: var(--bg-light);
    border: 1px solid var(--bg-dark);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
}

.additional-procedure-item .remove-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 24px;
    height: 24px;
    border: none;
    background: var(--danger);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
}

.ap-code-wrapper {
    position: relative;
}

.ap-name-wrapper {
    position: relative;
}

.ap-name-wrapper .dropdown,
.ap-code-wrapper .dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 100;
    background: white;
    border: 1px solid var(--bg-dark);
    border-radius: var(--radius);
    max-height: 200px;
    overflow-y: auto;
    display: none;
    box-shadow: var(--shadow);
}

.ap-name-wrapper .dropdown.show,
.ap-code-wrapper .dropdown.show {
    display: block;
}

.ap-name-dropdown .dropdown-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid var(--bg-dark);
    font-size: 0.875rem;
}

.ap-name-dropdown .dropdown-item:hover {
    background: var(--bg-light);
}

.ap-name-dropdown .dropdown-item:last-child {
    border-bottom: none;
}

.ap-name-dropdown .badge-primary {
    background: var(--primary);
    color: white;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
}

.ap-name-dropdown .badge-success {
    background: var(--success);
    color: white;
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
}

.ap-translation-preview {
    background: white;
    border: 1px solid var(--bg-dark);
    border-radius: var(--radius);
    padding: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.85rem;
}

.ap-translation-preview input {
    font-size: 0.85rem;
    padding: 0.25rem 0.5rem;
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        padding: 1rem;
    }
    
    .header-content {
        flex-direction: column;
        align-items: stretch;
    }
    
    .logo h1 {
        font-size: 1.25rem;
    }
    
    .header-controls {
        justify-content: center;
    }
    
    .nav {
        padding: 0 1rem;
    }
    
    .nav-btn {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
    }
    
    .main {
        padding: 1rem;
    }
    
    .form-grid {
        grid-template-columns: 1fr;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .bar-item {
        grid-template-columns: 1fr;
        gap: 0.5rem;
    }
    
    .bar-track {
        order: 2;
    }
    
    .bar-value {
        text-align: left;
        order: 3;
    }
    
    .table th,
    .table td {
        padding: 0.75rem 0.5rem;
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .stat-value {
        font-size: 2rem;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .btn-group {
        flex-direction: column;
    }
}

/* Print Styles */
@media print {
    .header, .nav, .btn, .modal-overlay {
        display: none !important;
    }
    
    .main {
        padding: 0;
    }
    
    .card {
        box-shadow: none;
        border: 1px solid #ddd;
    }
}

/* Translation Preview */
.translation-preview {
    background: var(--bg-light);
    border: 1px solid var(--bg-dark);
    border-radius: var(--radius);
    padding: 0.75rem;
    margin-top: 0.5rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.translation-edit-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.translation-edit-item label {
    font-weight: 600;
    color: var(--primary);
    min-width: 30px;
    font-size: 0.85rem;
}

.translation-edit-item input {
    flex: 1;
    font-size: 0.9rem;
}

.translation-buttons {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 0.25rem;
}

.translation-item {
    display: block;
    padding: 0.25rem 0.5rem;
    background: var(--white);
    border-radius: 4px;
    font-size: 0.85rem;
}

.translation-item strong {
    color: var(--primary);
}

/* Additional Procedures */
.additional-procedure-item {
    background: var(--bg-light);
    border: 1px solid var(--bg-dark);
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 0.75rem;
    position: relative;
}

.additional-procedure-item .remove-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: 50%;
    width: 24px;
    height: 24px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.additional-procedure-item .form-grid {
    margin-bottom: 0;
}

/* Larger Modal */
.modal-large {
    max-width: 800px;
    width: 95%;
}

.modal-large .modal-body {
    max-height: 70vh;
    overflow-y: auto;
}

/* Details Grid */
.details-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.details-item {
    padding: 0.75rem;
    background: var(--bg-light);
    border-radius: var(--radius);
}

.details-item.full-width {
    grid-column: span 2;
}

.details-label {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-bottom: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.details-value {
    font-weight: 500;
    color: var(--text-dark);
}

.details-section {
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--bg-dark);
}

.details-section-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 1rem;
}

/* Clickable Row */
.table tbody tr.clickable {
    cursor: pointer;
}

.table tbody tr.clickable:hover {
    background: rgba(26, 95, 122, 0.05);
}

/* Autocomplete Dropdown */
#operationNameDropdown {
    z-index: 1001;
}

#operationNameDropdown .dropdown-item {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--bg-light);
}

#operationNameDropdown .dropdown-item:last-child {
    border-bottom: none;
}

#operationNameDropdown .dropdown-item:hover {
    background: var(--bg-light);
}

/* Small buttons in labels */
.form-label .btn-link {
    padding: 0;
    margin-left: 0.5rem;
    font-size: 1rem;
    text-decoration: none;
}

/* Category tag in dropdowns */
.category-tag {
    display: inline-block;
    font-size: 0.7rem;
    padding: 0.1rem 0.4rem;
    background: var(--bg-dark);
    border-radius: 3px;
    margin-left: 0.5rem;
    color: var(--text-light);
}

@media (max-width: 768px) {
    .details-grid {
        grid-template-columns: 1fr;
    }
    
    .details-item.full-width {
        grid-column: span 1;
    }
    
    .modal-large {
        max-width: 100%;
        margin: 0.5rem;
    }
}

/* ==================== LOGIN SCREEN ==================== */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.login-box {
    background: var(--white);
    padding: 2.5rem;
    padding-top: 3.5rem;
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 400px;
    text-align: center;
    position: relative;
}

.login-logo {
    font-size: 4rem;
    margin-bottom: 1rem;
}

.login-box h1 {
    color: var(--text-dark);
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

.login-box .form-group {
    text-align: left;
    margin-bottom: 1rem;
}

.login-box .form-control {
    width: 100%;
    padding: 0.75rem 1rem;
    font-size: 1rem;
}

.login-box .btn {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

/* Responsive login */
@media (max-width: 480px) {
    .login-box {
        margin: 1rem;
        padding: 1.5rem;
    }
    
    .login-logo {
        font-size: 3rem;
    }
}

/* Subspecialty Autocomplete Dropdown */
.autocomplete-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--white);
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
    max-height: 250px;
    overflow-y: auto;
    z-index: 100;
    display: none;
    box-shadow: var(--shadow);
}

.autocomplete-dropdown.show {
    display: block;
}

.autocomplete-dropdown .dropdown-item {
    padding: 0.6rem 1rem;
    cursor: pointer;
    border-bottom: 1px solid var(--bg-dark);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.autocomplete-dropdown .dropdown-item:hover {
    background: var(--bg-light);
}

.autocomplete-dropdown .dropdown-item:last-child {
    border-bottom: none;
}

.autocomplete-dropdown .dropdown-item .name {
    font-weight: 500;
}

.autocomplete-dropdown .dropdown-item .count {
    font-size: 0.8rem;
    color: var(--text-light);
}

/* Board Review Modal (EBSQ/FEBVS) */
#boardReviewModal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.6);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.board-review-modal {
    background: var(--white) !important;
    border-radius: var(--radius);
    box-shadow: var(--shadow-hover);
    width: 95vw !important;
    min-width: 95vw !important;
    max-width: 95vw !important;
    height: 90vh !important;
    min-height: 90vh !important;
    max-height: 90vh !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
}

/* Summary Export Modal */
.summary-export-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.summary-export-modal-content {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hover);
    width: 550px;
    max-width: 95vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.summary-export-modal-content .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--bg-dark);
    background: var(--primary);
    color: white;
    border-radius: var(--radius) var(--radius) 0 0;
    flex-shrink: 0;
}

.summary-export-modal-content .modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
}

.summary-export-modal-content .modal-close {
    color: white;
    font-size: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
}

.summary-export-modal-content .modal-close:hover {
    opacity: 0.8;
}

.summary-export-modal-content .modal-body {
    flex: 1;
    overflow: auto;
    padding: 1rem;
}

.summary-export-modal-content .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-light);
    flex-shrink: 0;
}

/* Board Review Modal Overlay (shared by EBSQ, FEBVS, Summary Preview) */
.board-review-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    justify-content: center;
    align-items: center;
}

.board-review-modal-content {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hover);
    width: 95vw;
    max-width: 95vw;
    height: 90vh;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.board-review-modal-content .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--bg-dark);
    background: var(--primary);
    color: white;
    border-radius: var(--radius) var(--radius) 0 0;
    flex-shrink: 0;
}

.board-review-modal-content .modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.board-review-modal-content .modal-close {
    color: white;
    font-size: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
}

.board-review-modal-content .modal-body {
    flex: 1;
    overflow: auto;
    padding: 1rem;
}

.board-review-modal-content .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-light);
    flex-shrink: 0;
}

/* Summary table rows */
.board-review-table .summary-row {
    background-color: #e8e8e8 !important;
    font-weight: bold;
}

.board-review-table .detail-row {
    background-color: #f9f9f9;
    font-size: 0.9em;
    color: #666;
}

.board-review-modal .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--bg-dark);
    background: var(--primary);
    color: white;
    border-radius: var(--radius) var(--radius) 0 0;
    flex-shrink: 0;
}

.board-review-modal .modal-header h2 {
    margin: 0;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.board-review-modal .modal-header h2 img {
    height: 28px;
    width: auto;
}

.board-review-modal .modal-close {
    color: white;
    font-size: 1.5rem;
    background: none;
    border: none;
    cursor: pointer;
}

.board-review-modal .modal-close:hover {
    opacity: 0.8;
}

.board-review-modal .modal-body {
    flex: 1;
    overflow: auto;
    padding: 0;
}

.board-review-settings {
    padding: 0.75rem 1rem;
    background: var(--bg-light);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.board-review-settings-row {
    display: flex;
    gap: 2rem;
    align-items: center;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.board-review-settings-row.febvs-options {
    padding-top: 0.5rem;
    border-top: 1px dashed var(--border);
}

.board-review-settings .setting-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.board-review-settings .setting-group label {
    margin: 0;
    font-weight: 500;
}

.board-review-settings .setting-group select {
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

.board-review-columns-settings {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.board-review-columns-settings .columns-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.board-review-columns-settings .columns-header span {
    font-weight: 500;
}

.board-review-columns-settings .columns-header .btn-sm {
    padding: 0.15rem 0.4rem;
    font-size: 0.7rem;
}

.board-review-columns-settings .columns-checkboxes {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem 1rem;
}

.board-review-columns-settings .checkbox-inline {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-size: 0.8rem;
    cursor: pointer;
}

.board-review-columns-settings .checkbox-inline input {
    margin: 0;
}

.board-review-table .complexity-separator td {
    background: #e8e8e8 !important;
    font-weight: bold;
    text-align: left !important;
    padding: 0.5rem !important;
}

.board-review-table .complexity-separator.secondary td {
    background: #f0f0f0 !important;
    font-weight: normal;
    font-style: italic;
    padding-left: 1.5rem !important;
}

.board-review-modal .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    border-top: 1px solid var(--bg-dark);
    background: var(--bg-light);
    flex-shrink: 0;
}

.board-review-modal .modal-body {
    overflow-x: auto;
    padding: 1rem;
}

.board-review-table-container {
    overflow: auto;
    height: 100%;
    width: 100%;
}

.board-review-table {
    font-size: 0.75rem;
    white-space: nowrap;
    border-collapse: collapse;
    width: 100%;
}

.board-review-table th,
.board-review-table td {
    padding: 0.25rem 0.4rem;
    vertical-align: middle;
    border: 1px solid var(--border);
}

.board-review-table th {
    background: var(--primary);
    color: white;
    position: sticky;
    top: 0;
    z-index: 1;
    font-weight: 600;
    text-align: left;
    font-size: 0.7rem;
}

.board-review-table tbody tr:nth-child(even) {
    background: var(--bg-light);
}

.board-review-table tbody tr:hover {
    background: #e3f2fd;
}

.board-review-table td:nth-child(1) {
    text-align: center;
    font-weight: 600;
}

.board-review-table td:nth-child(10),
.board-review-table td:nth-child(11) {
    text-align: center;
}

.board-review-summary {
    padding: 0.5rem 1rem;
    background: var(--bg-light);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

/* UEMS button style */
.btn-uems {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

.btn-uems img {
    height: 20px;
    width: auto;
    border-radius: 50%;
}

@media print {
    #boardReviewModal {
        position: static;
        background: none;
        padding: 0;
    }
    
    .board-review-modal {
        width: 100%;
        height: auto;
        box-shadow: none;
    }
    
    .board-review-modal .modal-footer,
    .board-review-modal .modal-close {
        display: none;
    }
    
    .board-review-modal .modal-header {
        background: none;
        color: black;
        border-bottom: 2px solid black;
    }
    
    .board-review-table-container {
        overflow: visible;
    }
    
    .board-review-table {
        font-size: 9px;
    }
    
    .board-review-table th {
        background: #ddd !important;
        color: black !important;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}

/* Translation Confirmation Dialog */
.translation-confirm-modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    justify-content: center;
    align-items: center;
}

.translation-confirm-modal-content {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-hover);
    width: 450px;
    max-width: 95vw;
    overflow: hidden;
}

.translation-confirm-modal-content .modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: var(--primary);
    color: white;
}

.translation-confirm-modal-content .modal-header h3 {
    margin: 0;
    font-size: 1rem;
}

.translation-confirm-modal-content .modal-body {
    padding: 1rem;
}

.translation-confirm-modal-content .modal-body p {
    margin: 0 0 1rem 0;
}

.translation-preview {
    background: var(--bg-light);
    border-radius: var(--radius);
    padding: 0.75rem;
}

.translation-source {
    margin-bottom: 0.75rem;
}

.translation-source .source-text {
    color: var(--primary);
    font-style: italic;
}

.translation-targets {
    border-top: 1px solid var(--border);
    padding-top: 0.75rem;
}

.translation-targets .checkbox-label {
    display: block;
    margin: 0.25rem 0;
}

.translation-confirm-modal-content .modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border);
    background: var(--bg-light);
}

/* Multi-user styles */
.user-selector-bar {
    background: var(--primary-dark);
    padding: 0.5rem 1rem;
    display: flex;
    justify-content: center;
    align-items: center;
}

.user-selector-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--white);
    font-size: 0.9rem;
}

.user-selector-dropdown {
    min-width: 200px;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius);
    border: 1px solid rgba(255,255,255,0.3);
    background: rgba(255,255,255,0.1);
    color: var(--white);
}

.user-selector-dropdown option {
    background: var(--primary-dark);
    color: var(--white);
}

.viewing-indicator {
    color: var(--warning);
    font-weight: 500;
}

/* Signature styles in operations list */
.signature-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.5rem;
    border-radius: var(--radius);
    font-size: 0.75rem;
}

.signature-badge.signed {
    background: var(--success);
    color: white;
}

.signature-badge.unsigned {
    background: var(--text-light);
    color: white;
}

.signature-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.bulk-sign-bar {
    background: var(--secondary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Admin table styles */
#users-list .table {
    width: 100%;
    border-collapse: collapse;
}

#users-list .table th,
#users-list .table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

#users-list .table th {
    background: var(--background);
    font-weight: 600;
}

#users-list .btn-sm {
    padding: 0.25rem 0.5rem;
    font-size: 0.8rem;
    margin-right: 0.25rem;
}
