* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.container {
    width: 100%;
    max-width: 800px;
}

/* Login Page Styles */
.login-card {
    background: white;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.login-card h1 {
    color: #333;
    margin-bottom: 10px;
    text-align: center;
}

.subtitle {
    color: #666;
    text-align: center;
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    color: #333;
    font-weight: 500;
    margin-bottom: 8px;
}

.form-group input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: border-color 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: #667eea;
}

.error-message {
    color: #e74c3c;
    font-size: 14px;
    margin-top: 5px;
    display: block;
    min-height: 20px;
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.4);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    padding: 10px 20px;
    background: #e0e0e0;
    color: #333;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

/* Chat Page Styles */
.chat-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    height: 80vh;
    max-height: 700px;
}

.chat-header {
    padding: 20px;
    border-bottom: 2px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h1 {
    color: #333;
    font-size: 24px;
}

.notification-banner {
    background: #4caf50;
    color: white;
    padding: 15px 20px;
    text-align: center;
    font-weight: 500;
}

.notification-banner.hidden {
    display: none;
}

.completion-message {
    background: #e8f5e9;
    border-left: 4px solid #4caf50;
    padding: 15px 20px;
    margin: 15px 20px;
    border-radius: 4px;
}

.completion-message.hidden {
    display: none;
}

.completion-message {
    background: #e8f5e9;
    border-left: 4px solid #4caf50;
    padding: 15px 20px;
    margin: 15px 20px;
    border-radius: 4px;
}

.completion-message.hidden {
    display: none;
}

.message-list {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.message {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
}

.message.user {
    align-self: flex-end;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

.message.ai {
    align-self: flex-start;
    background: #f5f5f5;
    color: #333;
    border-bottom-left-radius: 4px;
}

.message.therapist {
    align-self: flex-start;
    background: #e3f2fd;
    color: #333;
    border-bottom-left-radius: 4px;
    border-left: 4px solid #2196f3;
}

.message-sender {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    opacity: 0.8;
}

.message-content {
    line-height: 1.5;
    white-space: pre-wrap;
}

.message-time {
    font-size: 11px;
    margin-top: 4px;
    opacity: 0.7;
}

.chat-input-container {
    padding: 20px;
    border-top: 2px solid #e0e0e0;
    display: flex;
    gap: 10px;
}

#messageInput {
    flex: 1;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    font-family: inherit;
    resize: none;
    transition: border-color 0.3s;
}

#messageInput:focus {
    outline: none;
    border-color: #667eea;
}

.chat-input-container .btn-primary {
    width: auto;
    padding: 12px 30px;
}

/* Scrollbar Styles */
.message-list::-webkit-scrollbar {
    width: 8px;
}

.message-list::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.message-list::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.message-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Typing Indicator (Animated Ellipsis) */
.typing-indicator {
    align-self: flex-start;
    background: #f5f5f5;
    color: #333;
    padding: 12px 16px;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #999;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Status Messages (Error and Completion) */
.status-message {
    padding: 15px 20px;
    margin: 0 20px 15px 20px;
    border-radius: 8px;
    font-weight: 500;
    text-align: center;
}

.status-message.error {
    background: #fee;
    border: 2px solid #fcc;
    color: #c00;
}

.status-message.completion {
    background: #e8f5e9;
    border: 2px solid #4caf50;
    color: #2e7d32;
}

.status-message.hidden {
    display: none;
}

/* Responsive Design */
@media (max-width: 600px) {
    .login-card {
        padding: 30px 20px;
    }
    
    .chat-container {
        height: 90vh;
    }
    
    .chat-header h1 {
        font-size: 18px;
    }
    
    .message {
        max-width: 85%;
    }
}

/* Completion message styles */
.status-message.completion {
    background-color: #e8f5e9;
    border: 1px solid #4caf50;
    padding: 16px;
    border-radius: 8px;
    margin: 16px 0;
    text-align: center;
    color: #2e7d32;
    font-weight: 500;
}

.status-message.error {
    background-color: #ffebee;
    border: 1px solid #f44336;
    padding: 16px;
    border-radius: 8px;
    margin: 16px 0;
    text-align: center;
    color: #c62828;
    font-weight: 500;
}

/* New chat button */
.new-chat-container {
    padding: 16px 20px;
    text-align: center;
}

.btn-new-chat {
    max-width: 300px;
    margin: 0 auto;
}

/* Conversation history section */
.conversation-history {
    border-top: 1px solid #e0e0e0;
    padding: 12px 20px;
}

.conversation-history .btn-toggle {
    width: 100%;
    padding: 10px;
    background: #f5f5f5;
    color: #666;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    text-align: left;
}

.conversation-history .btn-toggle:hover {
    background: #e8e8e8;
}

.history-list {
    margin-top: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.history-list.collapsed {
    display: none;
}

.history-item {
    background: #f9f9f9;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    padding: 12px 16px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: background 0.2s;
}

.history-item:hover {
    background: #f0f0f0;
}

.history-item-date {
    font-size: 13px;
    color: #333;
    font-weight: 500;
}

.history-item-status {
    font-size: 12px;
    color: #666;
    margin-top: 2px;
}

.history-item-preview {
    font-size: 12px;
    color: #999;
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* History conversation view */
.history-back-btn {
    margin-bottom: 10px;
    font-size: 13px;
    padding: 6px 12px;
}

.history-label {
    text-align: center;
    color: #999;
    font-size: 12px;
    padding: 8px;
    background: #f5f5f5;
    border-radius: 6px;
    margin-bottom: 10px;
}

/* Progress bar */
.progress-bar-container {
    width: 100%;
    height: 4px;
    background: #e0e0e0;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: #4caf50;
    transition: width 0.6s ease;
    width: 0%;
}

/* Login logo */
.login-logo {
    text-align: center;
    margin-bottom: 20px;
}

.logo-img {
    max-width: 180px;
    height: auto;
}

/* Login footer */
.login-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 16px;
    border-top: 1px solid #e0e0e0;
}

.login-footer a {
    color: #666;
    font-size: 13px;
    text-decoration: none;
    margin: 0 8px;
}

.login-footer a:hover {
    color: #2196f3;
    text-decoration: underline;
}

/* Terms page */
.terms-card {
    background: white;
    border-radius: 12px;
    padding: 40px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    margin: 20px auto;
    max-width: 700px;
}

.terms-card h1 {
    color: #333;
    text-align: center;
    margin-bottom: 8px;
}

.terms-updated {
    text-align: center;
    color: #999;
    font-size: 13px;
    margin-bottom: 24px;
}

.terms-content h2 {
    color: #333;
    font-size: 16px;
    margin-top: 20px;
    margin-bottom: 8px;
}

.terms-content p {
    color: #555;
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 8px;
}

.terms-contact {
    margin-top: 24px;
    padding: 16px;
    background: #f5f5f5;
    border-radius: 8px;
}

.terms-contact a {
    color: #2196f3;
}

.terms-footer {
    text-align: center;
    margin-top: 24px;
}

/* Terms acceptance modal */
.terms-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.terms-modal {
    background: white;
    border-radius: 12px;
    padding: 32px;
    max-width: 420px;
    width: 90%;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.terms-modal p {
    color: #333;
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 24px;
}

.terms-modal a {
    color: #2196f3;
    text-decoration: underline;
}

.terms-modal-actions {
    display: flex;
    gap: 12px;
}

.terms-modal-actions .btn-primary {
    flex: 1;
}

.btn-grey {
    flex: 1;
    padding: 14px;
    background: #e0e0e0;
    color: #666;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
}

.btn-grey:hover {
    background: #d0d0d0;
}

/* Video Session Styles */
.video-button-container {
    padding: 12px 20px;
    text-align: center;
}

.btn-video {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #4caf50 0%, #2e7d32 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn-video:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(76, 175, 80, 0.4);
}

.btn-video:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.video-session-container {
    background: #1a1a2e;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    height: 80vh;
    max-height: 700px;
    overflow: hidden;
    position: relative;
}

.waiting-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: white;
    text-align: center;
}

.waiting-content p {
    font-size: 18px;
    margin: 20px 0;
    color: #e0e0e0;
}

.waiting-animation {
    display: flex;
    gap: 8px;
    justify-content: center;
}

.waiting-animation span {
    width: 12px;
    height: 12px;
    background: #4caf50;
    border-radius: 50%;
    animation: waitingPulse 1.4s infinite;
}

.waiting-animation span:nth-child(2) {
    animation-delay: 0.2s;
}

.waiting-animation span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes waitingPulse {
    0%, 60%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    30% {
        transform: scale(1.3);
        opacity: 1;
    }
}

.video-area {
    flex: 1;
    position: relative;
    background: #000;
}

.remote-video-container {
    width: 100%;
    height: 100%;
}

.remote-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #222;
}

.local-video-container {
    position: absolute;
    bottom: 16px;
    right: 16px;
    width: 160px;
    height: 120px;
    border-radius: 8px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
}

.local-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #333;
}

.video-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: rgba(0, 0, 0, 0.8);
}

.btn-control {
    padding: 12px 20px;
    border: none;
    border-radius: 50px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn-control:hover {
    transform: scale(1.05);
}

.btn-mic-on, .btn-camera-on {
    background: #444;
    color: white;
}

.btn-mic-off, .btn-camera-off {
    background: #e74c3c;
    color: white;
}

.btn-end-session {
    background: #e74c3c;
    color: white;
    padding: 12px 24px;
}

.btn-end-session:hover {
    background: #c0392b;
}

.video-status-message {
    text-align: center;
    padding: 12px;
    color: #ffc107;
    background: rgba(0, 0, 0, 0.6);
    font-size: 14px;
}

@media (max-width: 600px) {
    .local-video-container {
        width: 100px;
        height: 75px;
        bottom: 8px;
        right: 8px;
    }

    .video-controls {
        gap: 10px;
        padding: 12px;
    }

    .btn-control {
        padding: 10px 14px;
        font-size: 14px;
    }
}
