/**
 * RAG Chatbot Public Styles - 白黒ベースのモダンデザイン
 */

.rag-chatbot-container {
    border: 2px solid #000000;
    border-radius: 0;
    background: #ffffff;
    box-shadow: 4px 4px 0px rgba(0, 0, 0, 1);
    display: flex;
    flex-direction: column;
    font-family: "ヒラギノ角ゴ ProN W3", "Hiragino Kaku Gothic ProN", "Yu Gothic", YuGothic, "メイリオ", Meiryo, "Arial Black", Arial, sans-serif;
    overflow: visible;
    max-width: 100%;
    height: 100%;
}

.rag-chatbot-header {
    padding: 24px 32px;
    background: #000000;
    color: #ffffff;
    border-radius: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative;
    border-bottom: 3px solid #ffffff;
    flex-shrink: 0;
}

.rag-chatbot-header::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    right: 0;
    height: 3px;
    background: repeating-linear-gradient(
        90deg,
        #ffffff 0,
        #ffffff 10px,
        #000000 10px,
        #000000 20px
    );
}

.rag-chatbot-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 900;
    color: #ffffff !important;
    letter-spacing: 0.1em;
    text-transform: none;
    font-family: "Arial Black", Arial, sans-serif;
}

.rag-chatbot-header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.rag-chatbot-reset {
    background: #ffffff;
    border: 3px solid #000000;
    color: #000000;
    padding: 12px 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 48px;
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    font-size: 14px;
    font-weight: 700;
}

.rag-chatbot-reset svg {
    width: 20px;
    height: 20px;
}

.rag-chatbot-reset:focus {
    outline: 2px solid #000000;
    outline-offset: 2px;
}

@media (hover: hover) {
    .rag-chatbot-reset:hover {
        background: #000000;
        color: #ffffff;
        transform: translateY(-2px);
        box-shadow: 0 4px 0 #000000;
    }
}

.rag-chatbot-reset:active {
    transform: translateY(0);
    box-shadow: 0 2px 0 #000000;
}

.rag-chatbot-status {
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rag-chatbot-status[data-status="online"] {
    color: #ffffff;
}

.rag-chatbot-status[data-status="online"]::before {
    content: '●';
    color: #ffffff;
    animation: pulse 2s infinite;
}

.rag-chatbot-status[data-status="offline"] {
    color: #cccccc;
}

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

.rag-chatbot-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 32px;
    background: #ffffff;
    min-height: 300px;
    border-left: 3px solid #000000;
    border-right: 3px solid #000000;
    position: relative;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: #000000 #f0f0f0;
}

.rag-chatbot-messages::-webkit-scrollbar {
    width: 8px;
}

.rag-chatbot-messages::-webkit-scrollbar-track {
    background: #f0f0f0;
}

.rag-chatbot-messages::-webkit-scrollbar-thumb {
    background: #000000;
    border-radius: 0;
}

.rag-chatbot-messages::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: repeating-linear-gradient(
        90deg,
        #000000 0,
        #000000 5px,
        transparent 5px,
        transparent 15px
    );
}

.rag-chatbot-welcome {
    text-align: center;
    color: #000000;
    padding: 40px 24px;
    background: #ffffff;
    border: 3px solid #000000;
    margin: 0 auto;
    max-width: 320px;
    position: relative;
}

.rag-chatbot-welcome::after {
    content: '';
    position: absolute;
    top: -6px;
    right: -6px;
    bottom: -6px;
    left: -6px;
    background: #000000;
    z-index: -1;
}

.rag-chatbot-welcome p {
    margin: 0;
    font-size: 16px;
    line-height: 1.6;
    font-weight: 700;
}

.rag-chatbot-message {
    display: flex;
    margin-bottom: 24px;
    animation: slideIn 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

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

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

.rag-chatbot-avatar {
    width: 48px;
    height: 48px;
    border: 3px solid #000000;
    border-radius: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 900;
    flex-shrink: 0;
    background: #ffffff;
    position: relative;
}

.rag-chatbot-message-user .rag-chatbot-avatar {
    background: #000000;
    color: #ffffff;
    margin-left: 16px;
}

.rag-chatbot-message-user .rag-chatbot-avatar::after {
    content: '';
    position: absolute;
    top: -6px;
    right: -6px;
    bottom: -6px;
    left: -6px;
    border: 2px solid #000000;
    z-index: -1;
}

.rag-chatbot-message-bot .rag-chatbot-avatar {
    background: #ffffff;
    color: #000000;
    margin-right: 16px;
}

.rag-chatbot-message-error .rag-chatbot-avatar {
    background: #ffffff;
    color: #000000;
    border-color: #000000;
}

.rag-chatbot-message-system {
    justify-content: center;
}

.rag-chatbot-message-system .rag-chatbot-avatar {
    display: none;
}

.rag-chatbot-message-system .rag-chatbot-message-content {
    background: #f8f8f8;
    color: #666666;
    border-color: #cccccc;
    border-style: dashed;
    max-width: 100%;
    text-align: center;
    font-size: 13px;
    font-style: italic;
}

.rag-chatbot-message-content {
    max-width: 75%;
    padding: 16px 24px;
    border: 3px solid #000000;
    border-radius: 0;
    line-height: 1.6;
    word-wrap: break-word;
    font-size: 15px;
    position: relative;
    font-weight: 500;
}

.rag-chatbot-message-user .rag-chatbot-message-content {
    background: #000000;
    color: #ffffff;
}

.rag-chatbot-message-user .rag-chatbot-message-content::after {
    content: '';
    position: absolute;
    top: -6px;
    right: -6px;
    bottom: -6px;
    left: -6px;
    background: #000000;
    z-index: -1;
}

.rag-chatbot-message-bot .rag-chatbot-message-content {
    background: #ffffff;
    color: #000000;
    border-color: #000000;
}

.rag-chatbot-message-error .rag-chatbot-message-content {
    background: #ffffff;
    color: #000000;
    border-color: #000000;
    position: relative;
}

.rag-chatbot-message-error .rag-chatbot-message-content::before {
    content: '!';
    position: absolute;
    top: -10px;
    right: -10px;
    width: 20px;
    height: 20px;
    background: #000000;
    color: #ffffff;
    border-radius: 50%;
    font-size: 12px;
    font-weight: 900;
    display: flex;
    align-items: center;
    justify-content: center;
}

.rag-chatbot-message-content pre {
    background: #000000;
    color: #ffffff;
    padding: 16px;
    border: 2px solid #ffffff;
    overflow-x: auto;
    margin: 12px 0;
    font-size: 13px;
    font-family: "Courier New", monospace;
}

.rag-chatbot-message-content code {
    background: #000000;
    color: #ffffff;
    padding: 4px 8px;
    border: 1px solid #ffffff;
    font-family: "Courier New", monospace;
    font-size: 0.9em;
    font-weight: 700;
}

.rag-chatbot-timestamp {
    font-size: 11px;
    color: #666666;
    margin-top: 8px;
    display: none;
    text-align: right;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rag-chatbot-message-user .rag-chatbot-timestamp {
    text-align: left;
}

.rag-chatbot-widget-container.active .rag-chatbot-timestamp {
    display: block;
}

@media (hover: hover) {
    .rag-chatbot-message:hover .rag-chatbot-timestamp {
        display: block;
    }
}

/* Typing indicator */
.rag-chatbot-typing-content {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rag-chatbot-typing-dots {
    display: flex;
    padding: 16px 24px 8px 24px;
    align-items: center;
    gap: 6px;
}

.rag-chatbot-typing-dots span {
    height: 10px;
    width: 10px;
    background: #000000;
    border-radius: 0;
    display: inline-block;
    animation: typing 1.4s ease-in-out infinite;
}

.rag-chatbot-typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.rag-chatbot-typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

.rag-chatbot-typing-text {
    padding: 0 24px 16px 24px;
    font-size: 12px;
    color: #666666;
    line-height: 1.5;
}

.rag-chatbot-typing-text .typing-main-text {
    font-weight: 600;
    color: #000000;
}

.rag-chatbot-typing-text .typing-sub-text {
    font-size: 11px;
    color: #999999;
    font-style: italic;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    30% {
        transform: scale(1.3);
        opacity: 1;
    }
}

/* Sources */
.rag-chatbot-sources {
    padding: 24px 32px;
    background: #f8f8f8;
    border: 3px solid #000000;
    border-top: none;
}

.rag-chatbot-sources h4 {
    margin: 0 0 16px 0;
    font-size: 14px;
    color: #000000;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.rag-chatbot-sources-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.rag-chatbot-sources-list li {
    padding: 12px 16px;
    background: #ffffff;
    border: 2px solid #000000;
    margin-bottom: 12px;
    font-size: 13px;
    color: #000000;
    line-height: 1.5;
    transition: all 0.2s ease;
    font-weight: 500;
}

.rag-chatbot-sources-list li.active {
    background: #000000;
    color: #ffffff;
}

@media (hover: hover) {
    .rag-chatbot-sources-list li:hover {
        background: #000000;
        color: #ffffff;
    }
}

.rag-chatbot-source-metadata {
    font-size: 11px;
    color: #666666;
    font-style: italic;
    margin-top: 4px;
    font-weight: 400;
}

/* Input area */
.rag-chatbot-input-area {
    padding: 32px;
    border: 3px solid #000000;
    border-top: none;
    background: #ffffff;
    flex-shrink: 0;
}

.rag-chatbot-form {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 12px;
    align-items: stretch;
}

.rag-chatbot-input {
    flex: 1;
    padding: 16px 24px;
    border: 3px solid #000000;
    border-radius: 0;
    font-size: 15px;
    outline: none;
    transition: all 0.2s ease;
    font-family: inherit;
    background: #ffffff;
    resize: none;
    min-height: 24px;
    font-weight: 500;
}

.rag-chatbot-input:focus {
    background: #f8f8f8;
    box-shadow: inset 0 0 0 2px #000000;
}

.rag-chatbot-input:disabled {
    background: #f0f0f0;
    cursor: not-allowed;
    opacity: 0.6;
}

.rag-chatbot-send {
    padding: 16px 32px;
    background: #000000;
    color: #ffffff;
    border: 3px solid #000000;
    border-radius: 0;
    font-size: 14px;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-family: "Arial Black", Arial, sans-serif;
    position: relative;
}

.rag-chatbot-send.active,
.rag-chatbot-send:focus {
    background: #ffffff;
    color: #000000;
    transform: translateY(-2px);
    box-shadow: 0 4px 0 #000000;
}

@media (hover: hover) {
    .rag-chatbot-send:hover {
        background: #ffffff;
        color: #000000;
        transform: translateY(-2px);
        box-shadow: 0 4px 0 #000000;
    }
}

.rag-chatbot-send:active {
    transform: translateY(0);
    box-shadow: 0 2px 0 #000000;
}

/* Usage display */
.rag-chatbot-usage {
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px 20px;
    background: #f8f8f8;
    border: 2px solid #000000;
}

.rag-chatbot-usage-bar {
    flex: 1;
    height: 12px;
    background: #ffffff;
    border: 2px solid #000000;
    overflow: hidden;
}

.rag-chatbot-usage-progress {
    height: 100%;
    background: #000000;
    transition: width 0.3s ease;
}

.rag-chatbot-usage-text {
    font-size: 12px;
    color: #000000;
    white-space: nowrap;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* Widget styles */
.rag-chatbot-widget-trigger {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 72px;
    height: 72px;
    border: 4px solid #000000;
    border-radius: 0;
    background: #ffffff;
    color: #000000;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 4px 4px 0 #000000;
    transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    z-index: 9998;
    font-size: 28px;
    font-weight: 900;
}

.rag-chatbot-widget-trigger svg {
    width: 32px;
    height: 32px;
    transition: all 0.3s ease;
}

.rag-chatbot-widget-trigger .close-icon {
    display: none;
    width: 28px;
    height: 28px;
    font-size: 32px;
    font-weight: 900;
    line-height: 1;
}

.rag-chatbot-widget-trigger.active {
    transform: translateY(-4px);
    box-shadow: 8px 8px 0 #000000;
    background: #000000;
    color: #ffffff;
}

.rag-chatbot-widget-trigger.active svg {
    display: none;
}

.rag-chatbot-widget-trigger.active .close-icon {
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (hover: hover) {
    .rag-chatbot-widget-trigger:hover {
        transform: translateY(-4px);
        box-shadow: 8px 8px 0 #000000;
        background: #000000;
        color: #ffffff;
    }
}

.rag-chatbot-widget-container {
    position: fixed;
    bottom: 110px;
    right: 24px;
    width: 420px;
    max-width: 90vw;
    height: 600px;
    max-height: 80vh;
    z-index: 9999;
    display: none;
    overflow: hidden;
}

.rag-chatbot-widget-container .rag-chatbot-container {
    height: 100%;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.rag-chatbot-widget-container.active {
    display: block;
    animation: slideUp 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(40px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Touch-friendly improvements */
.rag-chatbot-input,
.rag-chatbot-send,
.rag-chatbot-sources-list li,
.rag-chatbot-widget-trigger {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.rag-chatbot-send,
.rag-chatbot-widget-trigger {
    min-height: 48px;
    min-width: 48px;
}

.rag-chatbot-sources-list li {
    min-height: 48px;
    display: flex;
    align-items: center;
    cursor: pointer;
}

/* Responsive */
@media (max-width: 768px) {
    .rag-chatbot-widget-container {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        bottom: 0;
        right: 0;
        left: 0;
        border-radius: 0;
    }

    .rag-chatbot-widget-container .rag-chatbot-container {
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .rag-chatbot-container {
        border-radius: 0;
    }
    
    .rag-chatbot-header {
        padding: 20px 24px;
        min-height: 60px;
    }
    
    .rag-chatbot-messages {
        padding: 24px 20px;
    }
    
    .rag-chatbot-input-area {
        padding: 20px;
    }
    
    .rag-chatbot-message-content {
        max-width: 85%;
        font-size: 14px;
    }
    
    .rag-chatbot-widget-trigger {
        bottom: 16px;
        right: 16px;
        width: 64px;
        height: 64px;
        font-size: 24px;
    }
    
    .rag-chatbot-form {
        display: grid;
        grid-template-columns: auto 1fr auto;
        gap: 8px;
    }

    .rag-chatbot-send {
        padding: 16px 24px;
        min-height: 56px;
        font-size: 16px;
    }

    .rag-chatbot-reset {
        min-width: 56px;
        min-height: 56px;
        padding: 16px;
    }

    .rag-chatbot-reset svg {
        width: 24px;
        height: 24px;
    }

    .rag-chatbot-input {
        min-height: 56px;
        font-size: 16px;
        padding: 16px 20px;
    }
    
    .rag-chatbot-sources-list li {
        min-height: 56px;
        padding: 16px 20px;
        font-size: 14px;
    }
    
    .rag-chatbot-widget-container.active .rag-chatbot-timestamp {
        display: block;
    }
}

/* Modal styles */
.rag-chatbot-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

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

.rag-chatbot-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
}

.rag-chatbot-modal-content {
    position: relative;
    background: #ffffff;
    border: 4px solid #000000;
    box-shadow: 8px 8px 0 #000000;
    max-width: 400px;
    width: 90%;
    z-index: 1;
    animation: slideUp 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.rag-chatbot-modal-header {
    padding: 24px 32px;
    background: #000000;
    color: #ffffff;
    border-bottom: 3px solid #ffffff;
}

.rag-chatbot-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rag-chatbot-modal-body {
    padding: 32px;
    background: #ffffff;
}

.rag-chatbot-modal-body p {
    margin: 0;
    font-size: 15px;
    line-height: 1.6;
    color: #000000;
    font-weight: 500;
}

.rag-chatbot-modal-footer {
    padding: 24px 32px;
    background: #f8f8f8;
    border-top: 3px solid #000000;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.rag-chatbot-modal-btn {
    padding: 12px 24px;
    border: 3px solid #000000;
    font-size: 14px;
    font-weight: 900;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    min-height: 48px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.rag-chatbot-modal-cancel {
    background: #ffffff;
    color: #000000;
}

.rag-chatbot-modal-confirm {
    background: #000000;
    color: #ffffff;
}

@media (hover: hover) {
    .rag-chatbot-modal-cancel:hover {
        background: #f0f0f0;
        transform: translateY(-2px);
        box-shadow: 0 4px 0 #000000;
    }

    .rag-chatbot-modal-confirm:hover {
        background: #ffffff;
        color: #000000;
        transform: translateY(-2px);
        box-shadow: 0 4px 0 #000000;
    }
}

.rag-chatbot-modal-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 0 #000000;
}

@media (max-width: 768px) {
    .rag-chatbot-modal-content {
        max-width: 90%;
    }

    .rag-chatbot-modal-header {
        padding: 20px 24px;
    }

    .rag-chatbot-modal-header h3 {
        font-size: 16px;
    }

    .rag-chatbot-modal-body {
        padding: 24px;
    }

    .rag-chatbot-modal-footer {
        padding: 20px 24px;
        flex-direction: column;
    }

    .rag-chatbot-modal-btn {
        width: 100%;
        min-height: 56px;
        font-size: 16px;
    }
}

/* Trial badge styles */
.rag-chatbot-trial-badge {
    background: #000000;
    color: #ffffff;
    padding: 12px 20px;
    border-bottom: 3px solid #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    position: relative;
    animation: slideDown 0.3s ease;
}

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

.rag-chatbot-trial-badge::after {
    content: '';
    position: absolute;
    bottom: -3px;
    left: 0;
    right: 0;
    height: 3px;
    background: repeating-linear-gradient(
        90deg,
        #ffffff 0,
        #ffffff 8px,
        #000000 8px,
        #000000 16px
    );
}

.trial-badge-icon {
    font-size: 16px;
    animation: pulse 2s infinite;
}

.trial-badge-text {
    font-family: "Arial Black", Arial, sans-serif;
}

/* Trial mode container adjustments */
.rag-chatbot-container.rag-chatbot-trial {
    border-color: #000000;
}

.rag-chatbot-container.rag-chatbot-trial .rag-chatbot-header {
    background: #000000;
    border-bottom: 3px solid #ffffff;
}

.rag-chatbot-container.rag-chatbot-trial .rag-chatbot-welcome {
    border-color: #000000;
    background: #f8f8f8;
}

.rag-chatbot-container.rag-chatbot-trial .rag-chatbot-welcome::after {
    background: #000000;
}

/* Mobile responsive for trial badge */
@media (max-width: 768px) {
    .rag-chatbot-trial-badge {
        padding: 10px 16px;
        font-size: 12px;
    }

    .trial-badge-icon {
        font-size: 14px;
    }
}

/* Machine Link Styles */
.rag-chatbot-machine-link-wrapper {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #e0e0e0;
}

.rag-chatbot-machine-link {
    display: inline-block;
    padding: 10px 18px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white !important;
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.rag-chatbot-machine-link:hover {
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    color: white !important;
}

.rag-chatbot-machine-link:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

/* Mobile responsive */
@media (max-width: 480px) {
    .rag-chatbot-machine-link {
        display: block;
        text-align: center;
        padding: 12px 16px;
        font-size: 13px;
    }
}

/* Print styles */
@media print {
    .rag-chatbot-widget-trigger,
    .rag-chatbot-widget-container,
    .rag-chatbot-modal,
    .rag-chatbot-trial-badge,
    .rag-chatbot-machine-link {
        display: none !important;
    }
}