/* Additional custom styles for the shareholder dialogue app */

/* Connection Settings Collapse Functionality */
#connectionSettingsContent {
    transition: max-height 0.3s ease-in-out, opacity 0.3s ease-in-out;
    max-height: 1000px;
    opacity: 1;
    overflow: hidden;
}

.connection-settings-collapsed #connectionSettingsContent {
    max-height: 0;
    opacity: 0;
}

#collapseIcon {
    transition: transform 0.2s ease-in-out;
}

.connection-settings-collapsed #collapseIcon {
    transform: rotate(-90deg);
}

/* Ensure proper spacing and layout */
.container {
    padding-left: 1rem;
    padding-right: 1rem;
}

/* Dialogue Container Auto-Expansion */
#dialogueContainer {
    max-height: 60vh;
    overflow-y: auto;
    scroll-behavior: smooth;
    padding-right: 8px; /* 스크롤바 공간 확보 */
}

/* 스크롤바 스타일링 */
#dialogueContainer::-webkit-scrollbar {
    width: 6px;
}

#dialogueContainer::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

#dialogueContainer::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

#dialogueContainer::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* 빈 상태 최소 높이 설정 */
#dialogueContainer:empty {
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#dialogueContainer:empty::after {
    content: "対話メッセージがここに表示されます";
    color: #9ca3af;
    font-style: italic;
}

/* Chat bubble enhancements */
.chat-bubble {
    border-radius: 1rem;
    padding: 1rem;
    margin: 0.5rem 0;
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.chat-bubble:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.chat-bubble::before {
    content: '';
    position: absolute;
    width: 0;
    height: 0;
    border-style: solid;
}

.shareholder-bubble::before {
    bottom: -10px;
    left: 20px;
    border-width: 10px 10px 0 0;
    border-color: #1d4ed8 transparent transparent transparent;
}

.director-bubble::before {
    bottom: -10px;
    right: 20px;
    border-width: 10px 0 0 10px;
    border-color: #047857 transparent transparent transparent;
}

.system-bubble::before {
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    border-width: 10px 10px 0 10px;
    border-color: #7c3aed transparent transparent transparent;
}

/* PDF preview enhancements */
.pdf-preview {
    background: #f9fafb;
    transition: all 0.3s ease;
    max-width: 100%;
    overflow: hidden;
}

.pdf-preview canvas {
    max-width: 100%;
    height: auto;
}

.pdf-preview:hover {
    border-color: #3b82f6;
}

/* File list styling */
.file-item {
    border: 1px solid #e5e7eb;
    border-radius: 0.5rem;
    padding: 0.75rem;
    background: #f9fafb;
    transition: all 0.2s ease;
}

.file-item:hover {
    background: #f3f4f6;
    border-color: #3b82f6;
}

.file-item.selected {
    background: #dbeafe;
    border-color: #3b82f6;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .container {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    .chat-bubble {
        max-width: 95%;
    }
    
    #pdfControls {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    #pdfControls button {
        width: 100%;
    }
}

/* Loading and status indicators */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.status-indicator.connected {
    color: #10b981;
}

.status-indicator.disconnected {
    color: #ef4444;
}

.status-indicator.connecting {
    color: #f59e0b;
}

/* Animation improvements */
.slide-in {
    animation: slideIn 0.3s ease-out;
}

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

/* Enhanced button styles */
button:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Markdown content styling within chat bubbles */
.chat-content h1,
.chat-content h2,
.chat-content h3 {
    font-weight: bold;
    margin: 0.5rem 0;
}

.chat-content h1 {
    font-size: 1.25rem;
}

.chat-content h2 {
    font-size: 1.125rem;
}

.chat-content h3 {
    font-size: 1rem;
}

.chat-content p {
    margin: 0.5rem 0;
    line-height: 1.5;
}

.chat-content ul,
.chat-content ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.chat-content li {
    margin: 0.25rem 0;
}

.chat-content strong {
    font-weight: bold;
}

.chat-content em {
    font-style: italic;
}

.chat-content code {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-family: monospace;
}

.chat-content pre {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.5rem;
    border-radius: 0.5rem;
    overflow-x: auto;
    margin: 0.5rem 0;
}

.chat-content blockquote {
    border-left: 4px solid rgba(255, 255, 255, 0.3);
    padding-left: 1rem;
    margin: 0.5rem 0;
    font-style: italic;
}

/* Modal Popup Styles */
#chatBubbleModal {
    backdrop-filter: blur(4px);
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

#chatBubbleModal.show {
    display: flex !important;
    animation: modalFadeIn 0.3s ease-out;
}

#chatBubbleModal .bg-white {
    animation: modalSlideIn 0.3s ease-out;
}

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

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

/* Modal content styling for better readability */
#modalContent {
    font-size: 1.125rem;
    line-height: 1.7;
}

#modalContent h1,
#modalContent h2,
#modalContent h3 {
    color: #1f2937;
    margin: 1.5rem 0 1rem 0;
}

#modalContent h1 {
    font-size: 1.875rem;
    font-weight: 700;
}

#modalContent h2 {
    font-size: 1.5rem;
    font-weight: 600;
}

#modalContent h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

#modalContent p {
    margin: 1rem 0;
    color: #374151;
}

#modalContent ul,
#modalContent ol {
    margin: 1rem 0;
    padding-left: 2rem;
}

#modalContent li {
    margin: 0.5rem 0;
    color: #374151;
}

#modalContent strong {
    font-weight: 600;
    color: #1f2937;
}

#modalContent em {
    font-style: italic;
    color: #4b5563;
}

#modalContent code {
    background: #f3f4f6;
    color: #1f2937;
    padding: 0.25rem 0.5rem;
    border-radius: 0.375rem;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 0.875rem;
}

#modalContent blockquote {
    border-left: 4px solid #3b82f6;
    background: #f8fafc;
    padding: 1rem 1.5rem;
    margin: 1.5rem 0;
    border-radius: 0.5rem;
    font-style: italic;
    color: #475569;
}

/* Role-specific modal title styling */
.modal-title-shareholder {
    color: #1d4ed8;
}

.modal-title-director {
    color: #047857;
}

.modal-title-system {
    color: #7c3aed;
}

/* Question Candidates Section */
#questionCandidatesContent {
    transition: max-height 0.3s ease-in-out, opacity 0.3s ease-in-out;
    max-height: 1000px;
    opacity: 1;
    overflow: hidden;
}

#questionCandidatesSection.candidates-collapsed #questionCandidatesContent {
    max-height: 0;
    opacity: 0;
}

#candidatesIcon {
    transition: transform 0.2s ease-in-out;
}

#questionCandidatesSection.candidates-collapsed #candidatesIcon {
    transform: rotate(-90deg);
}

/* Question Candidate Item Styling */
.question-candidate {
    background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%);
    border: 2px solid #d1d5db;
    border-radius: 0.75rem;
    padding: 1rem;
    margin: 0.5rem 0;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.question-candidate:hover {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    border-color: #3b82f6;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.question-candidate:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(59, 130, 246, 0.1);
}

.question-candidate::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, #3b82f6, #8b5cf6);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.question-candidate:hover::before {
    opacity: 1;
}

.question-candidate .question-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    background: #3b82f6;
    color: white;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 600;
    margin-right: 0.75rem;
    flex-shrink: 0;
}

.question-candidate .question-text {
    flex: 1;
    font-size: 0.95rem;
    line-height: 1.5;
    color: #374151;
    font-weight: 500;
}

.question-candidate:hover .question-text {
    color: #1f2937;
}

.question-candidate .question-icon {
    font-size: 1.25rem;
    margin-left: 0.5rem;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

.question-candidate:hover .question-icon {
    opacity: 1;
}

/* Question Candidates Loading State */
#candidatesLoadingIndicator {
    color: #6b7280;
    font-size: 0.9rem;
}

#candidatesLoadingIndicator .loading-spinner {
    width: 24px;
    height: 24px;
    border-width: 2px;
}

/* Custom Question Input Section */
#customQuestionSection {
    background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
    border-radius: 0.75rem;
    padding: 1.5rem;
    margin-top: 1.5rem;
    border: 1px solid #e9d5ff;
}

#customQuestionSection h3 {
    color: #7c3aed;
    margin-bottom: 0.75rem;
}

#customQuestionInput {
    transition: all 0.2s ease;
    min-height: 80px;
    font-family: inherit;
    line-height: 1.5;
}

#customQuestionInput:focus {
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
    border-color: #8b5cf6;
}

#customQuestionInput::placeholder {
    color: #9ca3af;
    font-style: italic;
}

#submitCustomQuestionBtn {
    transition: all 0.2s ease;
    font-weight: 500;
    min-width: 200px;
}

#submitCustomQuestionBtn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.2);
}

#submitCustomQuestionBtn:active:not(:disabled) {
    transform: translateY(0);
}

#submitCustomQuestionBtn:disabled {
    background: #9ca3af !important;
    cursor: not-allowed;
}

/* Custom Question Section Mobile Responsiveness */
@media (max-width: 768px) {
    #customQuestionSection {
        padding: 1rem;
        margin-top: 1rem;
    }
    
    #customQuestionInput {
        font-size: 1rem;
        min-height: 100px;
    }
    
    #submitCustomQuestionBtn {
        width: 100%;
        min-width: auto;
    }
}

/* Mobile responsiveness for modal */
@media (max-width: 768px) {
    #chatBubbleModal .bg-white {
        margin: 1rem;
        max-height: calc(100vh - 2rem);
    }
    
    #modalContent {
        font-size: 1rem;
        line-height: 1.6;
    }
    
    #modalContent h1 {
        font-size: 1.5rem;
    }
    
    #modalContent h2 {
        font-size: 1.25rem;
    }
    
    #modalContent h3 {
        font-size: 1.125rem;
    }
    
    .question-candidate {
        padding: 0.75rem;
    }
    
    .question-candidate .question-text {
        font-size: 0.9rem;
    }
}