/**
 * AI Hiring Manager Chatbot Styles - Mobile Optimized
 */

/* Main Container */
.ai-hiring-container {
    max-width: 100%;
    margin: 0;
    border: none;
    border-radius: 0;
    background: #ffffff;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    min-height: 100vh;
}

/* Desktop styles */
@media (min-width: 769px) {
    .ai-hiring-container {
        max-width: 800px;
        margin: 20px auto;
        border: 1px solid #ddd;
        border-radius: 12px;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
        min-height: auto;
        height: 600px;
    }
}

/* Header */
.ai-hiring-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
}

@media (min-width: 769px) {
    .ai-hiring-header {
        padding: 20px;
        gap: 15px;
        position: static;
    }
}

.ai-hiring-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

@media (min-width: 769px) {
    .ai-hiring-avatar {
        width: 50px;
        height: 50px;
        font-size: 24px;
    }
}

.ai-hiring-header-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.2;
}

@media (min-width: 769px) {
    .ai-hiring-header-info h3 {
        font-size: 18px;
    }
}

.ai-hiring-status {
    font-size: 12px;
    opacity: 0.9;
    margin-top: 2px;
    display: block;
    line-height: 1.2;
}

@media (min-width: 769px) {
    .ai-hiring-status {
        font-size: 14px;
        margin-top: 4px;
    }
}

/* Messages Area */
.ai-hiring-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f8f9fa;
    -webkit-overflow-scrolling: touch;
}

@media (min-width: 769px) {
    .ai-hiring-messages {
        padding: 20px;
        min-height: 300px;
        max-height: 400px;
    }
}

.ai-hiring-message {
    display: flex;
    margin-bottom: 16px;
    align-items: flex-start;
    gap: 8px;
}

@media (min-width: 769px) {
    .ai-hiring-message {
        gap: 12px;
    }
}

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

.ai-hiring-message-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

@media (min-width: 769px) {
    .ai-hiring-message-avatar {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
}

.ai-hiring-message-content {
    max-width: 85%;
}

@media (min-width: 769px) {
    .ai-hiring-message-content {
        max-width: 70%;
    }
}

.ai-hiring-message-bubble {
    padding: 10px 14px;
    border-radius: 16px;
    line-height: 1.4;
    word-wrap: break-word;
    font-size: 14px;
}

@media (min-width: 769px) {
    .ai-hiring-message-bubble {
        padding: 12px 16px;
        border-radius: 18px;
        font-size: 14px;
    }
}

.bot-message .ai-hiring-message-bubble {
    background: #ffffff;
    border: 1px solid #e1e5e9;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.user-message .ai-hiring-message-bubble {
    background: #667eea;
    color: white;
}

.ai-hiring-message-time {
    font-size: 10px;
    color: #8e8e93;
    margin-top: 4px;
    text-align: right;
}

@media (min-width: 769px) {
    .ai-hiring-message-time {
        font-size: 11px;
    }
}

.user-message .ai-hiring-message-time {
    text-align: left;
}

/* File Upload Area */
.ai-hiring-file-upload {
    padding: 16px;
    background: #f8f9fa;
    border-top: 1px solid #e1e5e9;
}

@media (min-width: 769px) {
    .ai-hiring-file-upload {
        padding: 20px;
    }
}

.ai-hiring-upload-section h4 {
    margin: 0 0 12px 0;
    color: #333;
    font-size: 14px;
}

@media (min-width: 769px) {
    .ai-hiring-upload-section h4 {
        margin: 0 0 16px 0;
        font-size: 16px;
    }
}

.ai-hiring-upload-item {
    margin-bottom: 12px;
}

@media (min-width: 769px) {
    .ai-hiring-upload-item {
        margin-bottom: 16px;
    }
}

.ai-hiring-upload-item label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    color: #555;
    font-size: 13px;
}

@media (min-width: 769px) {
    .ai-hiring-upload-item label {
        margin-bottom: 8px;
        font-size: 14px;
    }
}

.ai-hiring-file-input-wrapper {
    position: relative;
}

.ai-hiring-file-input-wrapper input[type="file"] {
    position: absolute;
    opacity: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.ai-hiring-file-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    border: 2px dashed #ddd;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px;
}

@media (min-width: 769px) {
    .ai-hiring-file-status {
        gap: 10px;
        padding: 12px 16px;
    }
}

.ai-hiring-file-status:hover {
    border-color: #667eea;
    background: #f0f2ff;
}

.ai-hiring-file-status.file-selected {
    border-color: #28a745;
    background: #f0fff4;
    border-style: solid;
}

.ai-hiring-file-icon {
    font-size: 18px;
    flex-shrink: 0;
}

@media (min-width: 769px) {
    .ai-hiring-file-icon {
        font-size: 20px;
    }
}

.ai-hiring-file-text {
    color: #666;
    font-size: 13px;
    line-height: 1.3;
}

@media (min-width: 769px) {
    .ai-hiring-file-text {
        font-size: 14px;
    }
}

/* Input Area */
.ai-hiring-input {
    padding: 16px;
    background: white;
    border-top: 1px solid #e1e5e9;
    position: sticky;
    bottom: 0;
}

@media (min-width: 769px) {
    .ai-hiring-input {
        padding: 20px;
        position: static;
    }
}

.ai-hiring-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: flex-end;
    margin-bottom: 12px;
}

@media (min-width: 769px) {
    .ai-hiring-input-wrapper {
        gap: 12px;
        margin-bottom: 12px;
    }
}

.ai-hiring-input-wrapper textarea {
    flex: 1;
    padding: 12px 14px;
    border: 1px solid #ddd;
    border-radius: 20px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    background: #f8f9fa;
    transition: all 0.3s ease;
    min-height: 44px;
    max-height: 120px;
}

@media (min-width: 769px) {
    .ai-hiring-input-wrapper textarea {
        padding: 12px 16px;
        font-size: 14px;
    }
}

.ai-hiring-input-wrapper textarea:focus {
    outline: none;
    border-color: #667eea;
    background: white;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.ai-hiring-input-wrapper textarea:disabled {
    background: #f0f0f0;
    color: #999;
    cursor: not-allowed;
}

/* Buttons */
.ai-hiring-btn {
    padding: 12px 16px;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
    min-height: 44px;
    box-sizing: border-box;
    touch-action: manipulation;
}

@media (min-width: 769px) {
    .ai-hiring-btn {
        padding: 10px 20px;
        font-size: 14px;
        min-height: auto;
    }
}

.ai-hiring-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ai-hiring-btn-primary {
    background: #667eea;
    color: white;
}

.ai-hiring-btn-primary:hover:not(:disabled) {
    background: #5a6fd8;
    transform: translateY(-1px);
}

.ai-hiring-btn-secondary {
    background: #6c757d;
    color: white;
}

.ai-hiring-btn-secondary:hover:not(:disabled) {
    background: #5a6268;
}

.ai-hiring-btn-send {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: #667eea;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    flex-shrink: 0;
}

.ai-hiring-btn-send:hover:not(:disabled) {
    background: #5a6fd8;
    transform: scale(1.05);
}

.ai-hiring-send-icon {
    font-size: 16px;
}

.ai-hiring-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
}

@media (min-width: 769px) {
    .ai-hiring-actions {
        gap: 12px;
        justify-content: flex-start;
    }
}

/* Make buttons stack vertically on small screens */
@media (max-width: 480px) {
    .ai-hiring-actions {
        flex-direction: column;
    }
    
    .ai-hiring-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Loading Indicator - Simplified and More Reliable */
.ai-hiring-loading {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    transform: translate(-50%, -50%) !important;
    background: #ffffff !important;
    border: 2px solid #667eea !important;
    border-radius: 12px !important;
    padding: 20px 24px !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2) !important;
    color: #333 !important;
    font-weight: 600 !important;
    font-size: 16px !important;
    z-index: 9999 !important;
    min-width: 200px !important;
    text-align: center !important;
    display: none !important;
}

.ai-hiring-loading.show {
    display: block !important;
}

/* Loading backdrop */
.ai-hiring-loading-backdrop {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: rgba(0, 0, 0, 0.3) !important;
    z-index: 9998 !important;
    display: none !important;
}

.ai-hiring-loading-backdrop.show {
    display: block !important;
}

@media (max-width: 768px) {
    .ai-hiring-loading {
        font-size: 14px !important;
        padding: 16px 20px !important;
        min-width: 180px !important;
        max-width: 280px !important;
        margin: 0 20px !important;
    }
}

.ai-hiring-loading-dots {
    display: inline-block;
    margin-right: 8px;
    vertical-align: middle;
}

.ai-hiring-loading-dots span {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    margin: 0 2px;
    animation: loading-dots 1.4s infinite ease-in-out both;
}

.ai-hiring-loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.ai-hiring-loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes loading-dots {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* Remove the old overlay styles */
.ai-hiring-loading-overlay {
    display: none !important;
}

/* Ensure container doesn't interfere */
.ai-hiring-container {
    position: relative;
}

/* Message Content Formatting */
.ai-hiring-message-bubble h3 {
    margin: 6px 0;
    font-size: 15px;
    color: #333;
    line-height: 1.3;
}

@media (min-width: 769px) {
    .ai-hiring-message-bubble h3 {
        margin: 8px 0;
        font-size: 16px;
    }
}

.ai-hiring-message-bubble h4 {
    margin: 4px 0;
    font-size: 13px;
    color: #555;
    line-height: 1.3;
}

@media (min-width: 769px) {
    .ai-hiring-message-bubble h4 {
        margin: 6px 0;
        font-size: 14px;
    }
}

.ai-hiring-message-bubble hr {
    margin: 10px 0;
    border: none;
    border-top: 1px solid #eee;
}

@media (min-width: 769px) {
    .ai-hiring-message-bubble hr {
        margin: 12px 0;
    }
}

.ai-hiring-message-bubble strong {
    font-weight: 600;
}

.ai-hiring-message-bubble em {
    font-style: italic;
}

/* Dark Theme */
.ai-hiring-container.theme-dark {
    background: #2c2c2e;
    border-color: #444;
}

.theme-dark .ai-hiring-messages {
    background: #1c1c1e;
}

.theme-dark .bot-message .ai-hiring-message-bubble {
    background: #2c2c2e;
    border-color: #444;
    color: #ffffff;
}

.theme-dark .ai-hiring-input {
    background: #2c2c2e;
    border-color: #444;
}

.theme-dark .ai-hiring-input-wrapper textarea {
    background: #1c1c1e;
    border-color: #444;
    color: #ffffff;
}

.theme-dark .ai-hiring-file-upload {
    background: #1c1c1e;
    border-color: #444;
}

.theme-dark .ai-hiring-file-status {
    background: #2c2c2e;
    border-color: #444;
    color: #ffffff;
}

/* iOS Safari specific fixes */
@supports (-webkit-touch-callout: none) {
    .ai-hiring-input {
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
    
    .ai-hiring-input-wrapper textarea {
        -webkit-appearance: none;
        border-radius: 20px;
    }
    
    .ai-hiring-btn {
        -webkit-appearance: none;
    }
}

/* Landscape orientation adjustments */
@media (orientation: landscape) and (max-height: 500px) {
    .ai-hiring-container {
        min-height: 100vh;
    }
    
    .ai-hiring-messages {
        max-height: none;
    }
    
    .ai-hiring-header {
        padding: 12px 16px;
    }
    
    .ai-hiring-avatar {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }
    
    .ai-hiring-header-info h3 {
        font-size: 14px;
    }
    
    .ai-hiring-status {
        font-size: 11px;
    }
}

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

/* High contrast mode support */
@media (prefers-contrast: high) {
    .ai-hiring-message-bubble {
        border-width: 2px;
    }
    
    .ai-hiring-btn {
        border: 2px solid currentColor;
    }
    
    .ai-hiring-file-status {
        border-width: 3px;
    }
}

/* Focus management for better keyboard navigation */
.ai-hiring-btn:focus,
.ai-hiring-input-wrapper textarea:focus,
.ai-hiring-file-input-wrapper:focus-within {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Ensure minimum touch target sizes */
.ai-hiring-btn,
.ai-hiring-file-status,
.ai-hiring-input-wrapper textarea {
    min-height: 44px;
}

/* Prevent zoom on input focus in iOS */
@media (max-width: 768px) {
    .ai-hiring-input-wrapper textarea,
    input[type="file"] {
        font-size: 16px;
    }
}