/* =========================================================
   ENHANCED CHATBOT CSS - MOBILE-FIRST RESPONSIVE DESIGN
   Premium UI/UX with Modern Aesthetics
   ========================================================= */

/* ===== BASE RESET & VARIABLES ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Dynamic branding CSS variables */
:root {
    --brand-primary: #0C3C64;
    --brand-secondary: #6c757d;
    --brand-accent: #ffde59;
    
    /* Enhanced spacing system */
    --spacing-xs: 4px;
    --spacing-sm: 8px;
    --spacing-md: 12px;
    --spacing-lg: 16px;
    --spacing-xl: 20px;
    
    /* Enhanced border radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-full: 50%;
    
    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.12);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.15);
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;
    --transition-slow: 0.3s ease;
}

/* ===== BODY ===== */
body {
    background-color: #f8f9fa;
    min-height: 100vh;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== CHAT WIDGET - FULLY RESPONSIVE FOR IFRAME ===== */
.chat-widget {
    /* REMOVED max-width constraint - now fully responsive to container */
    width: 100%;
    min-width: 280px; /* Minimum for mobile readability */
    height: 500px;
    max-height: calc(100dvh - 120px - env(safe-area-inset-bottom, 20px));
    
    /* Positioning */
    position: fixed !important;
    bottom: calc(100px + env(safe-area-inset-bottom, 20px)) !important;
    right: calc(20px + env(safe-area-inset-right, 10px)) !important;
    z-index: 1001;
    
    /* Layout */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    
    /* Styling */
    background: #ffffff;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    
    /* Transitions */
    transition: all var(--transition-slow);
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
}

/* Visible state */
.chat-widget.visible {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Minimized state */
.chat-widget.minimized {
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
}

/* ===== CHAT HEADER ===== */
.chat-header {
    background-color: var(--brand-primary) !important;
    padding: var(--spacing-md) var(--spacing-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    min-height: 56px;
}

.ai-header-left {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
    flex: 1;
    min-width: 0; /* Allow text truncation */
}

.ai-header-title {
    display: flex;
    align-items: center;
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
    order: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Avatar styling */
.ai-avatar,
.bot-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: inline-flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    flex-shrink: 0;
    background: rgba(255, 255, 255, 0.1);
    transition: transform var(--transition-base);
}

.ai-avatar {
    order: 2;
}

.ai-avatar:hover {
    transform: scale(1.05);
}

.bot-avatar img,
.ai-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-full);
}

/* Header controls */
.header-controls {
    display: flex;
    gap: var(--spacing-sm);
    margin-left: auto;
    flex-shrink: 0;
}

.control-button {
    background: rgba(255, 255, 255, 0.15);
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border-radius: var(--radius-sm);
    transition: all var(--transition-base);
}

.control-button:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: scale(1.05);
}

.control-button:active {
    transform: scale(0.95);
}

/* Built-in badge */
.built-in-badge {
    background-color: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: var(--radius-lg);
    padding: 2px 8px;
    font-size: 11px;
    margin-left: var(--spacing-sm);
    color: #ffffff;
    font-weight: 500;
}

/* ===== STATUS MESSAGE ===== */
.status-message {
    padding: var(--spacing-sm) var(--spacing-lg);
    background-color: #f8f9fa;
    border-bottom: 1px solid #e9ebed;
    font-size: 12px;
    color: #545b64;
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.status-icon {
    width: 8px;
    height: 8px;
    background-color: #2cbb5d;
    border-radius: var(--radius-full);
    margin-right: 6px;
    animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ===== CONVERSATION AREA ===== */
.conversation {
    flex: 1 1 auto;
    overflow-y: auto;
    overflow-x: hidden;
    padding: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-lg);
    background-color: #ffffff;
    scroll-behavior: smooth;
}

/* Custom scrollbar */
.conversation::-webkit-scrollbar {
    width: 6px;
}

.conversation::-webkit-scrollbar-track {
    background: transparent;
}

.conversation::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
    transition: background var(--transition-base);
}

.conversation::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* Firefox scrollbar */
.conversation {
    scrollbar-width: thin;
    scrollbar-color: rgba(0, 0, 0, 0.15) transparent;
}

/* ===== MESSAGE BUBBLES ===== */
.message {
    display: flex;
    max-width: 100%;
    animation: messageSlideIn 0.3s ease-out;
}

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

.user-message {
    justify-content: flex-end;
}

.bot-message {
    justify-content: flex-start;
}

/* Avatar container */
.avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    display: flex;
    justify-content: center;
    align-items: center;
    margin-right: var(--spacing-md);
    flex-shrink: 0;
    background: #e9ebed;
}

.bot-avatar {
    width: 36px;
    height: 36px;
    margin-right: var(--spacing-sm);
}

.user-avatar {
    background-color: #e9ebed;
}

/* Message content */
.message-content {
    max-width: calc(100% - 48px);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    min-width: 0; /* Allow proper text wrapping */
}

/* Message bubble styling */
.message-bubble {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 14px;
    line-height: 1.5;
    color: #232f3e;
    max-width: 100%;
    display: inline-block;
    word-wrap: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    transition: all var(--transition-base);
}

/* User message bubble - Light blue (soft and readable) */
.user-message .message-bubble {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    border: 1px solid #90caf9;
    border-radius: var(--radius-md) var(--radius-md) var(--radius-sm) var(--radius-md);
    color: #1565c0;
    box-shadow: var(--shadow-sm);
}

/* Bot message bubble - Keep as is */
.bot-message .message-bubble {
    background-color: #f8f9fa;
    border: 1px solid #e9ebed;
    border-radius: var(--radius-md) var(--radius-md) var(--radius-md) var(--radius-sm);
    box-shadow: var(--shadow-sm);
}

.welcome-message {
    font-size: 14px !important;
    line-height: 1.6;
}

/* Text formatting */
.message-bubble strong {
    font-weight: 600;
    color: inherit;
}

.message-bubble ul,
.message-bubble ol {
    padding-left: 20px;
    margin: var(--spacing-sm) 0;
}

.message-bubble li {
    margin-bottom: 4px;
}

/* ===== SUGGESTION BUTTONS ===== */
.suggestion-container {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    margin-top: var(--spacing-xs);
}

.suggestion-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
    width: 100%;
    align-items: flex-start;
}

.suggestion-button {
    background: linear-gradient(135deg, #e6e6fa 0%, #d8d8f6 100%);
    border: 1px solid #c8c8ec;
    color: #161d26;
    border-radius: var(--radius-lg);
    padding: 10px 14px;
    line-height: 1.4;
    text-align: left;
    cursor: pointer;
    transition: all var(--transition-base);
    width: auto;
    max-width: 100%;
    display: inline-block;
    font-size: 13px;
    font-weight: 500;
    box-shadow: var(--shadow-sm);
}

.suggestion-button:hover {
    background: linear-gradient(135deg, #dadaf8 0%, #c8c8f0 100%);
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.suggestion-button:active {
    transform: translateY(0);
}

/* ===== INPUT CONTAINER ===== */
.input-container {
    padding: var(--spacing-md);
    background-color: #ffffff;
    border-top: 1px solid #e9ebed;
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    background-color: #f8f9fa;
    border: 2px solid #e9ebed;
    border-radius: var(--radius-md);
    padding: 6px 10px;
    transition: all var(--transition-base);
}

.input-wrapper:focus-within {
    background-color: #ffffff;
    border-color: #0972d3;
    box-shadow: 0 0 0 3px rgba(9, 114, 211, 0.1);
}

#message-input {
    flex: 1 1 auto;
    border: none;
    outline: none;
    background: transparent;
    padding: 8px 10px;
    font-size: 14px;
    color: #232f3e;
    resize: none;
    font-family: inherit;
    overflow-y: auto;
    max-height: 120px;
    min-height: 40px;
    line-height: 1.5;
}

#message-input::placeholder {
    color: #687078;
}

/* Custom scrollbar for input */
#message-input::-webkit-scrollbar {
    width: 4px;
}

#message-input::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
}

/* Send button - Enhanced for FontAwesome icon with smart color contrast */
#send-button {
    width: 36px;
    height: 36px;
    background-color: var(--brand-accent) !important;
    border-radius: var(--radius-full);
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all var(--transition-base);
    align-self: center;
    margin-left: var(--spacing-sm);
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

#send-button:hover:not(:disabled) {
    background-color: var(--brand-accent) !important;
    transform: scale(1.08);
    box-shadow: var(--shadow-md);
}

#send-button:active:not(:disabled) {
    transform: scale(0.95);
}

#send-button:disabled {
    background-color: #e9ebed !important;
    cursor: not-allowed;
    opacity: 0.6;
}

/* FontAwesome paper plane icon styling with smart contrast */
#send-button i,
#send-button .fa-paper-plane {
    font-size: 14px;
    transition: color var(--transition-base);
}

/* Default icon color - Smart contrast based on accent color lightness */
/* For light accent colors (like #ffde59), use dark icon */
#send-button i,
#send-button .fa-paper-plane {
    color: #ffffff;
}

/* For dark accent colors, use light icon - Add this class to button when needed */
#send-button.dark-accent i,
#send-button.dark-accent .fa-paper-plane {
    color: #ffffff;
}

/* Hover state - Always white on pink hover */
#send-button:hover:not(:disabled) i,
#send-button:hover:not(:disabled) .fa-paper-plane {
    color: #ffffff;
}

/* Disabled state */
#send-button:disabled i,
#send-button:disabled .fa-paper-plane {
    color: #999999;
}

/* Legacy support for arrow-icon class (if still used) */
.arrow-icon {
    color: #000000;
    transition: color var(--transition-base);
}

#send-button:hover:not(:disabled) .arrow-icon {
    color: #ffffff;
}

/* ===== FOOTER ===== */
.ai-footer {
    padding: var(--spacing-sm);
    text-align: center;
    font-size: 11px;
    color: #687078;
    flex-shrink: 0;
    background: #ffffff;
}

.ai-footer a {
    color: #0972d3;
    text-decoration: none;
    transition: color var(--transition-base);
}

.ai-footer a:hover {
    color: #075aad;
    text-decoration: underline;
}

/* ===== CHAT TOGGLE BUTTON ===== */
.chat-toggle-button {
    position: fixed !important;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
    right: calc(20px + env(safe-area-inset-right, 0px)) !important;
    width: 60px;
    height: 60px;
    border-radius: var(--radius-full);
    background-color: var(--brand-accent);
    color: #000000;
    border: none;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    transition: all var(--transition-base);
}

.chat-toggle-button:hover {
    background-color: #fb5b8f;
    color: #ffffff;
    transform: scale(1.08);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.2);
}

.chat-toggle-button:active {
    transform: scale(0.95);
}

/* ===== FORMS ===== */
.inquiry-form {
    border-radius: var(--radius-md);
    background-color: #f8f9fa;
    padding: var(--spacing-md);
    margin: var(--spacing-xs) 0;
}

.inquiry-form p {
    margin-bottom: var(--spacing-lg);
    color: #232f3e;
    font-size: 14px;
    line-height: 1.5;
}

.form-group {
    margin-bottom: var(--spacing-md);
}

.form-group label {
    font-weight: 600;
    color: #232f3e;
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid #d9d9d9;
    border-radius: var(--radius-sm);
    box-sizing: border-box;
    font-family: inherit;
    font-size: 14px;
    transition: all var(--transition-base);
    background: #ffffff;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #0972d3;
    box-shadow: 0 0 0 3px rgba(9, 114, 211, 0.1);
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

.form-group input[type="submit"] {
    background-color: #0972d3;
    color: #ffffff;
    border: none;
    cursor: pointer;
    padding: 12px 24px;
    font-weight: 600;
    transition: all var(--transition-base);
    box-shadow: var(--shadow-sm);
}

.form-group input[type="submit"]:hover {
    background-color: #075aad;
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.form-group input[type="submit"]:active {
    transform: translateY(0);
}

.form-group input[type="submit"]:disabled {
    background-color: #cccccc;
    cursor: not-allowed;
    opacity: 0.6;
    transform: none;
}

.form-group input[type="file"] {
    padding: 8px;
    border: 2px dashed #d9d9d9;
    background-color: #ffffff;
    cursor: pointer;
}

.form-group input[type="file"]:hover {
    border-color: #0972d3;
}

/* ===== CONFIRMATION & ERROR MESSAGES ===== */
.inquiry-confirmation,
.application-confirmation,
.error-message,
.success-message {
    padding: var(--spacing-md);
    border-radius: var(--radius-sm);
    margin: var(--spacing-sm) 0;
    font-size: 14px;
    line-height: 1.5;
    animation: messageSlideIn 0.3s ease-out;
}

.inquiry-confirmation,
.application-confirmation,
.success-message {
    background-color: #f0f7ff;
    border-left: 4px solid #0972d3;
    color: #232f3e;
}

.error-message {
    background-color: #fff0f0;
    border-left: 4px solid #d13212;
    color: #d13212;
}

.success-message {
    text-align: center;
    padding: var(--spacing-xl);
}

.success-icon {
    font-size: 48px;
    color: #0972d3;
    margin-bottom: var(--spacing-md);
    font-weight: bold;
}

.success-note {
    font-size: 12px !important;
    color: #5c6670 !important;
    margin-top: var(--spacing-md) !important;
}

/* ===== TYPING INDICATOR ===== */
.typing-message {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.typing-text {
    font-size: 13px;
    color: #5c6670;
}

.typing-animation {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #e0e0e0;
    border-top: 2px solid #0972d3;
    border-radius: var(--radius-full);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== SPINNER ===== */
.spinner {
    width: 20px;
    height: 20px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-radius: var(--radius-full);
    border-top-color: #0972d3;
    animation: spin 1s ease-in-out infinite;
    display: inline-block;
}

.processing-message {
    color: #555;
    font-style: italic;
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

/* ===== POPUPS ===== */
.blur-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 5;
    backdrop-filter: blur(2px);
    animation: fadeIn 0.2s ease;
}

.chat-popup {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #ffffff;
    padding: var(--spacing-xl);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    text-align: center;
    z-index: 10;
    max-width: 90%;
    width: 300px;
    animation: popupSlideIn 0.3s ease-out;
}

@keyframes popupSlideIn {
    from {
        opacity: 0;
        transform: translate(-50%, -45%);
    }
    to {
        opacity: 1;
        transform: translate(-50%, -50%);
    }
}

.chat-popup-header {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: var(--spacing-md);
    color: #232f3e;
}

.chat-popup-close {
    position: absolute;
    top: var(--spacing-md);
    right: var(--spacing-md);
    cursor: pointer;
    font-size: 20px;
    color: #666;
    transition: color var(--transition-base);
}

.chat-popup-close:hover {
    color: #000;
}

.chat-popup-buttons {
    margin-top: var(--spacing-lg);
    display: flex;
    justify-content: flex-end;
    gap: var(--spacing-md);
}

.chat-popup-No,
.chat-popup-Yes {
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-base);
}

.chat-popup-No {
    background-color: #f0f0f0;
    color: #232f3e;
}

.chat-popup-Yes {
    background-color: var(--brand-accent);
    color: #000000;
}

.chat-popup-No:hover {
    background-color: #e0e0e0;
}

.chat-popup-Yes:hover {
    background-color: #fb5b8f;
    color: #ffffff;
}

/* ===== DISCLAIMER POPUP ===== */
.disclaimer-popup {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.6);
    animation: fadeIn 0.3s;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(3px);
}

.disclaimer-content {
    background-color: #fefefe;
    padding: var(--spacing-xl);
    border: none;
    width: 90%;
    max-width: 700px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s;
    margin: 0 auto;
    position: relative;
}

.disclaimer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid #eee;
    padding-bottom: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.disclaimer-header h2 {
    margin: 0;
    color: #333;
    font-size: 20px;
}

.disclaimer-body {
    max-height: 60vh;
    overflow-y: auto;
    padding-right: var(--spacing-md);
}

.disclaimer-body p {
    margin-bottom: var(--spacing-lg);
    line-height: 1.6;
    color: #444;
}

.close-btn {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    background: none;
    border: none;
    cursor: pointer;
    transition: color var(--transition-base);
}

.close-btn:hover,
.close-btn:focus {
    color: #000;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* ===== ANIMATIONS ===== */
#chat-widget.visible {
    animation: slideInFromAboveButton 0.4s ease-out forwards;
}

#chat-widget.minimized {
    animation: slideOutToAboveButton 0.3s ease-in forwards;
}

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

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

/* ===== RESPONSIVE DESIGN - TABLET ===== */
@media (max-width: 768px) {
    .chat-widget {
        width: 95%;
        min-width: 280px;
        height: 500px;
        max-height: 75vh;
        right: 2.5%;
        bottom: calc(90px + env(safe-area-inset-bottom, 0px));
    }
    
    .chat-header {
        padding: var(--spacing-md);
    }
    
    .ai-header-title {
        font-size: 15px;
    }
    
    .control-button {
        width: 30px;
        height: 30px;
        font-size: 18px;
    }
    
    .chat-toggle-button {
        width: 56px;
        height: 56px;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px)) !important;
        right: calc(16px + env(safe-area-inset-right, 0px)) !important;
    }
}

/* ===== RESPONSIVE DESIGN - MOBILE ===== */
@media (max-width: 480px) {
    .chat-widget {
        width: 95%;
        min-width: 280px;
        height: 85vh;
        max-height: calc(100vh - 100px);
        bottom: calc(80px + env(safe-area-inset-bottom, 0px)) !important;
        right: 2.5% !important;
        left: 2.5%;
        margin: 0 auto;
        border-radius: var(--radius-md);
    }
    
    .chat-header {
        padding: var(--spacing-sm) var(--spacing-md);
        min-height: 52px;
    }
    
    .ai-header-title {
        font-size: 14px;
    }
    
    .ai-avatar,
    .bot-avatar {
        width: 32px;
        height: 32px;
    }
    
    .control-button {
        width: 28px;
        height: 28px;
        font-size: 16px;
    }
    
    .conversation {
        padding: var(--spacing-sm);
        gap: var(--spacing-md);
    }
    
    .message-bubble {
        padding: 9px 12px;
        font-size: 13px;
    }
    
    .suggestion-button {
        padding: 9px 12px;
        font-size: 12px;
    }
    
    .input-container {
        padding: var(--spacing-sm);
    }
    
    #message-input {
        font-size: 14px;
        max-height: 100px;
        padding: 7px 9px;
    }
    
    #send-button {
        width: 32px;
        height: 32px;
    }
    
    #send-button i,
    #send-button .fa-paper-plane {
        font-size: 13px;
    }
    
    .chat-toggle-button {
        width: 52px;
        height: 52px;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px)) !important;
        right: calc(12px + env(safe-area-inset-right, 0px)) !important;
    }
    
    .form-group input,
    .form-group select,
    .form-group textarea {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* ===== RESPONSIVE DESIGN - SMALL MOBILE ===== */
@media (max-width: 360px) {
    .chat-widget {
        width: 98%;
        min-width: 280px;
        right: 1% !important;
        left: 1%;
    }
    
    .ai-header-title {
        font-size: 13px;
    }
    
    .ai-avatar,
    .bot-avatar {
        width: 28px;
        height: 28px;
    }
    
    .control-button {
        width: 26px;
        height: 26px;
        font-size: 15px;
    }
    
    .message-bubble {
        padding: 8px 10px;
        font-size: 12px;
    }
    
    .built-in-badge {
        font-size: 10px;
        padding: 1px 6px;
    }
}

/* ===== LANDSCAPE MODE ===== */
@media screen and (orientation: landscape) and (max-height: 500px) {
    .chat-widget {
        height: 90vh;
        width: 60%;
        min-width: 400px;
        right: 20%;
    }
    
    .conversation {
        max-height: 60vh;
    }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus visible for keyboard navigation */
.control-button:focus-visible,
.suggestion-button:focus-visible,
#send-button:focus-visible,
.chat-toggle-button:focus-visible {
    outline: 3px solid #0972d3;
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .chat-widget {
        border: 2px solid currentColor;
    }
    
    .message-bubble {
        border-width: 2px;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .chat-widget,
    .chat-toggle-button {
        display: none !important;
    }
}