:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --info-color: #17a2b8;
    --warning-color: #ffc107;
    --danger-color: #dc3545;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
}

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

.hero-section {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    min-height: 70vh;
    display: flex;
    align-items: center;
}

.bg-gradient-primary {
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
}

.navbar-brand img {
    border-radius: 50%;
}

.upload-dropzone {
    transition: all 0.3s ease;
    cursor: pointer;
}

.upload-dropzone:hover {
    background-color: #e7f3ff;
    border-color: #0056b3;
}

.upload-dropzone.dragover {
    background-color: #e7f3ff;
    border-color: #0056b3;
    transform: scale(1.02);
}

.feature-icon {
    font-size: 1.5rem;
}

.step-number {
    font-size: 1.2rem;
    font-weight: bold;
}

.card {
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important;
}

.chat-message {
    margin-bottom: 1.5rem;
    opacity: 0;
    animation: slideInMessage 0.3s ease-out forwards;
}

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

.message-bubble {
    max-width: 100%;
    word-wrap: break-word;
    position: relative;
    transition: all 0.2s ease;
}

.message-bubble:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1) !important;
}

.user-message .message-bubble {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%) !important;
    color: white;
    border: none !important;
}

.bot-message .message-bubble {
    background-color: #ffffff;
    border: 1px solid #e9ecef;
    color: #495057;
}

.avatar {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.2s ease;
}

.avatar:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.bot-message .avatar {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%) !important;
}

.user-message .avatar {
    background: linear-gradient(135deg, var(--secondary-color) 0%, #495057 100%) !important;
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 0;
}

.typing-dots span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%);
    animation: typing 1.4s infinite ease-in-out;
}

.typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.4;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

.dashboard-file-icon {
    font-size: 1.25rem !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 50px !important;
    width: 50px !important;
    height: 50px !important;
    flex-shrink: 0 !important;
}

.dashboard-file-icon i {
    font-size: 1.25rem !important;
    line-height: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
    vertical-align: middle !important;
}

/* Force proper icon rendering to prevent compression */
.revised-files-section .file-icon {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    border-radius: 50% !important;
    overflow: hidden;
    position: relative;
}

.revised-files-section .file-icon::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    background: inherit;
    z-index: -1;
}

/* AI text icon styling */
.revised-files-section .ai-icon {
    background: linear-gradient(135deg, #28a745 0%, #20c997 100%) !important;
    color: white !important;
    font-weight: bold !important;
    font-size: 1.2rem !important;
    letter-spacing: 1px !important;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2) !important;
    border: 2px solid rgba(255, 255, 255, 0.2) !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

/* Ensure icon font doesn't get compressed */
.revised-files-section .fa-brain {
    transform: none !important;
    font-weight: 900 !important;
    font-family: "Font Awesome 5 Free" !important;
    vertical-align: middle !important;
    display: inline-block !important;
    font-style: normal !important;
    font-variant: normal !important;
    text-rendering: auto !important;
    line-height: 1 !important;
    margin: 0 !important;
    padding: 0 !important;
}

.progress-bar-animated {
    animation: progress-bar-stripes 1s linear infinite;
}

@keyframes progress-bar-stripes {
    0% {
        background-position: 1rem 0;
    }
    100% {
        background-position: 0 0;
    }
}

.btn {
    transition: all 0.3s ease;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.navbar {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.footer {
    margin-top: auto;
}

/* Revised Files Section Styling */
.revised-files-section .card {
    transition: all 0.3s ease;
}

.revised-files-section .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 0.75rem 2rem rgba(0, 0, 0, 0.15) !important;
}

.revised-files-section .file-icon {
    min-width: 50px !important;
    width: 50px !important;
    height: 50px !important;
    flex-shrink: 0 !important;
    font-size: 1.25rem !important;
    line-height: 1 !important;
}

.revised-files-section .file-icon i {
    font-size: 1.25rem !important;
    line-height: 1 !important;
}

.revised-files-section .text-truncate {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.revised-files-section .min-w-0 {
    min-width: 0;
}

.revised-files-section .card-body {
    overflow: hidden;
}

.revised-files-section .btn-group {
    width: 100%;
}

.revised-files-section .btn-group .btn {
    flex: 1;
}

.revised-files-section .btn-group .btn:last-child {
    flex: 0 0 auto;
    min-width: 40px;
}

/* File name truncation for long names */
.file-name-truncate {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: inline-block;
    vertical-align: bottom;
}

/* Badge styling improvements */
.revised-files-section .badge {
    font-size: 0.7rem !important;
    padding: 0.25em 0.5em;
    white-space: nowrap;
}

/* Button spacing and sizing improvements */
.revised-files-section .d-grid .btn {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Ensure cards have consistent height */
.revised-files-section .card {
    height: 100%;
    display: flex;
    flex-direction: column;
}

.revised-files-section .card-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* Responsive adjustments for small screens */
@media (max-width: 768px) {
    .revised-files-section .file-name-truncate {
        max-width: 150px;
    }
    
    .revised-files-section .file-icon {
        width: 45px !important;
        height: 45px !important;
        min-width: 45px !important;
        font-size: 1rem !important;
    }
    
    .revised-files-section .ai-icon {
        font-size: 1rem !important;
        letter-spacing: 0.5px !important;
    }
    
    .revised-files-section .file-icon i {
        font-size: 1.1rem !important;
    }
    
    .revised-files-section .btn-group .btn {
        font-size: 0.8rem;
        padding: 0.375rem 0.5rem;
    }
}

/* Mobile responsive file icons */
@media (max-width: 768px) {
    .dashboard-file-icon {
        min-width: 45px !important;
        width: 45px !important;
        height: 45px !important;
        font-size: 1.1rem !important;
    }
    
    .dashboard-file-icon i {
        font-size: 1.1rem !important;
    }
}

/* Dashboard section spacing */
.dashboard-section {
    margin-bottom: 2rem;
}

.dashboard-section h3 {
    font-weight: 600;
    color: var(--dark-color);
}

/* Enhanced visual separation between sections */
.ai-revised-section {
    background: linear-gradient(135deg, rgba(40, 167, 69, 0.05) 0%, rgba(40, 167, 69, 0.02) 100%);
    border-radius: 1rem;
    padding: 1.5rem;
    margin-top: 2rem;
}

/* Badge positioning fixes for dashboard cards */
.card .badge {
    position: relative;
    z-index: 1;
    display: inline-flex !important;
    align-items: center !important;
    white-space: nowrap !important;
}

.card .text-end {
    text-align: right !important;
    position: relative;
    z-index: 1;
}

/* Ensure card body contains all content properly */
.card-body {
    position: relative;
    overflow: hidden;
    padding: 1rem !important;
}

/* Prevent badge overflow */
.card .d-flex .text-end {
    flex-shrink: 0;
    min-width: fit-content;
}

.card .d-flex .flex-grow-1 {
    overflow: hidden;
    min-width: 0;
}

/* Dashboard card container fixes */
.dashboard-section .card {
    position: relative;
    overflow: visible;
    border: 1px solid rgba(0, 0, 0, 0.125);
    border-radius: 0.375rem;
}

.dashboard-section .card-body {
    display: flex;
    flex-direction: column;
    height: 100%;
    position: relative;
}

/* Loading spinner */
.spinner-border {
    width: 3rem;
    height: 3rem;
}

/* Custom scrollbar for chat */
#chat-container {
    scrollbar-width: thin;
    scrollbar-color: #c1c1c1 #f1f1f1;
}

#chat-container::-webkit-scrollbar {
    width: 8px;
}

#chat-container::-webkit-scrollbar-track {
    background: #f8f9fa;
    border-radius: 4px;
}

#chat-container::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #c1c1c1 0%, #a8a8a8 100%);
    border-radius: 4px;
}

#chat-container::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #a8a8a8 0%, #888888 100%);
}

/* File upload styling */
.upload-area {
    border: 2px dashed #dee2e6;
    border-radius: 8px;
    padding: 2rem;
    text-align: center;
    background-color: #f8f9fa;
    transition: all 0.3s ease;
}

.upload-area:hover {
    border-color: var(--primary-color);
    background-color: #e7f3ff;
}

.upload-area.dragover {
    border-color: var(--primary-color);
    background-color: #e7f3ff;
    transform: scale(1.02);
}

/* Success states */
.upload-success {
    border-color: var(--success-color);
    background-color: #d4edda;
}

/* Error states */
.upload-error {
    border-color: var(--danger-color);
    background-color: #f8d7da;
}

/* Animation for page transitions */
.fade-in {
    animation: fadeIn 0.5s ease-in;
}

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

/* Quiz Section Styles */
.bg-gradient-warning {
    background: linear-gradient(135deg, #ffc107 0%, #ff9800 100%);
}

.quiz-preview {
    animation: float 3s ease-in-out infinite;
}

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

.quiz-features .fas {
    font-size: 1.1rem;
}

.quiz-question {
    border-left: 4px solid var(--primary-color);
    padding-left: 1rem;
}

.quiz-options .form-check-label {
    cursor: pointer;
    padding: 0.5rem 0;
}

.quiz-options .form-check-input:checked + .form-check-label {
    font-weight: bold;
    color: var(--success-color);
}

/* Chat input styling */
#chat-input {
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

#chat-input:focus {
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.2) !important;
    border-color: var(--primary-color) !important;
    transform: translateY(-1px);
}

#send-btn {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%);
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

#send-btn:hover {
    background: linear-gradient(135deg, #0056b3 0%, #004085 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

#send-btn:active {
    transform: translateY(0);
}

/* Chat container enhancements */
#chat-container {
    background: linear-gradient(to bottom, #ffffff 0%, #f8f9fa 100%);
    border-radius: 0;
}

.chat .card-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%) !important;
    border-radius: 0.375rem 0.375rem 0 0 !important;
}

/* Enhance chat card styling */
.chat .card {
    border: none;
    box-shadow: 0 0.5rem 1.5rem rgba(0, 0, 0, 0.1) !important;
    border-radius: 0.75rem;
    overflow: hidden;
}

/* Enhanced Chat Message Formatting */
.message-text {
    line-height: 1.6;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.message-text h3,
.message-text h4,
.message-text h5 {
    color: inherit;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.message-text h3 {
    font-size: 1.1rem;
    border-bottom: 1px solid rgba(0,0,0,0.1);
    padding-bottom: 0.25rem;
}

.message-text h4 {
    font-size: 1.05rem;
}

.message-text h5 {
    font-size: 1rem;
}

/* Code formatting */
.message-text .code-block {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 0.375rem;
    padding: 0.75rem;
    margin: 0.5rem 0;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    white-space: pre-wrap;
    overflow-x: auto;
    max-width: 100%;
}

.message-text .inline-code {
    background-color: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 0.25rem;
    padding: 0.125rem 0.25rem;
    font-family: 'Courier New', monospace;
    font-size: 0.875rem;
    color: #d63384;
}

/* List formatting */
.message-text .formatted-list {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.message-text .formatted-list li {
    margin-bottom: 0.25rem;
    line-height: 1.5;
}

.message-text ul.formatted-list {
    list-style-type: disc;
}

.message-text ol.formatted-list {
    list-style-type: decimal;
}

.message-text .bullet-item,
.message-text .list-item {
    display: list-item;
}

/* Bold and italic text */
.message-text strong {
    font-weight: 600;
}

.message-text em {
    font-style: italic;
}

/* Paragraph spacing */
.message-text br + br {
    display: block;
    margin: 0.5rem 0;
    content: "";
}

/* Special styling for bot messages */
.bot-message .message-text .code-block {
    background-color: #f1f3f4;
    border-color: #dadce0;
}

.bot-message .message-text .inline-code {
    background-color: #f1f3f4;
    border-color: #dadce0;
    color: #1a73e8;
}

/* Special styling for user messages */
.user-message .message-text .code-block {
    background-color: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
    color: #ffffff;
}

.user-message .message-text .inline-code {
    background-color: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.2);
    color: #ffffff;
}

.user-message .message-text h3,
.user-message .message-text h4,
.user-message .message-text h5 {
    color: #ffffff;
    border-color: rgba(255,255,255,0.3);
}

/* Rendered Markdown Styles */
.rendered-markdown {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    color: #333;
    max-width: 100%;
    word-wrap: break-word;
}

.rendered-markdown h1,
.rendered-markdown h2,
.rendered-markdown h3,
.rendered-markdown h4,
.rendered-markdown h5,
.rendered-markdown h6 {
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 600;
    line-height: 1.25;
}

.rendered-markdown h1 {
    font-size: 1.75rem;
    border-bottom: 2px solid #e1e4e8;
    padding-bottom: 0.5rem;
}

.rendered-markdown h2 {
    font-size: 1.5rem;
    border-bottom: 1px solid #e1e4e8;
    padding-bottom: 0.3rem;
}

.rendered-markdown h3 {
    font-size: 1.25rem;
}

.rendered-markdown h4 {
    font-size: 1.1rem;
}

.rendered-markdown h5,
.rendered-markdown h6 {
    font-size: 1rem;
}

.rendered-markdown p {
    margin-bottom: 1rem;
}

.rendered-markdown strong,
.rendered-markdown b {
    font-weight: 600;
}

.rendered-markdown em,
.rendered-markdown i {
    font-style: italic;
}

.rendered-markdown ul,
.rendered-markdown ol {
    margin-bottom: 1rem;
    padding-left: 2rem;
}

.rendered-markdown li {
    margin-bottom: 0.25rem;
}

.rendered-markdown li > p {
    margin-bottom: 0.5rem;
}

.rendered-markdown ul {
    list-style-type: disc;
}

.rendered-markdown ol {
    list-style-type: decimal;
}

.rendered-markdown blockquote {
    margin: 1rem 0;
    padding: 0.5rem 1rem;
    border-left: 4px solid #dfe2e5;
    background-color: #f6f8fa;
    color: #6a737d;
}

.rendered-markdown blockquote p:last-child {
    margin-bottom: 0;
}

.rendered-markdown pre {
    background-color: #f6f8fa;
    border-radius: 6px;
    font-size: 0.875rem;
    line-height: 1.45;
    overflow: auto;
    padding: 1rem;
    margin-bottom: 1rem;
    font-family: 'Courier New', Consolas, monospace;
}

.rendered-markdown code {
    background-color: rgba(27, 31, 35, 0.05);
    border-radius: 3px;
    font-size: 0.875rem;
    margin: 0;
    padding: 0.2em 0.4em;
    font-family: 'Courier New', Consolas, monospace;
}

.rendered-markdown pre code {
    background-color: transparent;
    border-radius: 0;
    font-size: inherit;
    margin: 0;
    padding: 0;
    word-break: normal;
    white-space: pre;
    word-wrap: normal;
}

.rendered-markdown table {
    border-collapse: collapse;
    margin-bottom: 1rem;
    width: 100%;
}

.rendered-markdown table th,
.rendered-markdown table td {
    border: 1px solid #dfe2e5;
    padding: 6px 13px;
    text-align: left;
}

.rendered-markdown table th {
    background-color: #f6f8fa;
    font-weight: 600;
}

.rendered-markdown table tr:nth-child(2n) {
    background-color: #f6f8fa;
}

.rendered-markdown a {
    color: #0366d6;
    text-decoration: none;
}

.rendered-markdown a:hover {
    text-decoration: underline;
}

.rendered-markdown hr {
    border: none;
    border-top: 1px solid #e1e4e8;
    height: 1px;
    margin: 1.5rem 0;
}

.rendered-markdown img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
    margin: 0.5rem 0;
}

/* Display mode toggle styling */
#display-mode-toggle .btn-outline-secondary {
    border-color: #6c757d;
    color: #6c757d;
    padding: 0.25rem 0.5rem;
    font-size: 0.875rem;
}

#display-mode-toggle .btn-check:checked + .btn-outline-secondary {
    background-color: #6c757d;
    border-color: #6c757d;
    color: white;
}

#display-mode-toggle .btn-outline-secondary:hover {
    background-color: #5c636a;
    border-color: #565e64;
    color: white;
}

/* Alert for format detection */
.alert-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .rendered-markdown {
        font-size: 0.9rem;
    }
    
    .rendered-markdown h1 {
        font-size: 1.5rem;
    }
    
    .rendered-markdown h2 {
        font-size: 1.3rem;
    }
    
    .rendered-markdown h3 {
        font-size: 1.1rem;
    }
    
    .rendered-markdown pre {
        padding: 0.75rem;
        font-size: 0.8rem;
    }
    
    .rendered-markdown table {
        font-size: 0.875rem;
    }
    
    .rendered-markdown ul,
    .rendered-markdown ol {
        padding-left: 1.5rem;
    }
}
