/**
 * CardChat Frontend Styles
 */

/* Base Font & Variables */
:root {
    --cardchat-primary-color: #009ace;
    --cardchat-secondary-color: #f0f4f8;
    --cardchat-text-color: #333;
    --cardchat-bot-bg: #e1f5fe; /* Lighter shade of primary */
    --cardchat-user-bg: #ffffff;
    --cardchat-font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    --cardchat-border-radius: 8px;
    --cardchat-shadow: 0 5px 15px rgba(0, 0, 0, 0.15);
}

/* Floating Action Button (FAB) */
#cardchat-fab {
    position: fixed;
    bottom: 25px;
    right: 25px;
    width: 60px;
    height: 60px;
    background-color: var(--cardchat-primary-color);
    border-radius: 50%;
    box-shadow: var(--cardchat-shadow);
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    z-index: 9998;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

#cardchat-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
}

#cardchat-fab svg {
    width: 32px;
    height: 32px;
    fill: white;
}

/* Chat Window Container */
#cardchat-window {
    position: fixed;
    bottom: 100px; /* Above the FAB */
    right: 25px;
    width: 350px;
    max-width: 90vw;
    height: 500px;
    max-height: 70vh;
    background-color: #fff;
    border-radius: var(--cardchat-border-radius);
    box-shadow: var(--cardchat-shadow);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: var(--cardchat-font-family);
    visibility: hidden; /* Hidden by default */
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: visibility 0.3s ease, opacity 0.3s ease, transform 0.3s ease;
}

#cardchat-window.cardchat-visible {
    visibility: visible;
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* Fullscreen state */
#cardchat-window.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    bottom: auto;
    right: auto;
    border-radius: 0;
    z-index: 100000; /* Ensure it is on top */
    /* Reset transitions potentially */
    visibility: visible;
    opacity: 1;
    transform: none;
}

/* Chat Header */
#cardchat-header {
    background-color: var(--cardchat-primary-color);
    color: white;
    padding: 15px;
    font-size: 0.95em;
    font-weight: 600;
    border-top-left-radius: var(--cardchat-border-radius);
    border-top-right-radius: var(--cardchat-border-radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#cardchat-close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    padding: 0 5px;
    line-height: 1;
}

#cardchat-close-btn:hover {
    opacity: 0.8;
}

#cardchat-header button {
    background: none;
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    padding: 10px;
    line-height: 1;
    margin-left: 5px;
    opacity: 0.8;
    transition: background-color 0.2s ease, opacity 0.2s ease;
}

#cardchat-header button:hover {
    opacity: 1;
}

#cardchat-header button:active {
    background-color: rgba(0, 0, 0, 0.2);
    opacity: 1;
}

/* Style the SVG icon inside the fullscreen button */
#cardchat-fullscreen-btn svg {
    width: 16px; /* Match font size context */
    height: 16px;
    vertical-align: middle;
    stroke-width: 2; /* Ensure stroke shows */
}

/* Message Area */
#cardchat-messages {
    flex-grow: 1;
    overflow-y: auto;
    padding: 15px;
    background-color: var(--cardchat-secondary-color);
    display: flex;
    flex-direction: column;
    gap: 12px;
    font-size: 0.9em;
}

/* Individual Messages */
.cardchat-message {
    max-width: 85%;
    padding: 10px 15px;
    border-radius: var(--cardchat-border-radius);
    line-height: 1.4;
    word-wrap: break-word;
    font-size: 0.95em;
}

.cardchat-message.cardchat-bot {
    background-color: var(--cardchat-bot-bg);
    color: var(--cardchat-text-color);
    align-self: flex-start;
    border-bottom-left-radius: 0; /* "Tail" effect */
}

.cardchat-message.cardchat-user {
    background-color: var(--cardchat-primary-color);
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 0; /* "Tail" effect */
}

/* Typing Indicator */
.cardchat-message.cardchat-typing-indicator {
    background-color: var(--cardchat-bot-bg);
    color: var(--cardchat-text-color);
    align-self: flex-start;
    font-style: italic;
    display: flex;
    align-items: center;
    gap: 5px;
}

.typing-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  background-color: var(--cardchat-primary-color);
  border-radius: 50%;
  animation: typing-bounce 1.2s infinite ease-in-out;
}

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

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

@keyframes typing-bounce {
  0%, 60%, 100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-3px);
  }
}

/* Input Area */
#cardchat-input-area {
    display: flex;
    padding: 10px;
    border-top: 1px solid #e0e0e0;
    background-color: #fff;
    font-size: 0.9em;
}

#cardchat-input {
    flex-grow: 1;
    border: 1px solid #ccc;
    border-radius: var(--cardchat-border-radius);
    padding: 10px 15px;
    font-size: 1em;
    margin-right: 10px;
    resize: none; /* Prevent manual resizing */
    height: 40px; /* Start with single line */
    line-height: 1.4;
    font-family: var(--cardchat-font-family);
}

#cardchat-input:focus {
    outline: none;
    border-color: var(--cardchat-primary-color);
    box-shadow: 0 0 0 2px rgba(0, 154, 206, 0.2);
}

#cardchat-send-btn {
    background-color: var(--cardchat-primary-color);
    border: none;
    color: white;
    padding: 0 15px;
    border-radius: var(--cardchat-border-radius);
    cursor: pointer;
    font-size: 1.1em;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s ease;
    height: 40px;
}

#cardchat-send-btn:hover {
    background-color: #007ba7; /* Darker shade */
}

#cardchat-send-btn:disabled {
    background-color: #a0a0a0;
    cursor: not-allowed;
}

#cardchat-send-btn svg {
    width: 20px;
    height: 20px;
    fill: white;
}

/* Responsive Adjustments */
@media (max-width: 480px) {
    #cardchat-window {
        width: calc(100vw - 40px);
        right: 20px;
        bottom: 85px;
        height: calc(100vh - 100px);
        max-height: none;
    }
    #cardchat-fab {
        bottom: 15px;
        right: 15px;
        width: 55px;
        height: 55px;
    }
    #cardchat-fab svg {
        width: 28px;
        height: 28px;
    }
}
