/* Course Tutor Chat Widget */

.ct-registration,
.ct-chat-widget {
    font-family: inherit;
    width: 80%;
    max-width: none;
    margin: 50px auto;
    box-sizing: border-box;
}

.ct-registration *,
.ct-chat-widget * {
    box-sizing: border-box;
}

/* Registration Form */

.ct-reg-card {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 2rem;
    max-width: 440px;
    margin: 2rem auto;
}

.ct-reg-card h2 {
    margin: 0 0 0.5rem;
    font-size: 1.5rem;
    color: #1a202c;
}

.ct-reg-card p {
    margin: 0 0 1.5rem;
    color: #64748b;
    font-size: 0.9rem;
    line-height: 1.5;
}

.ct-field {
    margin-bottom: 1rem;
}

.ct-field label {
    display: block;
    margin-bottom: 0.35rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
}

.ct-field input[type="text"],
.ct-field input[type="email"],
.ct-field input[type="tel"] {
    width: 100%;
    padding: 0.6rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.15s;
    outline: none;
}

.ct-field input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.ct-field button {
    width: 100%;
    padding: 0.7rem;
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s;
}

.ct-field button:hover {
    background: #2563eb;
}

.ct-field button:disabled {
    background: #93c5fd;
    cursor: not-allowed;
}

.ct-error {
    color: #dc2626;
    font-size: 0.85rem;
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: #fef2f2;
    border-radius: 6px;
}

/* Chat Widget */

.ct-chat-widget {
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    overflow: hidden;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    height: 80vh;
}

.ct-chat-header {
    background: #1e293b;
    color: #fff;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.ct-header-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.ct-course-title {
    font-weight: 600;
    font-size: 0.95rem;
}

.ct-progress-badge {
    background: #3b82f6;
    color: #fff;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    font-size: 0.75rem;
    font-weight: 600;
}

/* Font size controls */

.ct-font-controls {
    display: flex;
    gap: 4px;
}

.ct-font-btn {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    cursor: pointer;
    line-height: 1;
    transition: background 0.15s;
}

.ct-font-btn:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Messages area */

.ct-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.ct-message {
    max-width: 85%;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: inherit;
    line-height: 1.6;
    word-wrap: break-word;
}

.ct-message-tutor {
    align-self: flex-start;
    background: #fff;
    color: #1a202c;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

.ct-message-student {
    align-self: flex-end;
    background: #3b82f6;
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Simple markdown rendering */

.ct-message-tutor h2,
.ct-message-tutor h3,
.ct-message-tutor h4 {
    margin: 0.75rem 0 0.35rem;
    line-height: 1.3;
}

.ct-message-tutor h2:first-child,
.ct-message-tutor h3:first-child,
.ct-message-tutor h4:first-child {
    margin-top: 0;
}

.ct-message-tutor h2 { font-size: 1.15em; }
.ct-message-tutor h3 { font-size: 1.05em; }
.ct-message-tutor h4 { font-size: 1em; }

.ct-message-tutor hr {
    border: none;
    border-top: 1px solid #e2e8f0;
    margin: 0.75rem 0;
}

.ct-message-tutor p {
    margin: 0 0 0.5rem;
}

.ct-message-tutor p:last-child {
    margin-bottom: 0;
}

.ct-message-tutor strong {
    font-weight: 700;
}

.ct-message-tutor em {
    font-style: italic;
}

.ct-message-tutor code {
    background: #f1f5f9;
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
    font-size: 0.85em;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
}

.ct-message-tutor pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 0.75rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.5rem 0;
    font-size: 0.85em;
}

.ct-message-tutor pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.ct-message-tutor ul,
.ct-message-tutor ol {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.ct-message-tutor li {
    margin-bottom: 0.25rem;
}

/* Typing indicator */

.ct-typing {
    padding: 0.5rem 1rem;
    flex-shrink: 0;
}

.ct-typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: #fff;
    border: 1px solid #e2e8f0;
    padding: 0.6rem 1rem;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}

.ct-typing-dots span {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: ct-bounce 1.4s infinite ease-in-out;
}

.ct-typing-dots span:nth-child(1) { animation-delay: 0s; }
.ct-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ct-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ct-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* Input area */

.ct-input-area {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    padding: 0.75rem;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.ct-input {
    flex: 1;
    padding: 0.6rem 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 0.9rem;
    font-family: inherit;
    resize: none;
    outline: none;
    max-height: 120px;
    line-height: 1.4;
    transition: border-color 0.15s;
}

.ct-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.ct-send {
    width: 40px;
    height: 40px;
    background: #3b82f6;
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}

.ct-send:hover {
    background: #2563eb;
}

.ct-send:disabled {
    background: #93c5fd;
    cursor: not-allowed;
}

/* Mobile responsive */

@media (max-width: 768px) {
    .ct-registration,
    .ct-chat-widget {
        width: 100%;
    }

    .ct-chat-widget {
        border-radius: 0;
        border-left: none;
        border-right: none;
        height: calc(100vh - 100px);
    }

    .ct-message {
        max-width: 92%;
    }

    .ct-reg-card {
        margin: 1rem;
        padding: 1.5rem;
    }
}
