/* static/style.css */

/* If you have Osam font files, put them in static/fonts/Osam-Regular.woff2
   and the stylesheet will use it automatically. Otherwise Vazir and Vazirmatn
   are used as fallbacks. */

@font-face {
    font-family: 'Osam';
    src: url('/static/fonts/Osam-Regular.woff2') format('woff2'),
         url('/static/fonts/Osam-Regular.woff') format('woff');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

body {
    font-family: 'Osam', 'Vazir', 'Vazirmatn', 'Segoe UI', Tahoma, sans-serif;
    background-color: #f0f2f5;
    margin: 0;
    padding: 10px;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    box-sizing: border-box;
}

.main-container {
    display: flex;
    width: 100%;
    max-width: 1200px;
    height: 90vh;
    gap: 10px;
}

.chat-wrapper {
    flex: 1.2;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    background-color: #075e54;
    color: white;
    padding: 15px 20px;
    font-size: 1.2em;
    font-weight: bold;
    text-align: center;
    flex-shrink: 0;
}

.chat-messages {
    flex-grow: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
    background-color: #fafafa;
}

.chat-input-form {
    display: flex;
    padding: 15px;
    background-color: #fff;
    border-top: 1px solid #e0e0e0;
    gap: 10px;
    flex-shrink: 0;
}

.chat-input-form textarea {
    flex-grow: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-family: inherit;
    font-size: 0.95em;
    resize: none;
    max-height: 120px;
    outline: none;
}

.chat-input-form textarea:focus {
    border-color: #0d6efd;
    box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.08);
}

.chat-input-form button {
    padding: 10px 18px;
    color: white;
    border: none;
    border-radius: 20px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.2s;
    background-color: #0d6efd; /* bootstrap primary blue */
}

.chat-input-form button:hover {
    background-color: #0b5ed7;
}

.chat-input-form button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* Sidebar QA List */
.sidebar-qalist {
    flex: 0.8;
    background-color: #fff;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    background-color: #075e54;
    color: white;
    padding: 15px;
    font-weight: bold;
    text-align: center;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.qalist-container {
    flex-grow: 1;
    overflow-y: auto;
    padding: 10px;
    background-color: #fafafa;
}

.qa-item {
    margin-bottom: 12px;
    padding: 10px;
    background: white;
    border-radius: 8px;
    border-right: 4px solid #0d6efd; /* blue accent */
    animation: slideIn 0.3s ease-in-out;
}

.qa-question {
    font-size: 0.85em;
    color: #333;
    margin-bottom: 8px;
    word-wrap: break-word;
    font-weight: 600;
}

.qa-answer {
    font-size: 0.8em;
    color: #666;
    word-wrap: break-word;
    line-height: 1.4;
}

.qa-answer em {
    color: #999;
    font-style: italic;
}

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

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #0d6efd;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #0b5ed7;
}

/* Responsive Design */
@media (max-width: 768px) {
    .main-container {
        flex-direction: column;
        height: auto;
    }
    
    .chat-wrapper {
        flex: 1;
        min-height: 500px;
    }
    
    .sidebar-qalist {
        flex: 1;
        max-height: 300px;
    }
    
    .message {
        max-width: 90%;
    }
}

.message.user {
    background-color: #dcf8c6;
    align-self: flex-end;
    margin-left: auto;
    display: none;
}

.message.ai {
    background-color: #ece5dd;
    align-self: flex-start;
    margin-right: auto;
}

.message.typing {
    background-color: #ece5dd;
    color: #888;
    font-style: italic;
}

/* Hourglass animation */
.hourglass {
    width: 20px;
    height: 28px;
    position: relative;
    border: 2px solid #0d6efd;
    border-radius: 3px;
    box-sizing: border-box;
    overflow: hidden;
}
.hourglass::before,
.hourglass::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    background: #0d6efd;
    transition: height 0.6s linear;
}
.hourglass::before {
    top: 0;
    height: 40%; /* top sand */
    transform-origin: top center;
    animation: sandTop 1.6s infinite ease-in-out;
}
.hourglass::after {
    bottom: 0;
    height: 10%; /* bottom sand */
    transform-origin: bottom center;
    animation: sandBottom 1.6s infinite ease-in-out;
}

@keyframes sandTop {
    0% { height: 40%; }
    50% { height: 5%; }
    100% { height: 40%; }
}

@keyframes sandBottom {
    0% { height: 10%; }
    50% { height: 45%; }
    100% { height: 10%; }
}

.chat-input-form {
    display: flex;
    padding: 10px;
    border-top: 1px solid #ddd;
    align-items: center;
    gap: 10px;
}

#promptInput {
    flex-grow: 1;
    border: 1px solid #ccc;
    border-radius: 20px;
    padding: 10px 15px;
    font-size: 1em;
    font-family: inherit;
    resize: none;
    max-height: 100px;
}

#sendButton {
    background-color: #128c7e;
    color: white;
    border: none;
    border-radius: 50%;
    width: 45px;
    height: 45px;
    font-size: 1.2em;
    cursor: pointer;
    transition: background-color 0.2s;
}

#sendButton:hover {
    background-color: #075e54;
}

#sendButton:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}