/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

.container {
    max-width: 800px;
    width: 100%;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

/* Header */
header {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    padding: 30px;
    text-align: center;
}

header h1 {
    font-size: 2.5rem;
    margin-bottom: 10px;
    font-weight: 700;
}

header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Chat Container */
.chat-container {
    height: 500px;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.message {
    display: flex;
    margin-bottom: 20px;
    align-items: flex-start;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    font-size: 20px;
    flex-shrink: 0;
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .message-avatar {
    margin-right: 0;
    margin-left: 12px;
}

.user-message .message-content {
    background: #007bff;
    color: white;
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: 18px;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    position: relative;
}

.message-content p {
    margin: 0;
    line-height: 1.4;
}

.user-message .message-content::after {
    content: '';
    position: absolute;
    top: 15px;
    right: -8px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-left-color: #007bff;
    border-right: 0;
    border-bottom: 0;
}

.bot-message .message-content::after {
    content: '';
    position: absolute;
    top: 15px;
    left: -8px;
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-right-color: white;
    border-left: 0;
    border-bottom: 0;
}

/* Chat Input */
.chat-input {
    display: flex;
    padding: 20px;
    background: white;
    border-top: 1px solid #e9ecef;
}

#messageInput {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #dee2e6;
    border-radius: 25px;
    font-family: inherit;
    font-size: 16px;
    margin-right: 12px;
}

#messageInput:focus {
    outline: none;
    border-color: #4facfe;
    box-shadow: 0 0 0 3px rgba(79, 172, 254, 0.1);
}

#sendButton {
    padding: 12px 24px;
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

#sendButton:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(79, 172, 254, 0.3);
}

#sendButton:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Status */
.status {
    padding: 10px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e9ecef;
    text-align: center;
}

#statusText {
    color: #6c757d;
    font-size: 14px;
}

/* Confetti Canvas */
#confettiCanvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1000;
}

/* Loading animation */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.5; }
    100% { opacity: 1; }
}

.loading {
    animation: pulse 1.5s infinite;
}

/* Success message styling */
.success-message {
    background: linear-gradient(135deg, #28a745, #20c997) !important;
    color: white !important;
    border: 2px solid #28a745;
}

.success-message::after {
    border-right-color: #28a745 !important;
}

/* Responsive design */

/* Mobile styles - general */
@media (max-width: 768px) {
    body {
        padding: 10px;
    }

    .container {
        margin: 0;
        border-radius: 15px;
        max-width: 100%;
    }

    header {
        padding: 20px 15px;
    }

    header h1 {
        font-size: 1.8rem;
        margin-bottom: 8px;
    }

    header p {
        font-size: 1rem;
    }

    .chat-container {
        height: calc(100vh - 200px);
        max-height: 500px;
    }

    .chat-messages {
        padding: 15px;
    }

    .message {
        margin-bottom: 15px;
    }

    .message-avatar {
        width: 35px;
        height: 35px;
        font-size: 18px;
        margin-right: 8px;
    }

    .user-message .message-avatar {
        margin-left: 8px;
        margin-right: 0;
    }

    .message-content {
        max-width: 80%;
        padding: 10px 14px;
        font-size: 15px;
    }

    .user-message .message-content::after {
        right: -6px;
        border-width: 6px;
        border-left-color: #007bff;
    }

    .bot-message .message-content::after {
        left: -6px;
        border-width: 6px;
        border-right-color: white;
    }

    .chat-input {
        padding: 15px;
        flex-wrap: wrap;
        gap: 10px;
    }

    #messageInput {
        flex: 1;
        min-width: 200px;
        font-size: 16px; /* Prevents zoom on iOS */
        padding: 12px 16px;
        margin-right: 0;
        margin-bottom: 0;
    }

    #sendButton {
        padding: 12px 20px;
        min-width: 80px;
        font-size: 14px;
    }

    .status {
        padding: 8px 15px;
    }

    #statusText {
        font-size: 13px;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    header {
        padding: 15px 12px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    header p {
        font-size: 0.9rem;
    }

    .chat-container {
        height: calc(100vh - 180px);
    }

    .chat-messages {
        padding: 12px;
    }

    .message-content {
        max-width: 85%;
        padding: 8px 12px;
        font-size: 14px;
    }

    .message-avatar {
        width: 30px;
        height: 30px;
        font-size: 16px;
    }

    .chat-input {
        padding: 12px;
        flex-direction: column;
        align-items: stretch;
    }

    #messageInput {
        margin-bottom: 8px;
        border-radius: 20px;
    }

    #sendButton {
        align-self: flex-end;
        width: 100%;
        border-radius: 20px;
    }

    .status {
        padding: 6px 12px;
    }
}

/* Extra small devices */
@media (max-width: 360px) {
    body {
        padding: 5px;
    }

    .container {
        border-radius: 10px;
    }

    header {
        padding: 12px 10px;
    }

    header h1 {
        font-size: 1.3rem;
    }

    header p {
        font-size: 0.85rem;
    }

    .chat-container {
        height: calc(100vh - 160px);
    }

    .chat-messages {
        padding: 10px;
    }

    .message {
        margin-bottom: 12px;
    }

    .message-content {
        max-width: 88%;
        padding: 6px 10px;
        font-size: 13px;
    }

    .chat-input {
        padding: 10px;
    }

    #messageInput {
        padding: 10px 14px;
    }

    #sendButton {
        padding: 10px 18px;
        font-size: 13px;
    }
}

/* Landscape orientation for mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .chat-container {
        height: 300px;
    }

    header {
        padding: 15px;
    }

    header h1 {
        font-size: 1.5rem;
    }

    .chat-messages {
        padding: 12px;
    }

    .message {
        margin-bottom: 10px;
    }

    .message-content {
        max-width: 75%;
        padding: 8px 12px;
        font-size: 14px;
    }
}

/* Touch-friendly interactions */
@media (hover: none) and (pointer: coarse) {
    #sendButton:hover {
        transform: none;
        box-shadow: 0 2px 6px rgba(79, 172, 254, 0.2);
    }

    #sendButton:active {
        transform: scale(0.98);
        box-shadow: 0 2px 6px rgba(79, 172, 254, 0.3);
    }

    #messageInput:focus {
        box-shadow: 0 0 0 2px rgba(79, 172, 254, 0.3);
    }

    .message-content {
        touch-action: manipulation;
    }

    /* Ensure buttons are touch-friendly */
    #sendButton {
        touch-action: manipulation;
        -webkit-tap-highlight-color: rgba(79, 172, 254, 0.2);
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .container {
        border: 2px solid #000;
    }

    .message-content {
        border: 1px solid #000;
    }

    #messageInput {
        border: 2px solid #000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    #sendButton:hover {
        transform: none;
    }
}
