:root {
    --primary-color: #3498db;
    --secondary-color: #2c3e50;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --info-color: #17a2b8;
    --readonly-bg: #f8f9fa;
    --readonly-border: #e9ecef;
    --readonly-text: #6c757d;
    --editable-bg: #ffffff;
    --populated-bg: #e8f5e8;
    --populated-border: #28a745;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f8f9fa;
    line-height: 1.6;
}

/* Bold form controls */
.form-control-bold {
    font-weight: bold !important;
    font-size: 14px;
}

.form-select-bold {
    font-weight: bold !important;
    font-size: 14px;
}

/* Apply bold to all form controls by default */
.form-control, .form-select {
    font-weight: bold !important;
}

/* Read-only field styling */
.readonly-field {
    background-color: var(--readonly-bg) !important;
    border-color: var(--readonly-border) !important;
    color: var(--readonly-text) !important;
    cursor: not-allowed !important;
    opacity: 0.9;
}

.readonly-field:focus {
    border-color: var(--readonly-border) !important;
    box-shadow: none !important;
    outline: none !important;
}

/* Data populated fields */
.data-populated {
    background-color: var(--populated-bg) !important;
    border-color: var(--populated-border) !important;
    font-weight: bold !important;
    position: relative;
}

.data-populated::after {
    content: "✓";
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--success-color);
    font-weight: bold;
    font-size: 12px;
}

/* Status indicators */
.status-indicator {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
    border-radius: 0.375rem;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
}

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

.status-readonly {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

.status-searching {
    background-color: #cce7ff;
    color: #004085;
    border: 1px solid #b3d7ff;
}

/* Field labels with status */
.field-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.field-status {
    font-size: 0.7rem;
    padding: 0.2rem 0.4rem;
    border-radius: 0.25rem;
    font-weight: 600;
}

.field-status.editable {
    background-color: #d4edda;
    color: #155724;
}

.field-status.readonly {
    background-color: #fff3cd;
    color: #856404;
}

/* Search status styling */
.search-status {
    padding: 0.5rem;
    border-radius: 0.375rem;
    margin: 0.5rem 0;
    font-size: 0.9rem;
    font-weight: 500;
}

.search-status.searching {
    background-color: #e7f3ff;
    color: #0066cc;
    border-left: 4px solid #0066cc;
}

.search-status.found {
    background-color: #f0fff4;
    color: #38a169;
    border-left: 4px solid #38a169;
}

.search-status.not-found {
    background-color: #fffaf0;
    color: #d69e2e;
    border-left: 4px solid #d69e2e;
}

.search-status.error {
    background-color: #fff5f5;
    color: #e53e3e;
    border-left: 4px solid #e53e3e;
}

/* Complication Dropdown Styling */
.complication-dropdown {
    border: 2px solid #dc3545 !important;
    background-color: #fff !important;
    transition: all 0.3s ease;
}

.complication-dropdown option[value="Yes"] {
    background-color: #28a745 !important;
    color: white !important;
    font-weight: bold !important;
}

.complication-dropdown option[value="No"] {
    background-color: #dc3545 !important;
    color: white !important;
    font-weight: bold !important;
}

/* Dynamic color changes based on selection */
.complication-dropdown.yes-selected {
    border-color: #28a745 !important;
    background-color: #f8fff9 !important;
    color: #155724 !important;
}

.complication-dropdown.no-selected {
    border-color: #dc3545 !important;
    background-color: #fff8f8 !important;
    color: #721c24 !important;
}

/* Ensure dropdown text is bold and visible */
.form-select-bold {
    font-weight: bold !important;
    font-size: 14px !important;
}

.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-card {
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    padding: 2rem;
    width: 100%;
    max-width: 400px;
}

.dashboard-header {
    background: linear-gradient(135deg, var(--secondary-color), var(--primary-color));
    color: white;
    padding: 1rem 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.form-section {
    background: white;
    border-radius: 10px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 15px rgba(0,0,0,0.08);
    border: 1px solid #e9ecef;
}

.section-title {
    color: var(--secondary-color);
    border-bottom: 2px solid #eee;
    padding-bottom: 0.5rem;
    margin-bottom: 1rem;
    font-weight: 600;
}

.radio-group {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.radio-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 80px;
}

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

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

.btn-primary:hover {
    background-color: #2980b9;
    border-color: #2980b9;
}

.loading-spinner {
    display: none;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.alert-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1050;
    min-width: 300px;
}

.success-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.success-card {
    background: white;
    border-radius: 15px;
    padding: 3rem;
    text-align: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.1);
}

.success-icon {
    font-size: 4rem;
    color: var(--success-color);
    margin-bottom: 1rem;
}

/* Checkup Section Specific Styles */
.checkup-section {
    border-left: 4px solid #007bff;
    margin-bottom: 10px;
}

.collapsible-header {
    cursor: pointer;
    padding: 15px;
    transition: all 0.3s ease;
}

.collapsible-header:hover {
    background-color: rgba(255,255,255,0.1);
}

.collapsible-header .toggle-icon {
    transition: transform 0.3s ease;
    color: #6c757d;
}

.collapsible-header.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.checkup-card {
    margin-bottom: 5px;
    border: 1px solid #dee2e6;
}

.section-badge {
    font-size: 0.7rem;
    margin-right: 10px;
    font-weight: 500;
    padding: 0.35em 0.65em;
}

/* Complication Card Styling */
.complication-card {
    margin-bottom: 5px;
    border: 1px solid #dee2e6;
    border-radius: 8px;
    overflow: hidden;
}

.complication-card .collapsible-header {
    background: linear-gradient(135deg, #f8f9fa, #e9ecef);
    border-bottom: 1px solid #dee2e6;
}

.complication-card .collapsible-header:hover {
    background: linear-gradient(135deg, #e9ecef, #dee2e6);
}

/* Complication count badges */
#lastComplicationCount, #presentComplicationCount {
    font-size: 0.8rem;
    font-weight: 600;
}

/* Complication section specific styles */
.complication-card .card-body {
    background-color: #fafafa;
}

.complication-card .form-label {
    font-weight: 500;
    color: #495057;
    margin-bottom: 0.5rem;
}

/* Placeholder Styling */
.form-control::placeholder {
    color: #6c757d;
    opacity: 0.7;
    font-weight: normal !important;
    font-style: italic;
}

.form-control:focus::placeholder {
    color: #999;
    opacity: 0.5;
}

/* Form text styling */
.form-text.small {
    font-size: 0.75rem;
    margin-top: 0.25rem;
    color: #6c757d;
    font-style: italic;
}

/* Better alignment for header content */
.collapsible-header .d-flex.align-items-center {
    gap: 8px;
}

/* Smooth transitions for complication sections */
.complication-card .collapse {
    transition: all 0.3s ease-in-out;
}

/* Header styling for complication sections */
.complication-card .card-header {
    font-weight: 600;
    padding: 1rem 1.25rem;
}

/* Better spacing for complication rows */
.complication-card .row {
    margin-left: -0.5rem;
    margin-right: -0.5rem;
}

.complication-card .col-md-6 {
    padding-left: 0.5rem;
    padding-right: 0.5rem;
}

/* Auto-search specific styles */
.auto-search-container {
    position: relative;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 0.375rem 0.375rem;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.search-result-item {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid #f8f9fa;
    cursor: pointer;
    transition: background-color 0.2s;
}

.search-result-item:hover {
    background-color: #f8f9fa;
}

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

.search-result-item.active {
    background-color: #007bff;
    color: white;
}

/* Field group styling with status */
.field-group {
    margin-bottom: 1rem;
    padding: 1rem;
    border-radius: 0.5rem;
    border: 1px solid transparent;
    transition: all 0.3s ease;
}

.field-group.editable {
    border-color: #d4edda;
    background-color: rgba(212, 237, 218, 0.1);
}

.field-group.readonly {
    border-color: #fff3cd;
    background-color: rgba(255, 243, 205, 0.1);
}

/* Record status badge */
.record-status-badge {
    font-size: 0.8rem;
    padding: 0.4rem 0.8rem;
    border-radius: 1rem;
}

/* PW ID input specific styling */
.pw-id-input-group {
    position: relative;
}

.pw-id-loading {
    position: absolute;
    right: 80px;
    top: 50%;
    transform: translateY(-50%);
}

/* Validation styles */
.is-valid {
    border-color: #28a745 !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%2328a745' d='M2.3 6.73L.6 4.53c-.4-1.04.46-1.4 1.1-.8l1.1 1.4 3.4-3.8c.6-.63 1.6-.27 1.2.7l-4 4.6c-.43.5-.8.4-1.1.1z'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

.is-invalid {
    border-color: #dc3545 !important;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 12' width='12' height='12' fill='none' stroke='%23dc3545'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath d='m5.8 3.6.4.4.4-.4'/%3e%3cpath d='M6 7v1'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right calc(0.375em + 0.1875rem) center;
    background-size: calc(0.75em + 0.375rem) calc(0.75em + 0.375rem);
}

/* Field focus effects */
.form-control:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 0.2rem rgba(13, 110, 253, 0.15);
}

/* Mobile Responsive Enhancements */
@media (max-width: 768px) {
    .form-section {
        padding: 1rem;
        margin-bottom: 1rem;
        border-radius: 8px;
    }
    
    .radio-group {
        gap: 0.5rem;
        justify-content: flex-start;
    }
    
    .radio-option {
        min-width: 70px;
        flex: 0 0 auto;
    }
    
    .user-info {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }
    
    .alert-container {
        left: 10px;
        right: 10px;
        min-width: auto;
    }
    
    .card-body {
        padding: 1rem;
    }
    
    .btn-lg {
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }
    
    /* Stack columns on mobile */
    .col-md-6, .col-md-4, .col-md-3 {
        margin-bottom: 1rem;
    }
    
    /* Complications section mobile optimization */
    .card .row .col-md-6 {
        margin-bottom: 1.5rem;
    }
    
    .card .row .col-md-6 .form-label {
        font-size: 0.9rem;
        margin-bottom: 0.5rem;
        font-weight: 500;
    }
    
    /* Complication dropdowns on mobile */
    .complication-dropdown {
        font-size: 14px !important;
    }
    
    /* Checkup header mobile */
    .collapsible-header .fw-bold {
        font-size: 0.9rem;
    }
    
    .section-badge {
        font-size: 0.65rem;
        margin-right: 8px;
    }
    
    .collapsible-header {
        padding: 12px 15px;
    }
    
    /* Complication card mobile */
    .complication-card .col-md-6 {
        margin-bottom: 1rem;
    }
    
    .complication-card .form-label {
        font-size: 0.9rem;
    }
    
    #lastComplicationCount, #presentComplicationCount {
        font-size: 0.75rem;
    }
    
    /* Status indicators mobile */
    .status-indicator {
        font-size: 0.7rem;
        padding: 0.3rem 0.6rem;
    }
    
    .field-group {
        padding: 0.75rem;
    }
}

@media (max-width: 576px) {
    .container {
        padding-left: 10px;
        padding-right: 10px;
    }
    
    .form-section {
        margin-left: -5px;
        margin-right: -5px;
        border-radius: 0;
    }
    
    .card {
        border: none;
        border-radius: 0;
        margin-bottom: 1rem;
    }
    
    .card-header {
        border-radius: 0 !important;
        padding: 0.75rem 1rem;
        font-size: 0.95rem;
    }
    
    /* Radio buttons mobile optimization */
    .radio-group {
        gap: 0.75rem;
    }
    
    .radio-option {
        min-width: 60px;
    }
    
    .form-check-label {
        font-size: 0.85rem;
    }
    
    /* Submit buttons stack on mobile */
    .text-center .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .text-center .btn + .btn {
        margin-left: 0 !important;
    }
    
    /* Auto-search mobile */
    .search-results {
        position: fixed;
        top: auto;
        left: 10px;
        right: 10px;
        max-height: 150px;
    }
}

/* Card enhancements */
.card {
    border: none;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    margin-bottom: 1.5rem;
    border-radius: 10px;
}

.card-header {
    border-radius: 10px 10px 0 0 !important;
    font-weight: 600;
}

/* Form control enhancements */
.form-control, .form-select {
    border-radius: 8px;
    border: 1px solid #ddd;
    padding: 0.75rem;
    font-weight: bold !important;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 0.2rem rgba(52, 152, 219, 0.15);
}

/* Input group enhancements */
.input-group-text {
    background-color: #f8f9fa;
    border-color: #ddd;
}

/* Button enhancements */
.btn {
    border-radius: 8px;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-lg {
    padding: 0.875rem 2rem;
    font-size: 1.1rem;
}

/* Complications section specific styles */
.complication-item {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
    border-left: 4px solid var(--primary-color);
}

/* Footer */
footer {
    border-top: 1px solid #dee2e6;
    margin-top: auto;
}

/* Print styles */
@media print {
    .btn, .alert-container, footer {
        display: none !important;
    }
    
    .card {
        border: 1px solid #000 !important;
        box-shadow: none !important;
    }
    
    .readonly-field {
        background-color: transparent !important;
        border: 1px solid #ccc !important;
    }
}

/* Enhanced radio buttons for better mobile touch */
.form-check-input {
    width: 1.2em;
    height: 1.2em;
    margin-top: 0.15em;
}

.form-check-label {
    margin-left: 0.3em;
    user-select: none;
}

/* Compact complications layout for mobile */
@media (max-width: 768px) {
    .complication-grid {
        display: grid;
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .complication-item {
        margin-bottom: 0.5rem;
        padding: 0.75rem;
    }
}

/* Animation for collapsible sections */
.collapse {
    transition: all 0.3s ease-in-out;
}

/* Hover effects for better UX */
.card:hover {
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transform: translateY(-2px);
    transition: all 0.3s ease;
}

/* Loading states */
.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Success states */
.success-state {
    border-color: #28a745 !important;
    background-color: #f8fff9 !important;
}

/* Custom scrollbar for better UX */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Pulse animation for loading states */
@keyframes pulse {
    0% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
    100% {
        opacity: 1;
    }
}

.pulse {
    animation: pulse 2s infinite;
}

/* Focus states for accessibility */
.form-control:focus-visible,
.form-select:focus-visible,
.btn:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .readonly-field {
        border: 2px dashed #000 !important;
    }
    
    .data-populated {
        border: 2px solid #000 !important;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .collapse,
    .btn,
    .form-control,
    .form-select {
        transition: none;
    }
    
    .loading-spinner {
        animation: none;
    }
}