/* Medical Intake Booth - Styles */

:root {
    --primary-color: #2196f3;
    --primary-dark: #1976d2;
    --primary-light: #e3f2fd;
    --success-color: #4caf50;
    --danger-color: #f44336;
    --warning-color: #ff9800;
    --text-primary: #212121;
    --text-secondary: #757575;
    --background: #f5f5f5;
    --surface: #ffffff;
    --border: #e0e0e0;
    --shadow: rgba(0, 0, 0, 0.1);
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --border-color: var(--border);
    --accent: var(--primary-color);
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 2px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
header {
    text-align: center;
    padding: 30px 0;
    background: var(--surface);
    border-radius: 12px;
    margin-bottom: 30px;
    box-shadow: 0 2px 8px var(--shadow);
}

.header-banner {
    width: 100%;
    max-width: 1200px;
    height: auto;
    border-radius: 8px;
    margin-bottom: 15px;
}

header h1 {
    font-size: 2.5em;
    color: var(--primary-color);
    margin-bottom: 10px;
}

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.subtitle {
    color: var(--text-secondary);
    font-size: 1.1em;
}

/* Main Content */
.main-content {
    background: var(--surface);
    border-radius: 12px;
    padding: 30px;
    box-shadow: 0 2px 8px var(--shadow);
}

/* Status Panel */
.status-panel {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: var(--primary-light);
    border-radius: 8px;
    margin-bottom: 30px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--text-secondary);
    animation: pulse 2s infinite;
}

.status-indicator.active .status-dot {
    background: var(--success-color);
}

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

/* Loading state for avatar */
.status-indicator.loading .status-dot {
    background: #ff9800;
    animation: loading-pulse 0.8s infinite;
}

.status-indicator.loading #statusText {
    color: #ff9800;
}

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

.session-info {
    font-size: 0.9em;
    color: var(--text-secondary);
}

/* ==================== Doctor 11-17 Interface ==================== */
.agent-interface {
    display: flex;
    gap: 20px;
    background: var(--surface);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 2px 8px var(--shadow);
    min-height: 500px;
}

/* Avatar Panel (Left Side) */
.avatar-panel {
    width: 400px;
    min-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px 10px;
    background: linear-gradient(135deg, var(--primary-light) 0%, var(--surface) 100%);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.avatar-panel .avatar-container {
    width: 100%;
    height: 500px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border-radius: 8px;
    overflow: hidden;
}

.avatar-static {
    animation: float 3s ease-in-out infinite;
}

@keyframes float {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

.avatar-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
}

.avatar-name {
    margin-top: 15px;
    font-size: 1em;
    font-weight: 600;
    color: var(--primary-dark);
    text-align: center;
}

/* HeyGen Toggle Switch */
.heygen-toggle {
    margin-top: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.toggle-switch {
    position: relative;
    width: 50px;
    height: 26px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 26px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: var(--primary-color);
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(24px);
}

.toggle-label {
    font-size: 0.75em;
    color: var(--text-secondary);
    text-align: center;
}

/* Chat Interface (Right Side) */
.chat-interface {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Agent Message Area */
.agent-message-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--background);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.agent-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: var(--primary-light);
    border-bottom: 1px solid var(--border);
}

.agent-icon {
    font-size: 1.4em;
}

.agent-title {
    font-weight: 600;
    color: var(--primary-dark);
    flex: 1;
}

.agent-header .status-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85em;
    padding: 0;
    background: transparent;
}

.agent-header .status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success-color);
    animation: pulse 2s infinite;
}

.agent-message-box {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    min-height: 200px;
}

.agent-message {
    font-size: 1.05em;
    line-height: 1.6;
    color: var(--text-primary);
    margin: 0;
}

.agent-message .icon-link {
    text-decoration: none;
    cursor: pointer;
    display: inline-block;
    transition: transform 0.2s ease;
    font-size: 1.1em;
}

.agent-message .icon-link:hover {
    transform: scale(1.3);
    filter: brightness(1.2);
}

/* Quick Response Buttons */
.quick-responses {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 20px;
}

.quick-response-btn {
    padding: 12px 20px;
    background: var(--surface);
    border: 2px solid var(--primary-color);
    border-radius: 25px;
    color: var(--primary-color);
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.quick-response-btn .btn-icon {
    margin-right: 8px;
}

/* User Input Area */
.user-input-area {
    background: var(--background);
    border-radius: 12px;
    border: 1px solid var(--border);
    overflow: hidden;
}

.user-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 16px;
    background: #f0f0f0;
    border-bottom: 1px solid var(--border);
}

.user-icon {
    font-size: 1.2em;
}

.user-title {
    font-weight: 600;
    color: var(--text-primary);
}

.user-input-box {
    padding: 16px;
}

.user-input-box textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1em;
    font-family: inherit;
    resize: none;
    transition: border-color 0.2s;
}

.user-input-box textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.input-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 12px;
}

/* Legacy Avatar Container (for other uses) */
.avatar-placeholder {
    display: inline-block;
}

.avatar-label {
    margin-top: 20px;
    font-size: 1.1em;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Conversation Container */
.conversation-container {
    margin-bottom: 30px;
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.conversation-header h2 {
    color: var(--text-primary);
    font-size: 1.5em;
}

.btn-clear {
    padding: 8px 16px;
    background: var(--text-secondary);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.3s;
}

.btn-clear:hover {
    background: var(--text-primary);
}

.conversation-box {
    height: 400px;
    overflow-y: auto;
    padding: 20px;
    background: var(--background);
    border-radius: 8px;
    border: 1px solid var(--border);
}

/* Messages */
.message {
    margin-bottom: 20px;
    padding: 15px;
    border-radius: 8px;
    animation: slideIn 0.3s ease-out;
}

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

.message-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.timestamp {
    font-size: 0.85em;
    color: var(--text-secondary);
}

.patient-message {
    background: var(--primary-light);
    border-left: 4px solid var(--primary-color);
}

.assistant-message {
    background: #f1f8e9;
    border-left: 4px solid var(--success-color);
}

.system-message {
    background: #fff3e0;
    border-left: 4px solid var(--warning-color);
    font-style: italic;
    color: var(--text-secondary);
}

/* Controls Container */
.controls-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Input Section */
.input-section {
    width: 100%;
}

.input-group {
    display: flex;
    gap: 10px;
}

.input-group input {
    flex: 1;
    padding: 12px 20px;
    font-size: 1em;
    border: 2px solid var(--border);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.3s;
}

.input-group input:focus {
    border-color: var(--primary-color);
}

.input-group input:disabled {
    background: var(--background);
    cursor: not-allowed;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    font-size: 1em;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    white-space: nowrap;
}

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

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

.btn-send:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow);
}

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

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow);
}

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

.btn-danger:hover:not(:disabled) {
    background: #d32f2f;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px var(--shadow);
}

/* Audio Section */
.audio-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
    padding: 20px;
    background: var(--background);
    border-radius: 8px;
}

.btn-record {
    background: var(--success-color);
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 15px 30px;
}

.btn-record:hover:not(:disabled) {
    background: #45a049;
}

.btn-record.recording {
    background: var(--danger-color);
    animation: recordPulse 1s infinite;
}

@keyframes recordPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(244, 67, 54, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(244, 67, 54, 0);
    }
}

.record-icon {
    font-size: 1.2em;
}

/* Audio Visualizer */
.audio-visualizer {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    height: 60px;
    gap: 3px;
}

.visualizer-bar {
    width: 4px;
    min-height: 5%;
    background: var(--primary-color);
    border-radius: 2px;
    transition: height 0.1s ease;
}

/* Session Controls */
.session-controls {
    display: flex;
    justify-content: center;
    gap: 20px;
}

/* Settings Panel */
.settings-panel {
    margin-top: 30px;
    padding: 20px;
    background: var(--background);
    border-radius: 8px;
}

.settings-panel summary {
    cursor: pointer;
    font-weight: 600;
    font-size: 1.1em;
    padding: 10px;
    user-select: none;
}

.settings-panel summary:hover {
    color: var(--primary-color);
}

.settings-content {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.setting-item {
    display: flex;
    align-items: center;
    gap: 15px;
}

.setting-item label {
    font-weight: 500;
    min-width: 80px;
}

.setting-item select {
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 1em;
    cursor: pointer;
    outline: none;
}

.setting-item select:focus {
    border-color: var(--primary-color);
}

.setting-item input[type="range"] {
    flex: 1;
    max-width: 200px;
}

/* Footer */
footer {
    text-align: center;
    padding: 30px 0;
    margin-top: 30px;
    color: var(--text-secondary);
    font-size: 0.9em;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    gap: 20px;
    z-index: 1000;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--primary-light);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-overlay p {
    color: white;
    font-size: 1.2em;
    font-weight: 600;
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 10px;
    }

    header {
        padding: 20px 15px;
        margin-bottom: 15px;
    }

    header h1 {
        font-size: 1.5em;
    }

    header .subtitle {
        font-size: 0.9em;
    }

    .tab-nav {
        gap: 5px;
        margin-top: 15px;
    }

    .tab-btn {
        padding: 10px 16px;
        font-size: 0.9em;
    }

    .main-content {
        padding: 20px;
    }

    .status-panel {
        flex-direction: column;
        gap: 15px;
    }

    .conversation-box {
        height: 300px;
    }

    .session-controls {
        flex-direction: column;
    }

    .btn {
        width: 100%;
    }

    /* Agent Interface - Mobile Layout */
    .agent-interface {
        flex-direction: column;
        padding: 15px;
        gap: 15px;
        min-height: auto;
    }

    .avatar-panel {
        width: 100%;
        min-width: 100%;
        padding: 15px;
        order: -1; /* Keep avatar on top */
    }

    .avatar-panel .avatar-container {
        height: 250px; /* Smaller on mobile */
    }

    .avatar-name {
        font-size: 0.95em;
        margin-top: 10px;
    }

    .heygen-toggle {
        margin-top: 10px;
    }

    .chat-interface {
        width: 100%;
        gap: 10px;
    }

    .agent-header {
        padding: 10px 12px;
    }

    .agent-icon {
        font-size: 1.2em;
    }

    .agent-title {
        font-size: 0.95em;
    }

    .agent-message-box {
        padding: 15px;
        min-height: 150px;
    }

    .agent-message {
        font-size: 1em;
        line-height: 1.5;
    }

    .quick-responses {
        gap: 8px;
        margin-top: 12px;
    }

    .quick-response-btn {
        padding: 10px 14px;
        font-size: 0.9em;
    }

    .user-input-area {
        margin-top: 10px;
    }

    .user-header {
        padding: 10px 12px;
    }

    .user-input-box {
        padding: 12px;
    }

    .user-input-box textarea {
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 10px;
    }

    .input-actions {
        flex-direction: row;
        gap: 8px;
    }

    .input-actions .btn {
        flex: 1;
        padding: 12px;
    }

    /* Modal adjustments for mobile */
    .modal {
        width: 95%;
        max-width: none;
        margin: 10px;
        max-height: 90vh;
    }

    .modal-header {
        padding: 12px 16px;
    }

    .modal-header h2 {
        font-size: 1.1em;
    }

    .modal-body {
        padding: 15px;
    }

    .modal-footer {
        padding: 12px 16px;
        flex-direction: column;
        gap: 8px;
    }

    .modal-footer .btn {
        width: 100%;
    }

    .print-preview {
        padding: 15px;
        max-height: 50vh;
    }

    /* Map modal on mobile */
    #locationMap {
        height: 300px !important;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    header h1 {
        font-size: 1.3em;
    }

    .avatar-panel .avatar-container {
        height: 200px;
    }

    .quick-responses {
        flex-direction: column;
    }

    .quick-response-btn {
        width: 100%;
        justify-content: center;
    }

    .tab-btn {
        padding: 8px 12px;
        font-size: 0.85em;
    }
}

/* Scrollbar Styling */
.conversation-box::-webkit-scrollbar {
    width: 8px;
}

.conversation-box::-webkit-scrollbar-track {
    background: var(--border);
    border-radius: 4px;
}

.conversation-box::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.conversation-box::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* ==================== Tab Navigation ==================== */
.tab-nav {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-top: 20px;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 12px 24px;
    font-size: 1em;
    font-weight: 600;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s;
}

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

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

.tab-content {
    display: none;
    animation: fadeIn 0.3s ease-out;
}

.tab-content.active {
    display: block;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* ==================== Facilities Tab ==================== */
.facilities-stats {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.stat-card {
    flex: 1;
    min-width: 150px;
    padding: 20px;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    text-align: center;
}

.stat-value {
    display: block;
    font-size: 2.5em;
    font-weight: 700;
    color: var(--primary-color);
    line-height: 1;
}

.stat-label {
    display: block;
    margin-top: 8px;
    font-size: 0.9em;
    color: var(--text-secondary);
}

/* Facilities Toolbar */
.facilities-toolbar {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
    padding: 20px;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
}

.search-box {
    flex: 1;
    min-width: 200px;
}

.search-box input {
    width: 100%;
    padding: 12px 16px;
    font-size: 1em;
    border: 2px solid var(--border);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.3s;
}

.search-box input:focus {
    border-color: var(--primary-color);
}

.filter-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.filter-group select {
    padding: 10px 14px;
    font-size: 0.95em;
    border: 2px solid var(--border);
    border-radius: 8px;
    background: var(--surface);
    cursor: pointer;
    outline: none;
    min-width: 130px;
}

.filter-group select:focus {
    border-color: var(--primary-color);
}

.action-buttons {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

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

.btn-secondary:hover:not(:disabled) {
    background: var(--text-primary);
}

/* Facilities Table */
.facilities-table-container {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
    overflow-x: auto;
    margin-bottom: 20px;
}

.facilities-table {
    width: 100%;
    border-collapse: collapse;
}

.facilities-table th,
.facilities-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

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

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

.facilities-table .table-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
    font-style: italic;
}

.type-badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 0.85em;
    font-weight: 500;
    border-radius: 20px;
    background: var(--primary-light);
    color: var(--primary-dark);
    text-transform: capitalize;
}

.verified-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    font-size: 0.85em;
    border-radius: 20px;
}

.verified-badge.verified {
    background: #e8f5e9;
    color: #2e7d32;
}

.verified-badge.unverified {
    background: #fff3e0;
    color: #ef6c00;
}

.action-btn {
    padding: 6px 10px;
    font-size: 0.85em;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-right: 5px;
    transition: all 0.2s;
}

.action-btn.edit {
    background: var(--primary-light);
    color: var(--primary-dark);
}

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

.action-btn.delete {
    background: #ffebee;
    color: var(--danger-color);
}

.action-btn.delete:hover {
    background: var(--danger-color);
    color: white;
}

.action-btn.verify {
    background: #e8f5e9;
    color: #2e7d32;
}

.action-btn.verify:hover {
    background: #4caf50;
    color: white;
}

/* Directions Link */
.directions-link {
    display: inline-block;
    margin-left: 8px;
    text-decoration: none;
    font-size: 1.1em;
    opacity: 0.7;
    transition: all 0.2s ease;
}

.directions-link:hover {
    opacity: 1;
    transform: scale(1.2);
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 20px;
    padding: 20px;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
}

#pageInfo {
    font-weight: 500;
    color: var(--text-secondary);
}

/* ==================== Scraper Tab ==================== */
.scraper-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.scraper-panel {
    padding: 24px;
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 2px 8px var(--shadow);
}

.scraper-panel h2 {
    font-size: 1.3em;
    color: var(--text-primary);
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--border);
}

.scraper-panel.scraper-history {
    grid-column: 1 / -1;
}

.scraper-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group label {
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    padding: 10px 14px;
    font-size: 1em;
    border: 2px solid var(--border);
    border-radius: 8px;
    outline: none;
    transition: border-color 0.3s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary-color);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
}

.checkbox-group {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
    border: 2px solid var(--border);
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 400;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.checkbox-group label:hover {
    background: var(--bg-primary);
}

.checkbox-group input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.location-counts {
    font-weight: 400;
    font-size: 0.9em;
    color: var(--text-secondary, #666);
}

.locations-group {
    max-height: 500px;
    overflow-y: auto;
}

.checkbox-group .location-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
}

.checkbox-group .location-item .location-label {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
}

.checkbox-group .remove-btn {
    background: none;
    border: none;
    color: var(--danger-color, #dc3545);
    cursor: pointer;
    padding: 2px 6px;
    font-size: 1.1em;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.checkbox-group .remove-btn:hover {
    opacity: 1;
}

.checkbox-controls,
.location-controls {
    display: flex;
    gap: 8px;
    margin-top: 8px;
    align-items: center;
}

.location-controls input {
    flex: 1;
    padding: 8px 12px;
    border: 2px solid var(--border);
    border-radius: 6px;
    font-size: 0.9em;
}

.btn-small {
    padding: 6px 12px;
    font-size: 0.85em;
}

.btn-secondary {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 2px solid var(--border);
}

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

.scraper-actions {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

/* Scraper Status */
.scraper-status {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.status-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: var(--background);
    border-radius: 8px;
}

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

.status-row .status-value {
    font-weight: 600;
    color: var(--text-primary);
}

.progress-bar-container {
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
}

/* Scraper Activity Log */
.scraper-activity {
    margin-top: 20px;
    border-top: 1px solid var(--border);
    padding-top: 16px;
}

.scraper-activity h3 {
    font-size: 0.95em;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.activity-log {
    max-height: 150px;
    overflow-y: auto;
    background: var(--background);
    border-radius: 8px;
    padding: 10px;
    font-family: monospace;
    font-size: 0.85em;
}

.activity-log .activity-empty {
    color: var(--text-secondary);
    font-style: italic;
}

.activity-log .activity-item {
    padding: 4px 0;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 10px;
}

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

.activity-log .activity-time {
    color: var(--text-secondary);
    flex-shrink: 0;
}

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

.activity-log .activity-message.success {
    color: #2e7d32;
}

.activity-log .activity-message.error {
    color: #c62828;
}

.activity-log .activity-message.info {
    color: #1565c0;
}

/* Jobs Table */
.jobs-table {
    width: 100%;
    border-collapse: collapse;
}

.jobs-table th,
.jobs-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.jobs-table th {
    background: var(--background);
    font-weight: 600;
    color: var(--text-secondary);
}

.jobs-table .table-empty {
    text-align: center;
    padding: 30px;
    color: var(--text-secondary);
    font-style: italic;
}

.status-tag {
    display: inline-block;
    padding: 4px 10px;
    font-size: 0.85em;
    font-weight: 500;
    border-radius: 20px;
    text-transform: capitalize;
}

.status-tag.running {
    background: #e3f2fd;
    color: #1565c0;
}

.status-tag.completed {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-tag.failed {
    background: #ffebee;
    color: #c62828;
}

/* Scraper Stats Panel */
.scraper-stats-panel {
    grid-column: 1 / -1;
}

.stats-total {
    font-weight: 400;
    font-size: 0.85em;
    color: var(--primary-color);
}

.scrape-summary {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding: 12px;
    background: var(--background);
    border-radius: 8px;
}

.scrape-summary .summary-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.scrape-summary .summary-label {
    font-size: 0.8em;
    color: var(--text-secondary);
}

.scrape-summary .summary-value {
    font-weight: 600;
    color: var(--text-primary);
}

.stats-table-container {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.stats-table th,
.stats-table td {
    padding: 10px 12px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.stats-table th:first-child,
.stats-table td:first-child {
    text-align: left;
    position: sticky;
    left: 0;
    background: var(--bg-secondary);
}

.stats-table th {
    background: var(--background);
    font-weight: 600;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
    z-index: 1;
}

.stats-table th:first-child {
    z-index: 2;
}

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

.stats-table .count-cell {
    font-weight: 500;
}

.stats-table .count-cell.has-data {
    color: var(--primary-color);
}

.stats-table .count-cell.no-data {
    color: var(--text-secondary);
    opacity: 0.5;
}

.stats-table .total-cell {
    font-weight: 700;
    color: var(--text-primary);
}

.stats-table .table-empty {
    text-align: center;
    padding: 30px;
    color: var(--text-secondary);
    font-style: italic;
}

.status-tag.pending {
    background: #fff3e0;
    color: #ef6c00;
}

/* ==================== Modal ==================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--surface);
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalSlideIn 0.3s ease-out;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.modal-header h2 {
    font-size: 1.4em;
    color: var(--text-primary);
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.8em;
    color: var(--text-secondary);
    cursor: pointer;
    line-height: 1;
    padding: 0;
    transition: color 0.2s;
}

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

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    background: var(--background);
}

/* ==================== Duplicates Modal ==================== */
.modal.modal-large {
    max-width: 800px;
}

.duplicates-help {
    margin-bottom: 20px;
    color: var(--text-secondary);
    font-size: 0.95em;
}

.duplicates-help strong {
    color: var(--success-color);
}

.no-duplicates {
    text-align: center;
    padding: 40px;
    color: var(--success-color);
    font-size: 1.1em;
}

.duplicate-group {
    border: 1px solid var(--border);
    border-radius: 8px;
    margin-bottom: 16px;
    overflow: hidden;
}

.duplicate-group-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    background: var(--primary-light);
    border-bottom: 1px solid var(--border);
}

.duplicate-count {
    font-size: 0.85em;
    color: var(--text-secondary);
    background: var(--surface);
    padding: 4px 10px;
    border-radius: 12px;
}

.duplicate-items {
    padding: 8px;
}

.duplicate-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.duplicate-item:hover {
    background: var(--background);
}

.duplicate-item input[type="checkbox"] {
    margin-top: 4px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.duplicate-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.duplicate-name {
    font-weight: 600;
    color: var(--text-primary);
}

.duplicate-info {
    font-size: 0.9em;
    color: var(--text-secondary);
}

.duplicate-meta {
    font-size: 0.8em;
    color: var(--text-secondary);
    opacity: 0.8;
}

#duplicatesContent .loading {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

#duplicatesContent .error {
    color: var(--danger-color);
    padding: 20px;
    text-align: center;
}

/* ==================== Print & Email Modals ==================== */
.print-modal,
.email-modal {
    max-width: 700px;
}

.print-preview {
    background: white;
    padding: 30px;
    border: 1px solid var(--border);
    border-radius: 8px;
    max-height: 60vh;
    overflow-y: auto;
}

.print-preview .header {
    text-align: center;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.print-preview .header h1 {
    color: var(--primary-dark);
    font-size: 1.5em;
    margin: 0;
}

.print-preview .header p {
    color: var(--text-secondary);
    margin: 5px 0 0;
}

.print-preview .date {
    text-align: right;
    color: var(--text-secondary);
    font-size: 0.85em;
    margin-bottom: 15px;
}

.print-preview .patient-info {
    background: var(--background);
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 20px;
}

.print-preview h2 {
    font-size: 1.1em;
    color: var(--primary-dark);
    margin-bottom: 12px;
}

.print-preview .facility {
    border: 1px solid var(--border);
    padding: 16px;
    margin-bottom: 12px;
    border-radius: 8px;
}

.print-preview .facility h3 {
    margin: 0 0 8px;
    color: var(--primary-dark);
    font-size: 1.05em;
}

.print-preview .facility p {
    margin: 4px 0;
    color: var(--text-primary);
}

.print-preview .facility.emergency {
    background: #ffebee;
    border-color: var(--danger-color);
}

.print-preview .facility.emergency h3 {
    color: var(--danger-color);
}

.print-preview .advice-section {
    margin-bottom: 20px;
}

.print-preview .advice-section h2 {
    color: var(--primary-dark);
    font-size: 1.1em;
    margin-bottom: 10px;
}

.print-preview .advice-content {
    background: var(--primary-light);
    padding: 15px;
    border-radius: 8px;
    line-height: 1.6;
}

.print-preview .footer {
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px solid var(--border);
    font-size: 0.85em;
    color: var(--text-secondary);
    text-align: center;
}

.email-modal .form-group {
    margin-bottom: 16px;
}

.email-modal .form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: var(--text-primary);
}

.email-modal .form-group input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1em;
    transition: border-color 0.2s;
}

.email-modal .form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.1);
}

/* ==================== Location Map Modal ==================== */
.map-modal-body {
    padding: 16px;
}

.map-help {
    margin-bottom: 12px;
    color: var(--text-secondary);
    font-size: 0.95em;
}

.map-search {
    margin-bottom: 12px;
}

.map-search input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 1em;
}

.map-search input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.location-map {
    height: 350px;
    border-radius: 8px;
    border: 1px solid var(--border);
    margin-bottom: 12px;
    z-index: 1;
}

.map-location-list {
    max-height: 150px;
    overflow-y: auto;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px;
    background: var(--background);
    border-radius: 8px;
    border: 1px solid var(--border);
}

.map-location-btn {
    padding: 8px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 0.85em;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.map-location-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
}

.map-location-btn.first-nation {
    background: #fff3e0;
    border-color: #ffb74d;
}

.map-location-btn.first-nation:hover {
    background: #ffe0b2;
}

/* Leaflet popup customization */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
}

.leaflet-popup-content {
    margin: 10px 12px;
    font-size: 0.95em;
}

.location-popup {
    text-align: center;
}

.location-popup h4 {
    margin: 0 0 8px 0;
    color: var(--primary-dark);
}

.location-popup button {
    padding: 6px 16px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9em;
}

.location-popup button:hover {
    background: var(--primary-dark);
}

/* Location tooltip on hover */
.location-tooltip {
    background: white;
    border: none;
    border-radius: 8px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
    padding: 8px 12px;
    font-size: 0.9em;
}

.location-tooltip strong {
    color: var(--primary-dark);
}

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

/* ==================== Responsive Adjustments ==================== */
@media (max-width: 768px) {
    .tab-nav {
        gap: 8px;
    }

    .tab-btn {
        padding: 10px 16px;
        font-size: 0.9em;
    }

    .facilities-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .filter-group {
        width: 100%;
    }

    .filter-group select {
        flex: 1;
    }

    .action-buttons {
        width: 100%;
        justify-content: stretch;
    }

    .action-buttons .btn {
        flex: 1;
    }

    .scraper-container {
        grid-template-columns: 1fr;
    }

    .facilities-table th,
    .facilities-table td {
        padding: 10px 12px;
        font-size: 0.9em;
    }

    .modal {
        max-height: 95vh;
        margin: 10px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

/* Video Modal Styles */
.btn-video {
    margin-top: 12px;
    background: linear-gradient(135deg, #e91e63, #c2185b);
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 25px;
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 8px rgba(233, 30, 99, 0.3);
}

.btn-video:hover {
    background: linear-gradient(135deg, #c2185b, #ad1457);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(233, 30, 99, 0.4);
}

.btn-video .btn-icon {
    font-size: 0.9em;
}

.video-modal-overlay {
    cursor: pointer;
}

.video-modal {
    max-width: 900px;
    width: 90%;
    padding: 0;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    cursor: default;
}

.video-container {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%; /* 16:9 aspect ratio */
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.video-hint {
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    padding: 12px;
    margin: 0;
    font-size: 0.85em;
}

@media (max-width: 768px) {
    .btn-video {
        padding: 8px 18px;
        font-size: 0.9em;
    }

    .video-modal {
        width: 95%;
        margin: 10px;
    }
}

/* Disclaimer Modal & Button */
.disclaimer-btn {
    background: transparent !important;
    border: 1px solid #f59e0b !important;
    color: #f59e0b !important;
}

.disclaimer-btn:hover {
    background: rgba(245, 158, 11, 0.1) !important;
}

.disclaimer-modal {
    max-width: 700px;
    max-height: 85vh;
}

.disclaimer-content {
    line-height: 1.7;
}

.disclaimer-content h4 {
    color: var(--primary-color);
    margin: 20px 0 10px 0;
    font-size: 1.1em;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 5px;
}

.disclaimer-content h4:first-child {
    margin-top: 0;
}

.disclaimer-content p {
    margin: 10px 0;
    color: var(--text-secondary);
}

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

.disclaimer-footer {
    margin-top: 25px;
    padding-top: 15px;
    border-top: 2px solid var(--border-color);
    text-align: center;
    color: var(--text-secondary);
}

/* Categorized Search Terms */
.search-term-category {
    margin-bottom: 15px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}

.category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
}

.category-header:hover {
    background: rgba(26, 115, 232, 0.05);
}

.category-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
}

.category-toggle input {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.category-count {
    font-size: 0.85em;
    color: var(--text-secondary);
}

.category-terms {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 5px;
    padding: 10px 15px;
    background: var(--background);
}

.term-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
}

.term-item:hover {
    background: rgba(26, 115, 232, 0.08);
}

.term-item:hover .term-remove-btn {
    opacity: 1;
}

.term-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9em;
    flex: 1;
}

.term-label input {
    cursor: pointer;
}

.term-remove-btn {
    background: none;
    border: none;
    color: #dc3545;
    font-size: 1.2em;
    font-weight: bold;
    cursor: pointer;
    padding: 0 5px;
    opacity: 0;
    transition: opacity 0.2s, transform 0.2s;
    line-height: 1;
}

.term-remove-btn:hover {
    transform: scale(1.3);
}

/* Select All / Deselect All buttons */
.term-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.term-actions button {
    padding: 6px 12px;
    font-size: 0.85em;
    border-radius: 4px;
    border: 1px solid var(--border-color);
    background: var(--surface);
    cursor: pointer;
    transition: all 0.2s;
}

.term-actions button:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* ==================== Scraper Sub-Tabs ==================== */
.sub-tab-nav {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 2px solid var(--border);
}

.sub-tab-btn {
    padding: 10px 20px;
    background: var(--surface);
    border: 2px solid var(--border);
    border-radius: 8px;
    font-size: 0.95em;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-secondary);
}

.sub-tab-btn:hover {
    background: var(--primary-light);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.sub-tab-btn.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.sub-tab-content {
    display: none;
}

.sub-tab-content.active {
    display: block;
}

/* Make Locations sub-tab panel full width */
#subtab-locations .scraper-panel {
    grid-column: 1 / -1;
}
