/**
 * SmartSearchWP Chat Full - Frontend Styles
 *
 * @package SmartSearchWP_ChatFull
 */

/* CSS Variables */
:root {
    --cf-maxw: 1200px;
    --cf-accent: #0073aa;
    --cf-bg: #ffffff;
    --cf-bg-alt: #f8f9fa;
    --cf-border: #e0e0e0;
    --cf-text: #333333;
    --cf-text-muted: #666666;
    --cf-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --cf-radius: 8px;
    --cf-radius-sm: 4px;
    --cf-spacing: 16px;
    --cf-spacing-sm: 8px;
    --cf-spacing-lg: 24px;
}

/* Ensure full width for the chat container */
.sswp-full-page-wrap {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
}

/* Global box-sizing for all elements */
.sswp-full-page-wrap *,
.sswp-full-page-wrap *::before,
.sswp-full-page-wrap *::after {
    box-sizing: border-box;
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    :root {
        --cf-bg: #1a1a1a;
        --cf-bg-alt: #2d2d2d;
        --cf-border: #404040;
        --cf-text: #ffffff;
        --cf-text-muted: #cccccc;
        --cf-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    }
}

/* Main container for full-screen chat */
.sswp-full-page-wrap {
    min-height: 80vh;
    width: 100% !important;
    max-width: 100% !important;
    display: flex;
    align-items: stretch;
    background-color: var(--cf-bg);
    border: 1px solid var(--cf-border);
    border-radius: var(--cf-radius);
    overflow: hidden;
    box-shadow: var(--cf-shadow);
}

/* Chat container */
#sswp-full-page {
    flex: 1;
    width: 100%;
    max-width: 100%;
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Layout container */
.sswp-full-page-layout {
    display: grid;
    grid-template-rows: auto 1fr auto;
    height: 100%;
    width: 100%;
    min-height: 80vh;
}

/* Header styles */
.sswp-cf-header {
    padding: var(--cf-spacing-lg);
    background-color: var(--cf-bg-alt);
    border-bottom: 1px solid var(--cf-border);
    text-align: center;
}

.sswp-cf-header[hidden] {
    display: none;
}

.sswp-cf-logo {
    max-height: 60px;
    width: auto;
    margin-bottom: var(--cf-spacing-sm);
    border-radius: var(--cf-radius-sm);
}

.sswp-cf-title {
    margin: 0 0 var(--cf-spacing-sm) 0;
    font-size: 24px;
    font-weight: 600;
    color: var(--cf-text);
}

.sswp-cf-subtitle {
    margin: 0;
    font-size: 16px;
    color: var(--cf-text-muted);
}

/* Main content area */
.sswp-cf-main {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Messages container */
.sswp-cf-messages {
    flex: 1;
    padding: var(--cf-spacing);
    overflow-y: auto;
    scroll-behavior: smooth;
}

/* Message styles */
.sswp-cf-msg {
    margin: var(--cf-spacing) 0;
    max-width: 80%;
    word-wrap: break-word;
}

.sswp-cf-msg.is-user {
    margin-left: auto;
    text-align: right;
}

.sswp-cf-msg.is-assistant {
    margin-right: auto;
    text-align: left;
}

.sswp-cf-msg-content {
    display: inline-block;
    padding: var(--cf-spacing) var(--cf-spacing-lg);
    border-radius: 18px;
    background-color: var(--cf-bg-alt);
    border: 1px solid var(--cf-border);
    color: var(--cf-text);
    line-height: 1.5;
}

.sswp-cf-msg.is-user .sswp-cf-msg-content {
    background-color: var(--cf-accent);
    color: white;
    border-color: var(--cf-accent);
}

/* Sources panel */
.sswp-cf-sources {
    width: 320px;
    background-color: var(--cf-bg-alt);
    border-left: 1px solid var(--cf-border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    max-height: 100vh;
    overflow-y: auto;
}

.sswp-cf-sources[hidden] {
    display: none;
}

.sswp-cf-sources-header {
    padding: var(--cf-spacing);
    border-bottom: 1px solid var(--cf-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--cf-bg);
}

.sswp-cf-sources-header span {
    font-weight: 600;
    color: var(--cf-text);
}

.sswp-cf-sources-close {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: var(--cf-text-muted);
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--cf-radius-sm);
}

.sswp-cf-sources-close:hover {
    background-color: var(--cf-border);
    color: var(--cf-text);
}

.sswp-cf-sources-list {
    list-style: none;
    margin: 0;
    padding: var(--cf-spacing);
}

.sswp-cf-sources-list li {
    margin-bottom: var(--cf-spacing-sm);
}

.sswp-cf-sources-list a {
    color: var(--cf-accent);
    text-decoration: none;
    font-size: 14px;
    line-height: 1.4;
    display: block;
    padding: var(--cf-spacing-sm);
    border-radius: var(--cf-radius-sm);
    transition: background-color 0.2s;
}

.sswp-cf-sources-list a:hover {
    background-color: var(--cf-border);
    text-decoration: underline;
}

/* Input footer */
.sswp-cf-input {
    padding: var(--cf-spacing);
    background-color: var(--cf-bg);
    border-top: 1px solid var(--cf-border);
    position: sticky;
    bottom: 0;
    box-sizing: border-box;
    width: 100%;
}

.sswp-cf-form {
    display: flex;
    flex-direction: column;
    gap: var(--cf-spacing-sm);
    box-sizing: border-box;
    width: 100%;
}

.sswp-cf-form textarea {
    width: 100%;
    min-height: 44px;
    max-height: 132px; /* 6 lines max */
    padding: var(--cf-spacing);
    border: 1px solid var(--cf-border);
    border-radius: var(--cf-radius);
    background-color: var(--cf-bg);
    color: var(--cf-text);
    font-family: inherit;
    font-size: 16px;
    line-height: 1.4;
    resize: none;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    box-sizing: border-box;
}

.sswp-cf-form textarea:focus {
    border-color: var(--cf-accent);
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.2);
}

.sswp-cf-form textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.sswp-cf-actions {
    display: flex;
    gap: var(--cf-spacing-sm);
    flex-wrap: wrap;
    box-sizing: border-box;
    width: 100%;
}

.sswp-cf-actions button {
    padding: var(--cf-spacing-sm) var(--cf-spacing);
    border: 1px solid var(--cf-border);
    border-radius: var(--cf-radius);
    background-color: var(--cf-bg);
    color: var(--cf-text);
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    box-sizing: border-box;
}

.sswp-cf-actions button:hover:not(:disabled) {
    background-color: var(--cf-bg-alt);
    border-color: var(--cf-accent);
}

.sswp-cf-actions button:focus-visible {
    outline: 2px solid var(--cf-accent);
    outline-offset: 2px;
}

.sswp-cf-actions button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.sswp-cf-send {
    background-color: var(--cf-accent) !important;
    color: white !important;
    border-color: var(--cf-accent) !important;
}

.sswp-cf-send:hover:not(:disabled) {
    background-color: #005a87 !important;
    border-color: #005a87 !important;
}

/* Notifications */
.sswp-cf-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: var(--cf-spacing);
    border-radius: var(--cf-radius);
    color: white;
    font-weight: 500;
    z-index: 1000;
    animation: slideIn 0.3s ease-out;
}

.sswp-cf-notification-success {
    background-color: #28a745;
}

.sswp-cf-notification-error {
    background-color: #dc3545;
}

.sswp-cf-notification-info {
    background-color: var(--cf-accent);
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Markdown content styles */
.sswp-cf-msg-content pre {
    background-color: var(--cf-bg);
    border: 1px solid var(--cf-border);
    border-radius: var(--cf-radius-sm);
    padding: var(--cf-spacing);
    overflow-x: auto;
    margin: var(--cf-spacing-sm) 0;
}

.sswp-cf-msg-content code {
    background-color: var(--cf-bg);
    border: 1px solid var(--cf-border);
    border-radius: var(--cf-radius-sm);
    padding: 2px 4px;
    font-family: 'Courier New', monospace;
    font-size: 0.9em;
}

.sswp-cf-msg-content pre code {
    background: none;
    border: none;
    padding: 0;
}

.sswp-cf-msg-content a {
    color: var(--cf-accent);
    text-decoration: underline;
}

.sswp-cf-msg-content a:hover {
    text-decoration: none;
}

/* Layout variations */
.sswp-full-page-layout[data-layout="contained"] {
    max-width: var(--cf-maxw);
    margin: 0 auto;
}

/* Access denied styles */
.sswp-chat-full-denied {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    padding: var(--cf-spacing-lg);
    background-color: var(--cf-bg-alt);
    border: 1px solid var(--cf-border);
    border-radius: var(--cf-radius);
    text-align: center;
}

.sswp-cf-denied-content h3 {
    margin: 0 0 var(--cf-spacing) 0;
    color: var(--cf-text);
    font-size: 18px;
    font-weight: 600;
}

.sswp-cf-denied-content p {
    margin: 0 0 var(--cf-spacing-sm) 0;
    color: var(--cf-text-muted);
    line-height: 1.5;
}

.sswp-cf-login-link {
    display: inline-block;
    padding: var(--cf-spacing-sm) var(--cf-spacing);
    background-color: var(--cf-accent);
    color: white;
    text-decoration: none;
    border-radius: var(--cf-radius);
    font-weight: 500;
    transition: background-color 0.2s;
}

.sswp-cf-login-link:hover {
    background-color: #005a87;
    color: white;
    text-decoration: none;
}

/* Session menu styles */
.sswp-cf-session-menu {
    position: relative;
    display: inline-block;
}

.sswp-cf-session-overflow {
    background: none;
    border: none;
    color: var(--cf-text-muted);
    font-size: 18px;
    cursor: pointer;
    padding: var(--cf-spacing-sm);
    border-radius: var(--cf-radius);
    transition: all 0.2s;
}

.sswp-cf-session-overflow:hover {
    background-color: var(--cf-bg-alt);
    color: var(--cf-text);
}

.sswp-cf-session-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background: var(--cf-bg);
    border: 1px solid var(--cf-border);
    border-radius: var(--cf-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    min-width: 160px;
    overflow: hidden;
}

.sswp-cf-session-dropdown button {
    display: block;
    width: 100%;
    padding: var(--cf-spacing-sm) var(--cf-spacing);
    background: none;
    border: none;
    text-align: left;
    color: var(--cf-text);
    cursor: pointer;
    transition: background-color 0.2s;
    font-size: 14px;
}

.sswp-cf-session-dropdown button:hover {
    background-color: var(--cf-bg-alt);
}

.sswp-cf-session-dropdown button:not(:last-child) {
    border-bottom: 1px solid var(--cf-border);
}

/* Accessibility - Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .sswp-cf-msg,
    .sswp-cf-send,
    .sswp-cf-regenerate,
    .sswp-cf-copy,
    .sswp-cf-clear,
    .sswp-cf-toggle-sources,
    .sswp-cf-sources-close,
    .sswp-cf-session-overflow,
    .sswp-cf-session-dropdown button {
        transition: none !important;
        animation: none !important;
    }
    
    .sswp-cf-messages {
        scroll-behavior: auto !important;
    }
}

/* Performance optimizations */
.sswp-cf-reduced-motion * {
    transition: none !important;
    animation: none !important;
}

/* Responsive design */
@media (max-width: 768px) {
    .sswp-full-page-wrap {
        min-height: 70vh;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }
    
    .sswp-cf-main {
        flex-direction: column;
    }
    
    .sswp-cf-sources {
        width: 100%;
        max-height: 50vh;
        border-left: none;
        border-top: 1px solid var(--cf-border);
        position: relative;
    }
    
    .sswp-cf-msg {
        max-width: 90%;
    }
    
    .sswp-cf-actions {
        justify-content: center;
    }
    
    .sswp-cf-actions button {
        flex: 1;
        min-width: 0;
    }
}

@media (max-width: 480px) {
    .sswp-cf-header {
        padding: var(--cf-spacing);
    }
    
    .sswp-cf-title {
        font-size: 20px;
    }
    
    .sswp-cf-subtitle {
        font-size: 14px;
    }
    
    .sswp-cf-messages {
        padding: var(--cf-spacing-sm);
    }
    
    .sswp-cf-input {
        padding: var(--cf-spacing-sm);
    }
}

/* Typing Animation */
.sswp-typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: var(--cf-spacing-sm) 0;
    opacity: 0.7;
}

.sswp-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--cf-text-muted);
    animation: sswp-typing-bounce 1.4s infinite ease-in-out both;
}

.sswp-typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

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

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

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