/* Base styles and variables */
:root {
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --background-color: #f3f4f6;
    --text-color: #1f2937;
    --border-color: #e5e7eb;
    --tooltip-bg: rgba(0, 0, 0, 0.8);
}

body {
    min-height: 100vh;
    color: var(--text-color);
    line-height: 1.5;
}

/* Progress Section Styles */
.progress-item {
    display: flex;
    align-items: center;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.3s ease;
}

.progress-item:hover {
    background-color: #f3f4f6;
}

.progress-item .icon {
    width: 1.5rem;
    height: 1.5rem;
    margin-right: 0.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.progress-item .text {
    flex-grow: 1;
}

.progress-item.completed .icon {
    background-color: var(--success-color);
    color: white;
}

.progress-item.completed .text {
    color: var(--success-color);
}

/* Tooltip Styles */
.progress-item[data-tooltip] {
    position: relative;
    cursor: pointer;
}

.progress-item[data-tooltip]:before {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background-color: var(--tooltip-bg);
    color: white;
    padding: 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    white-space: pre-wrap;
    max-width: 200px;
    width: max-content;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
    z-index: 10;
    pointer-events: none;
}

.progress-item[data-tooltip]:hover:before {
    opacity: 1;
    visibility: visible;
}

/* Action Buttons */
.action-btn {
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 600;
    transition: background-color 0.3s ease;
    text-align: center;
    cursor: pointer;
}

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

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

/* Tab Styles */
.tabs {
    border-bottom: 1px solid var(--border-color);
    position: relative;
    margin-bottom: -1px;
    display: flex;
    gap: 4px;
    border-radius: 8px 8px 0 0;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    position: relative;
    background: white;
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    font-weight: 600;
    color: var(--text-color);
    cursor: pointer;
    transform: translateY(1px);
    transition: all 0.2s ease;
    box-shadow: 0 -2px 4px rgba(0,0,0,0.05);
}

.tab-btn:not(.active) {
    background: #f8f9fa;
    transform: translateY(3px);
}

.tab-btn.active {
    z-index: 2;
    border-bottom-color: white;
}

.tab-pane {
    display: none;
}

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

.tab-content {
    /* remove the border line */
    border-radius: 0 8px 8px 8px;
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    position: relative;
    z-index: 1;
}

/* Chat Container Styles */
.chat-container {
    height: calc(100vh - 12rem);
    display: flex;
    flex-direction: column;
    border-bottom: none;
    border-radius: 0 0 0 0;
}

.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 1rem;
}

.chat-message {
    margin-bottom: 1rem;
    max-width: 75%;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
}

.user-message {
    background-color: var(--primary-color);
    color: white;
    margin-left: auto;
}

.bot-message {
    background-color: var(--border-color);
    margin-right: auto;
}

.bot-message ul {
    margin-left: 20px;
    margin-bottom: 10px;
}

.bot-message li {
    margin-bottom: 5px;
}

.bot-message strong {
    display: block;
    margin-top: 10px;
    margin-bottom: 5px;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Input Group Styles */
.chat-input-container {
    border-top: 1px solid var(--border-color);
    padding: 1rem;
    background-color: white;
}

.input-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-input {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.375rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    resize: none;
    min-height: 42px;
    max-height: 200px;
    line-height: 1.5;
    font-size: 0.95rem;
    min-width: 0;
}

.input-actions {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

/* Input Buttons */
.input-btn {
    padding: 0.5rem;
    border-radius: 0.375rem;
    background-color: var(--primary-color);
    color: white;
    cursor: pointer;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 42px;
    width: 42px;
    flex-shrink: 0;
}

.input-btn.generate-btn {
    white-space: nowrap;
    padding: 0.5rem 1rem;
    background-color: var(--success-color);
    font-weight: 600;
    font-size: 0.9rem;
    width: auto;
}

.input-btn.generate-btn:hover {
    background-color: #059669;
}

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

.input-btn svg {
    width: 1.5rem;
    height: 1.5rem;
}

.input-btn.active {
    background-color: var(--error-color);
}

.input-btn input[type="file"] {
    display: none;
}

/* Loading Spinner */
.loading-spinner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

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

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

.loading-spinner.hidden {
    display: none;
}

/* Scrollbar Styles */
.chat-messages::-webkit-scrollbar,
.chat-input::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track,
.chat-input::-webkit-scrollbar-track {
    background: var(--border-color);
}

.chat-messages::-webkit-scrollbar-thumb,
.chat-input::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover,
.chat-input::-webkit-scrollbar-thumb:hover {
    background: #666;
}

/* Responsive Adjustments */
@media (max-width: 640px) {
    .input-group {
        flex-direction: column;
    }
    
    .input-btn.generate-btn {
        width: 100%;
        order: -1;
        margin-bottom: 0.5rem;
    }
    
    .chat-input {
        order: 0;
    }
    
    .input-actions {
        order: 1;
        margin-top: 0.5rem;
        width: 100%;
        justify-content: flex-end;
    }
}

/* Images in chat */
.chat-message img {
    max-width: 300px;
    border-radius: 0.375rem;
}

/* Add these styles at the end of the file */
#recommendationsContent {
    max-height: 600px;
    overflow-y: auto;
  }
  
  #recommendationsContent h3 {
    color: #2563eb;
    margin-top: 1rem;
  }
  
  #recommendationsContent table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 1rem;
  }
  
  #recommendationsContent th, #recommendationsContent td {
    border: 1px solid #e5e7eb;
    padding: 0.5rem;
    text-align: left;
  }
  
  #recommendationsContent th {
    background-color: #f3f4f6;
    font-weight: 600;
  }

  .abstract-content, .full-abstract {
    margin-bottom: 0.5rem;
  }
  
  .read-more-btn {
    cursor: pointer;
    text-decoration: underline;
  }
  
  #markdown-content h1, #markdown-content h2, #markdown-content h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: bold;
  }
  
  #markdown-content h1 { font-size: 1.5rem; }
  #markdown-content h2 { font-size: 1.3rem; }
  #markdown-content h3 { font-size: 1.1rem; }
  
  #markdown-content ul, #markdown-content ol {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
  }
  
  #markdown-content li {
    margin-bottom: 0.25rem;
  }
  
  #markdown-content table {
    border-collapse: collapse;
    margin-bottom: 1rem;
  }
  
  #markdown-content th, #markdown-content td {
    border: 1px solid #e5e7eb;
    padding: 0.5rem;
  }
  
  #markdown-content th {
    background-color: #f3f4f6;
    font-weight: 600;
  }

  .follow-up-letter h1 {
    color: #2563eb;
    margin-bottom: 1rem;
  }
  
  .follow-up-letter p {
    margin-bottom: 1rem;
  }
  
  .follow-up-letter ul {
    margin-left: 1.5rem;
    margin-bottom: 1rem;
  }
  
  .follow-up-letter li {
    margin-bottom: 0.5rem;
  }

  .patient-lookup {
    margin-top: 1rem;
}

.patient-lookup input {
    margin-bottom: 0.5rem;
}

/* Welcome Pop-up Styles */
#welcomePopup {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: opacity 0.3s ease-in-out;
}

#welcomePopup.hidden {
    opacity: 0;
    pointer-events: none;
}

#welcomePopup .popup-content {
    background-color: white;
    padding: 2rem;
    border-radius: 0.5rem;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-width: 90%;
    width: 100%;
    max-width: 500px;
}

#welcomePopup h2 {
    font-size: 1.5rem;
    font-weight: bold;
    margin-bottom: 1rem;
    color: var(--primary-color);
}

#welcomePopup p {
    margin-bottom: 1rem;
}

#welcomePopup img {
    max-width: 100%;
    height: auto;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

#closePopup {
    display: block;
    width: 100%;
    padding: 0.75rem;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 0.375rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

#closePopup:hover {
    background-color: var(--primary-hover);
}