/**
 * FITBOT AI Chatbot Responsive Styles
 * Mobile-first responsive design for all devices
 */

/* CSS Variables for theming */
.fitbot-chatbot {
    --fitbot-primary-color: #FFD700;
    --fitbot-primary-rgb: 255, 215, 0;
    --fitbot-secondary-color: #000000;
    --fitbot-text-color: #FFD700;
    --fitbot-light-gray: #000000;
    --fitbot-border-color: #FFD700;
    --fitbot-shadow: 0 4px 20px rgba(255, 215, 0, 0.15);
    --fitbot-border-radius: 12px;
    --fitbot-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Base chatbot container */
.fitbot-chatbot {
    position: fixed;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    font-size: 14px;
    line-height: 1.4;
    opacity: 0;
    visibility: hidden;
    transition: var(--fitbot-transition);
}

.fitbot-chatbot.fitbot-visible {
    opacity: 1;
    visibility: visible;
}

/* Position variants */
.fitbot-chatbot.fitbot-bottom-right {
    bottom: 20px;
    right: 20px;
}

.fitbot-chatbot.fitbot-bottom-left {
    bottom: 20px;
    left: 20px;
}

/* Chatbot button */
.fitbot-button {
    width: 60px;
    height: 60px;
    background: var(--fitbot-primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--fitbot-shadow);
    transition: var(--fitbot-transition);
    position: relative;
    overflow: hidden;
}

.fitbot-button:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 25px rgba(var(--fitbot-primary-rgb), 0.3);
}

.fitbot-button .fitbot-icon {
    width: 24px;
    height: 24px;
    color: white;
    transition: var(--fitbot-transition);
}

.fitbot-button .fitbot-close-icon {
    position: absolute;
    color: white;
    font-size: 24px;
    font-weight: bold;
    opacity: 0;
    transform: rotate(180deg);
    transition: var(--fitbot-transition);
}

.fitbot-chatbot.fitbot-open .fitbot-button .fitbot-icon {
    opacity: 0;
    transform: rotate(-180deg);
}

.fitbot-chatbot.fitbot-open .fitbot-button .fitbot-close-icon {
    opacity: 1;
    transform: rotate(0deg);
}

/* Pulse animation for attention */
.fitbot-button.fitbot-pulse {
    animation: fitbot-pulse 2s infinite;
}

@keyframes fitbot-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(var(--fitbot-primary-rgb), 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(var(--fitbot-primary-rgb), 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(var(--fitbot-primary-rgb), 0);
    }
}

/* Chat window */
.fitbot-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: var(--fitbot-border-radius);
    box-shadow: var(--fitbot-shadow);
    display: flex;
    flex-direction: column;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: var(--fitbot-transition);
    overflow: hidden;
}

.fitbot-chatbot.fitbot-open .fitbot-chat-window {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

/* Chat header */
.fitbot-header {
    background: var(--fitbot-primary-color);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

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

.fitbot-avatar svg {
    width: 20px;
    height: 20px;
}

.fitbot-info {
    flex: 1;
}

.fitbot-info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.fitbot-status {
    font-size: 12px;
    opacity: 0.8;
}

.fitbot-minimize {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: var(--fitbot-transition);
}

.fitbot-minimize:hover {
    background: rgba(255, 255, 255, 0.1);
}

.fitbot-minimize svg {
    width: 16px;
    height: 16px;
}

/* Messages area */
.fitbot-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    scroll-behavior: smooth;
    background: #000000;
}

.fitbot-messages::-webkit-scrollbar {
    width: 4px;
}

.fitbot-messages::-webkit-scrollbar-track {
    background: var(--fitbot-light-gray);
}

.fitbot-messages::-webkit-scrollbar-thumb {
    background: var(--fitbot-border-color);
    border-radius: 2px;
}

/* Message styles */
.fitbot-message {
    display: flex;
    margin-bottom: 16px;
    animation: fitbot-message-appear 0.3s ease-out;
}

@keyframes fitbot-message-appear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

.fitbot-message-avatar {
    width: 32px;
    height: 32px;
    background: var(--fitbot-primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 8px;
    flex-shrink: 0;
}

.fitbot-message-avatar svg {
    width: 16px;
    height: 16px;
    color: white;
}

.fitbot-message-bubble {
    max-width: 80%;
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
}

.fitbot-user-message .fitbot-message-bubble {
    background: #000000;
    color: #FFD700;
    border-bottom-right-radius: 4px;
    border: 1px solid #FFD700;
}

.fitbot-bot-message .fitbot-message-bubble {
    background: #FFD700;
    color: #000000;
    border-bottom-left-radius: 4px;
}

.fitbot-message-content {
    word-wrap: break-word;
    line-height: 1.4;
}

.fitbot-message-content a {
    color: inherit;
    text-decoration: underline;
}

.fitbot-user-message .fitbot-message-content a {
    color: rgba(255, 255, 255, 0.9);
}

.fitbot-message-time {
    font-size: 11px;
    opacity: 0.6;
    margin-top: 4px;
    text-align: right;
}

.fitbot-bot-message .fitbot-message-time {
    text-align: left;
}

/* Upgrade button */
.fitbot-upgrade-button {
    margin-top: 8px;
}

.fitbot-upgrade-link {
    display: inline-block;
    background: var(--fitbot-primary-color);
    color: white !important;
    padding: 8px 16px;
    border-radius: 20px;
    text-decoration: none !important;
    font-size: 12px;
    font-weight: 600;
    transition: var(--fitbot-transition);
}

.fitbot-upgrade-link:hover {
    background: rgba(var(--fitbot-primary-rgb), 0.8);
    transform: translateY(-1px);
}

/* PDF download */
.fitbot-pdf-download {
    margin-top: 8px;
}

.fitbot-pdf-link {
    display: inline-block;
    background: #28a745;
    color: white !important;
    padding: 8px 16px;
    border-radius: 20px;
    text-decoration: none !important;
    font-size: 12px;
    font-weight: 600;
    transition: var(--fitbot-transition);
}

.fitbot-pdf-link:hover {
    background: #218838;
    transform: translateY(-1px);
}

/* Typing indicator */
.fitbot-typing-indicator {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--fitbot-light-gray);
    border-top: 1px solid var(--fitbot-border-color);
}

.fitbot-typing-dots {
    display: flex;
    gap: 4px;
}

.fitbot-typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--fitbot-primary-color);
    border-radius: 50%;
    animation: fitbot-typing 1.4s infinite ease-in-out;
}

.fitbot-typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.fitbot-typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes fitbot-typing {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

.fitbot-typing-text {
    font-size: 12px;
    color: #666;
    font-style: italic;
}

/* Input area */
.fitbot-input-area {
    border-top: 1px solid var(--fitbot-border-color);
    background: white;
    flex-shrink: 0;
}

/* Quick actions */
.fitbot-quick-actions {
    padding: 12px 16px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    border-bottom: 1px solid var(--fitbot-border-color);
}

.fitbot-quick-btn {
    background: var(--fitbot-secondary-color);
    border: 1px solid var(--fitbot-primary-color);
    color: var(--fitbot-primary-color);
    padding: 6px 12px;
    border-radius: 16px;
    font-size: 12px;
    cursor: pointer;
    transition: var(--fitbot-transition);
    white-space: nowrap;
}

.fitbot-quick-btn:hover {
    background: var(--fitbot-primary-color);
    color: white;
}

/* Input container */
.fitbot-input-container {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 16px;
}

.fitbot-input {
    flex: 1;
    border: 1px solid #FFD700;
    border-radius: 20px;
    padding: 12px 16px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: var(--fitbot-transition);
    min-height: 20px;
    max-height: 120px;
    background: #000000;
    color: #FFD700;
}

.fitbot-input:focus {
    border-color: var(--fitbot-primary-color);
    box-shadow: 0 0 0 2px rgba(var(--fitbot-primary-rgb), 0.1);
}

.fitbot-input::placeholder {
    color: rgba(255, 215, 0, 0.7);
}

.fitbot-send-btn {
    width: 40px;
    height: 40px;
    background: #FFD700;
    border: none;
    border-radius: 50%;
    color: #000000;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--fitbot-transition);
    flex-shrink: 0;
    font-weight: bold;
    font-size: 12px;
}

.fitbot-send-btn:hover:not(:disabled) {
    background: rgba(var(--fitbot-primary-rgb), 0.8);
    transform: scale(1.05);
}

.fitbot-send-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.fitbot-send-btn svg {
    width: 16px;
    height: 16px;
}

/* Powered by */
.fitbot-powered-by {
    text-align: center;
    font-size: 10px;
    color: #999;
    padding: 8px 16px;
    border-top: 1px solid var(--fitbot-border-color);
}

/* Responsive Design */

/* Mobile Styles (up to 768px) */
@media (max-width: 768px) {
    .fitbot-chatbot {
        bottom: 10px;
        right: 10px;
        left: 10px;
    }
    
    .fitbot-button {
        width: 56px;
        height: 56px;
    }
    
    .fitbot-button .fitbot-icon {
        width: 22px;
        height: 22px;
    }
    
    .fitbot-chat-window {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        top: 0;
        width: 100%;
        height: 100%;
        border-radius: 0;
        z-index: 1000000;
    }
    
    .fitbot-chatbot.fitbot-open .fitbot-button {
        display: none;
    }
    
    .fitbot-header {
        padding: 20px;
        padding-top: max(20px, env(safe-area-inset-top));
    }
    
    .fitbot-messages {
        padding: 16px;
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
    
    .fitbot-input-container {
        padding: 16px;
        padding-bottom: max(16px, env(safe-area-inset-bottom));
    }
    
    .fitbot-quick-actions {
        padding: 12px 16px;
        gap: 6px;
    }
    
    .fitbot-quick-btn {
        font-size: 11px;
        padding: 6px 10px;
    }
    
    .fitbot-message-bubble {
        max-width: 85%;
    }
    
    .fitbot-input {
        font-size: 16px; /* Prevents zoom on iOS */
    }
}

/* Tablet Styles (769px to 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .fitbot-chat-window {
        width: 400px;
        height: 600px;
        bottom: 90px;
    }
    
    .fitbot-button {
        width: 64px;
        height: 64px;
    }
    
    .fitbot-button .fitbot-icon {
        width: 26px;
        height: 26px;
    }
    
    .fitbot-message-bubble {
        max-width: 75%;
    }
}

/* Desktop Styles (1025px and up) */
@media (min-width: 1025px) {
    .fitbot-chat-window {
        width: 380px;
        height: 520px;
        bottom: 80px;
    }
    
    .fitbot-message-bubble {
        max-width: 70%;
    }
}

/* Landscape orientation adjustments for mobile */
@media (max-width: 768px) and (orientation: landscape) {
    .fitbot-header {
        padding: 12px 20px;
    }
    
    .fitbot-messages {
        padding: 12px 16px;
    }
    
    .fitbot-input-container {
        padding: 12px 16px;
    }
}

/* High DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .fitbot-button {
        box-shadow: var(--fitbot-shadow), 0 1px 3px rgba(0, 0, 0, 0.1);
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .fitbot-chat-window {
        background: #2d2d2d;
        color: #fff;
    }
    
    .fitbot-bot-message .fitbot-message-bubble {
        background: #404040;
        color: #fff;
    }
    
    .fitbot-input {
        background: #404040;
        border-color: #555;
        color: #fff;
    }
    
    .fitbot-input::placeholder {
        color: #aaa;
    }
    
    .fitbot-typing-indicator {
        background: #404040;
        border-color: #555;
    }
    
    .fitbot-quick-actions {
        border-color: #555;
    }
    
    .fitbot-quick-btn {
        background: #404040;
        border-color: var(--fitbot-primary-color);
        color: #fff;
    }
    
    .fitbot-powered-by {
        border-color: #555;
        color: #aaa;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .fitbot-chatbot,
    .fitbot-button,
    .fitbot-chat-window,
    .fitbot-message,
    .fitbot-input,
    .fitbot-send-btn,
    .fitbot-quick-btn,
    .fitbot-upgrade-link,
    .fitbot-pdf-link {
        transition: none;
    }
    
    .fitbot-button.fitbot-pulse {
        animation: none;
    }
    
    .fitbot-typing-dots span {
        animation: none;
    }
    
    @keyframes fitbot-message-appear {
        from, to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* Print styles */
@media print {
    .fitbot-chatbot {
        display: none !important;
    }
}

/* Focus styles for accessibility */
.fitbot-button:focus,
.fitbot-minimize:focus,
.fitbot-send-btn:focus,
.fitbot-quick-btn:focus,
.fitbot-upgrade-link:focus,
.fitbot-pdf-link:focus {
    outline: 2px solid var(--fitbot-primary-color);
    outline-offset: 2px;
}

.fitbot-input:focus {
    outline: none; /* Custom focus style already applied */
}

/* Screen reader only content */
.fitbot-sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Animation for smooth scrolling */
.fitbot-messages {
    scroll-behavior: smooth;
}

/* Custom scrollbar for webkit browsers */
.fitbot-messages::-webkit-scrollbar {
    width: 6px;
}

.fitbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.fitbot-messages::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 3px;
}

.fitbot-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.3);
}

/* Loading state */
.fitbot-loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Error state */
.fitbot-error .fitbot-message-bubble {
    background: #ffebee;
    border-left: 3px solid #f44336;
}

/* Success state */
.fitbot-success .fitbot-message-bubble {
    background: #e8f5e8;
    border-left: 3px solid #4caf50;
}

/* Shortcode Assistant Styles */
.fitbot-assistant-container {
    border: 1px solid #e1e5e9;
    border-radius: 8px;
    background: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: flex;
    flex-direction: column;
    --fitbot-border-color: #e1e5e9;
    --fitbot-border-radius: 8px;
    --fitbot-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.fitbot-assistant-header {
    background: var(--fitbot-primary-color, #0073aa);
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.fitbot-assistant-info {
    display: flex;
    flex-direction: column;
}

.fitbot-assistant-name {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    line-height: 1.2;
}

.fitbot-assistant-personality {
    font-size: 12px;
    opacity: 0.9;
    text-transform: capitalize;
    margin-top: 2px;
}

.fitbot-assistant-pricing {
    display: flex;
    align-items: center;
}

.fitbot-price {
    font-size: 14px;
    font-weight: 600;
    background: rgba(255,255,255,0.2);
    padding: 4px 8px;
    border-radius: 4px;
}

.fitbot-chat-area {
    height: calc(100% - 70px);
    display: flex;
    flex-direction: column;
    min-height: 300px;
}

.fitbot-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    max-height: calc(100% - 120px);
    background: #000000;
}

.fitbot-chat-input-area {
    border-top: 1px solid var(--fitbot-border-color, #e1e5e9);
    padding: 15px 20px;
    background: #fafbfc;
}

.fitbot-input-container {
    display: flex;
    align-items: flex-end;
    gap: 10px;
}

.fitbot-message-input {
    flex: 1;
    border: 1px solid #FFD700;
    border-radius: 20px;
    padding: 10px 15px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    max-height: 100px;
    min-height: 40px;
    outline: none;
    transition: border-color 0.2s;
    background: #000000;
    color: #FFD700;
}

.fitbot-message-input:focus {
    border-color: #FFD700;
}

.fitbot-message-input::placeholder {
    color: rgba(255, 215, 0, 0.7);
}

.fitbot-send-button {
    background: #FFD700;
    color: #000000;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s;
    font-weight: bold;
    font-size: 12px;
}

.fitbot-send-button:hover {
    background: rgba(255, 215, 0, 0.8);
}

.fitbot-send-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.fitbot-login-required,
.fitbot-subscription-required {
    padding: 20px;
    text-align: center;
    background: #fafbfc;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fitbot-system-message {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    padding: 20px;
    text-align: center;
    margin: 20px;
}

.fitbot-login-btn,
.fitbot-subscribe-btn {
    display: inline-block;
    background: var(--fitbot-primary-color, #0073aa);
    color: white;
    padding: 10px 20px;
    border-radius: 5px;
    text-decoration: none;
    margin-top: 10px;
    font-weight: 600;
    transition: background-color 0.2s;
}

.fitbot-login-btn:hover,
.fitbot-subscribe-btn:hover {
    background: var(--fitbot-primary-color-dark, #005a87);
    color: white;
    text-decoration: none;
}

.fitbot-usage-info {
    margin-top: 8px;
    text-align: center;
}

.fitbot-usage-text {
    font-size: 11px;
    color: #666;
}

.fitbot-typing-indicator {
    padding: 10px 15px;
    margin-bottom: 10px;
}

.fitbot-typing-indicator span {
    display: inline-block;
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #999;
    margin: 0 2px;
    animation: fitbot-typing 1.4s infinite ease-in-out;
}

.fitbot-typing-indicator span:nth-child(1) { 
    animation-delay: -0.32s; 
}

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

@keyframes fitbot-typing {
    0%, 80%, 100% { 
        transform: scale(0.8); 
        opacity: 0.5; 
    }
    40% { 
        transform: scale(1); 
        opacity: 1; 
    }
}

/* Responsive styles for shortcode assistants */
@media (max-width: 768px) {
    .fitbot-assistant-container {
        border-radius: 0;
        height: 100vh !important;
        width: 100% !important;
        position: fixed;
        top: 0;
        left: 0;
        z-index: 9999;
    }
    
    .fitbot-assistant-header {
        padding: 12px 15px;
    }
    
    .fitbot-assistant-name {
        font-size: 16px;
    }
    
    .fitbot-chat-messages {
        padding: 15px;
    }
    
    .fitbot-message-bubble {
        max-width: 90%;
    }
    
    .fitbot-input-container {
        gap: 8px;
    }
    
    .fitbot-message-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

@media (max-width: 480px) {
    .fitbot-assistant-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
    
    .fitbot-assistant-pricing {
        align-self: flex-end;
    }
    
    .fitbot-chat-input-area {
        padding: 10px 15px;
    }
}

/* Error styles for shortcode */
.fitbot-error {
    background: #ffebee;
    color: #c62828;
    padding: 15px;
    border-radius: 4px;
    border-left: 4px solid #f44336;
    font-weight: 500;
}
