/* =============================================================================
   CUSTOM STYLES - DaVita Interview Application
   ============================================================================= */

/* -----------------------------------------------------------------------------
   CLIENT HIDDEN ELEMENTS (TEMPORARY)
   Remove the 'client-hidden' class from elements to unhide features.
   See HIDDEN.md in the project root for instructions.
   ----------------------------------------------------------------------------- */
.client-hidden {
    display: none !important;
}

/* -----------------------------------------------------------------------------
   Error Messages
   ----------------------------------------------------------------------------- */
.chat-error {
    background-color: #fee2e2;
    border: 1px solid #ef4444;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 10px 0;
    color: #991b1b;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
    animation: slideIn 0.3s ease-out;
}

.chat-error .error-icon {
    font-size: 18px;
    color: #dc2626;
}

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

/* -----------------------------------------------------------------------------
   Disabled Button States
   ----------------------------------------------------------------------------- */
#sendQuestion.disabled,
#sendQuestion:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

#sendQuestion {
    transition: opacity 0.2s ease;
}

/* -----------------------------------------------------------------------------
   Character Card Loading States
   ----------------------------------------------------------------------------- */
.characterCard.loading {
    position: relative;
    pointer-events: none;
}

.characterCard.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: inherit;
}

.characterCard.loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 30px;
    height: 30px;
    margin: -15px 0 0 -15px;
    border: 3px solid #e0e0e0;
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 1;
}

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

.characterCard.load-error {
    opacity: 0.6;
    border-color: #ef4444;
}

.characterCard.load-error::after {
    content: 'Failed to load';
    position: absolute;
    bottom: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: #ef4444;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
}

/* -----------------------------------------------------------------------------
   Character Load Error
   ----------------------------------------------------------------------------- */
.character-load-error {
    text-align: center;
    padding: 40px;
    color: #991b1b;
}

.character-load-error p {
    margin-bottom: 20px;
}

/* -----------------------------------------------------------------------------
   Screen Reader Only (Accessibility)
   ----------------------------------------------------------------------------- */
.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;
}

/* -----------------------------------------------------------------------------
   Focus States (Accessibility)
   ----------------------------------------------------------------------------- */
.btn:focus,
button:focus,
textarea:focus,
input:focus {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* Remove default focus outline since we're adding our own */
.btn:focus-visible,
button:focus-visible,
textarea:focus-visible,
input:focus-visible {
    outline: 2px solid #3498db;
    outline-offset: 2px;
}

/* -----------------------------------------------------------------------------
   Export Button
   ----------------------------------------------------------------------------- */
#exportInterview {
    background-color: #059669;
}

#exportInterview:hover {
    background-color: #047857;
}

/* -----------------------------------------------------------------------------
   Skip to Content Link (Accessibility)
   ----------------------------------------------------------------------------- */
.skip-link {
    position: absolute;
    top: -40px;
    left: 0;
    background: #000;
    color: #fff;
    padding: 8px;
    z-index: 100;
    transition: top 0.3s;
}

.skip-link:focus {
    top: 0;
}

/* -----------------------------------------------------------------------------
   Character Card Focus States
   ----------------------------------------------------------------------------- */
.characterCard:focus {
    outline: 3px solid #3498db;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.3);
}

.characterCard:focus-visible {
    outline: 3px solid #3498db;
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(52, 152, 219, 0.3);
}

/* -----------------------------------------------------------------------------
   High Contrast Mode Support
   ----------------------------------------------------------------------------- */
@media (prefers-contrast: high) {
    .chat-error {
        border-width: 2px;
    }

    .btn:focus,
    button:focus {
        outline-width: 3px;
    }
}

/* -----------------------------------------------------------------------------
   Reduced Motion Support
   ----------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
    .chat-error,
    .characterCard.loading::before {
        animation: none;
    }

    .characterCard.loading::before {
        border-top-color: #3498db;
        border-right-color: #3498db;
    }
}

/* =============================================================================
   GROUP CHAT SELECTION MODE STYLES
   ============================================================================= */

/* -----------------------------------------------------------------------------
   Character Selection Header
   ----------------------------------------------------------------------------- */
.characterSelectionHeader {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding: 0 10px;
}

.characterSelectionHeader .labelTitle {
    margin: 0;
}

#groupInterviewBtn {
    background-color: #e2e8f0;
    color: #1e293b;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 400;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

#groupInterviewBtn:hover {
    background-color: #cbd5e1;
    transform: translateY(-1px);
}

#groupInterviewBtn:active {
    transform: translateY(0);
}

/* -----------------------------------------------------------------------------
   Selection Mode Body State
   ----------------------------------------------------------------------------- */
.group-selection-mode #charactersContainer {
    position: relative;
}

.group-selection-mode .characterCard {
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.group-selection-mode .characterCard:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

/* -----------------------------------------------------------------------------
   Selected Character Card Styles
   ----------------------------------------------------------------------------- */
.characterCard.group-selected {
    border: 3px solid #22c55e;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.2);
    position: relative;
}

.characterCard.group-selected::before {
    content: '';
    position: absolute;
    top: 10px;
    right: 10px;
    width: 28px;
    height: 28px;
    background-color: #22c55e;
    border-radius: 50%;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.characterCard.group-selected::after {
    content: '';
    position: absolute;
    top: 16px;
    right: 18px;
    width: 8px;
    height: 14px;
    border: solid white;
    border-width: 0 3px 3px 0;
    transform: rotate(45deg);
    z-index: 11;
}

/* Ensure loading overlay doesn't interfere with selection checkmark */
.characterCard.group-selected.loading::after {
    content: '';
    background: rgba(255, 255, 255, 0.7);
    top: 0;
    right: 0;
    width: 100%;
    height: 100%;
    border: none;
    transform: none;
}

/* -----------------------------------------------------------------------------
   Group Selection UI Panel
   ----------------------------------------------------------------------------- */
#groupSelectionUI {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 10px 14px;
    margin: 10px auto 0 auto;
    max-width: 420px;
    display: none;
    animation: slideIn 0.3s ease-out;
}

.group-selection-mode #groupSelectionUI {
    display: block;
}

/* Top row: counter and toggle */
#groupSelectionTopRow {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

#groupSelectionCounter {
    font-size: 13px;
    font-weight: 500;
    color: #1e293b;
}

#groupSelectionButtons {
    display: flex;
    justify-content: center;
    gap: 10px;
}

#startGroupChatBtn {
    background-color: #dcfce7;
    color: #1e293b;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 400;
    border-radius: 6px;
    border: 1px solid #86efac;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

#startGroupChatBtn:hover:not(:disabled) {
    background-color: #bbf7d0;
}

#startGroupChatBtn:disabled {
    background-color: #f1f5f9;
    border-color: #cbd5e1;
    color: #94a3b8;
    cursor: not-allowed;
}

#cancelGroupSelectBtn {
    background-color: #f1f5f9;
    color: #1e293b;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 400;
    border-radius: 6px;
    border: 1px solid #cbd5e1;
    transition: background-color 0.2s ease;
}

#cancelGroupSelectBtn:hover {
    background-color: #e2e8f0;
}

/* -----------------------------------------------------------------------------
   Toggle Switch for Aware/Unaware Mode
   ----------------------------------------------------------------------------- */
#groupModeSelector {
    display: none;
}

.modeToggleContainer {
    display: flex;
    align-items: center;
    gap: 8px;
}

.modeToggleLabel {
    font-size: 12px;
    color: #64748b;
    transition: color 0.2s ease;
}

.modeToggleLabel.active {
    color: #1e293b;
    font-weight: 500;
}

.modeToggleSwitch {
    position: relative;
    width: 44px;
    height: 22px;
    background-color: #6366f1;
    border-radius: 11px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.modeToggleSwitch.unaware {
    background-color: #f59e0b;
}

.modeToggleSwitch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 18px;
    height: 18px;
    background-color: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.modeToggleSwitch.unaware::after {
    transform: translateX(22px);
}

/* -----------------------------------------------------------------------------
   Group Chat Active State
   ----------------------------------------------------------------------------- */
.group-chat-active #characterInfo {
    /* Styles for when group chat is active */
}

/* Hide the single character display when in group chat */
.group-chat-active #charPictureNoUnity {
    display: none;
}

/* -----------------------------------------------------------------------------
   Secondary Button Style
   ----------------------------------------------------------------------------- */
.btn.btnSecondary {
    background-color: #64748b;
}

.btn.btnSecondary:hover {
    background-color: #475569;
}

/* =============================================================================
   GROUP INTERVIEW PANEL STYLES
   ============================================================================= */

/* -----------------------------------------------------------------------------
   Participants Sidebar
   ----------------------------------------------------------------------------- */
#groupParticipantsSidebar {
    background: linear-gradient(180deg, #f8fafc 0%, #e2e8f0 100%);
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 15px;
    margin-bottom: 15px;
    max-height: 450px;
    overflow-y: auto;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

#groupParticipantsSidebar .sidebarTitle {
    color: #475569;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 1px solid #cbd5e1;
}

.participantItem {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: 8px;
    margin-bottom: 6px;
    background: rgba(255, 255, 255, 0.7);
    border: 1px solid #e2e8f0;
    transition: background-color 0.2s ease, border-color 0.2s ease;
}

.participantItem:hover {
    background: rgba(255, 255, 255, 0.95);
    border-color: #94a3b8;
}

.participantItem:last-child {
    margin-bottom: 0;
}

.participantImage {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
    border: 2px solid #94a3b8;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.participantInfo {
    flex: 1;
    min-width: 0;
}

.participantName {
    color: #1e293b;
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 3px;
}

.participantApproval {
    display: flex;
    align-items: center;
    gap: 8px;
}

.miniApprovalBar {
    flex: 1;
    height: 6px;
    background: #cbd5e1;
    border-radius: 3px;
    overflow: hidden;
}

.miniApprovalFill {
    height: 100%;
    background: linear-gradient(90deg, #ef4444 0%, #f59e0b 50%, #22c55e 100%);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.approvalText {
    color: #475569;
    font-size: 11px;
    font-weight: 500;
    min-width: 32px;
    text-align: right;
}

/* -----------------------------------------------------------------------------
   Group Messages
   ----------------------------------------------------------------------------- */
.groupMessage {
    margin-bottom: 15px;
    padding: 12px 16px;
    border-radius: 10px;
    position: relative;
}

.groupMessage.systemMessage {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    color: #0369a1;
    text-align: center;
    font-style: italic;
    font-size: 14px;
}

.groupMessage.userMessage {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 1px solid #e2e8f0;
    margin-left: 20px;
}

.groupMessage.assistantMessage {
    background: linear-gradient(135deg, #fefce8 0%, #fef9c3 100%);
    border: 1px solid #fde047;
    margin-right: 20px;
}

.groupMessage .messageLabel {
    font-weight: 600;
    font-size: 13px;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.groupMessage.userMessage .messageLabel {
    color: #475569;
}

.groupMessage .messageContent {
    color: #1e293b;
    line-height: 1.5;
}

/* -----------------------------------------------------------------------------
   Hide Single Character Elements in Group Mode
   ----------------------------------------------------------------------------- */
.group-chat-active #approvalBarContainer {
    display: none;
}

.group-chat-active #unityContainer {
    display: none;
}

/* Show the sidebar in group mode */
.group-chat-active #groupParticipantsSidebar {
    display: block;
}

/* Hide sidebar in normal mode */
#groupParticipantsSidebar {
    display: none;
}

.group-chat-active #groupParticipantsSidebar {
    display: block;
}

/* -----------------------------------------------------------------------------
   Speaking Indicator (for current speaker)
   ----------------------------------------------------------------------------- */
.participantItem.speaking {
    background: rgba(34, 197, 94, 0.15) !important;
    border: 1px solid #22c55e !important;
}

.participantItem.speaking .participantImage {
    border-color: #22c55e !important;
    animation: speakingPulse 1.5s ease-in-out infinite;
}

.participantItem.speaking .participantName {
    color: #166534;
}

@keyframes speakingPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
    }
    50% {
        box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
    }
}

/* -----------------------------------------------------------------------------
   Ask All Button and Participant Selection
   ----------------------------------------------------------------------------- */
.askAllBtn {
    background: rgba(59, 130, 246, 0.1);
    color: #475569;
    padding: 8px 12px;
    margin-bottom: 10px;
    border-radius: 8px;
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: 1px solid #cbd5e1;
}

.askAllBtn:hover {
    background: rgba(59, 130, 246, 0.15);
    color: #1e293b;
    border-color: #94a3b8;
}

.askAllBtn.selected {
    background: rgba(59, 130, 246, 0.2);
    color: #2563eb;
    border-color: #3b82f6;
}

.participantItem {
    cursor: pointer;
}

.participantItem.selected {
    background: rgba(139, 92, 246, 0.15) !important;
    border: 1px solid #8b5cf6 !important;
    border-radius: 8px;
}

.participantItem.selected .participantName {
    color: #6d28d9;
}

/* -----------------------------------------------------------------------------
   Group Interview Header
   ----------------------------------------------------------------------------- */
.group-chat-active #characterInfoFullName {
    font-size: 16px;
}

/* -----------------------------------------------------------------------------
   Responsive Adjustments
   ----------------------------------------------------------------------------- */
@media (max-width: 768px) {
    #groupParticipantsSidebar {
        max-height: 200px;
    }

    .participantItem {
        padding: 6px;
        gap: 6px;
        margin-bottom: 4px;
    }

    .participantImage {
        width: 28px;
        height: 28px;
    }

    .participantName {
        font-size: 11px;
    }
}

/* -----------------------------------------------------------------------------
   Group Chat Error Text
   ----------------------------------------------------------------------------- */
.error-text {
    color: #dc2626;
    font-style: italic;
}

/* -----------------------------------------------------------------------------
   Group Chat Export Styles
   ----------------------------------------------------------------------------- */
.group-chat-active #exportInterview {
    /* Export still works in group chat */
}

/* -----------------------------------------------------------------------------
   Mode Tooltips
   ----------------------------------------------------------------------------- */
#groupModeSelector label[title] {
    cursor: help;
}

/* Aware mode - default tooltip style */
#groupModeSelector label:first-child::after {
    content: '';
}

/* -----------------------------------------------------------------------------
   Max Participants Warning Toast
   ----------------------------------------------------------------------------- */
.max-participants-warning {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #fef3c7;
    border: 1px solid #f59e0b;
    color: #92400e;
    padding: 12px 24px;
    border-radius: 8px;
    z-index: 1000;
    animation: slideUp 0.3s ease-out;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

/* =============================================================================
   GROUP BIO POPUP - Tabbed Navigation
   ============================================================================= */

#groupBioTabs {
    display: flex;
    gap: 8px;
    padding: 10px 0;
    margin-bottom: 10px;
    overflow-x: auto;
    flex-wrap: wrap;
}

.bioTab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    font-weight: 500;
}

.bioTab:hover {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    border-color: #94a3b8;
    color: #1e293b;
}

.bioTab.active {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    border-color: #4f46e5;
    color: white;
}

.bioTab .tabImage {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.bioTab .tabName {
    white-space: nowrap;
}

/* Hide Start Interview button in group mode */
#popupCharacterBio.groupMode #bioStartInterview {
    display: none !important;
}

/* =============================================================================
   GROUP NOTES POPUP - Tabbed Layout
   ============================================================================= */

#groupNotesTabs {
    display: flex;
    gap: 8px;
    padding: 10px 0;
    margin-bottom: 10px;
    overflow-x: auto;
    flex-wrap: wrap;
}

.notesTab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    color: #64748b;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 13px;
    font-weight: 500;
}

.notesTab:hover {
    background: linear-gradient(135deg, #e2e8f0 0%, #cbd5e1 100%);
    border-color: #94a3b8;
    color: #1e293b;
}

.notesTab.active {
    background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
    border-color: #4f46e5;
    color: white;
}

.notesTab .tabImage {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.notesTab .tabName {
    white-space: nowrap;
}

/* Adjust notes popup for group mode */
#popupCharacterNotes.groupMode #notesData {
    display: none;
}

#popupCharacterNotes.groupMode #notesList {
    margin-top: 0;
}
