/* ========================================================================== */
/* AGENT.CSS - LEGALIZY AI CHAT INTERFACE STYLES */
/* ========================================================================== */

/* ========================================================================== */
/* 1. GLOBAL RESET AND BASE STYLES */
/* ========================================================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

i {
    color: inherit;
}

/* ========================================================================== */
/* 2. LAYOUT CONTAINERS AND STRUCTURE */
/* ========================================================================== */

/* Sidebar visibility controls */
.s-hidden {
    display: none;
}

.s-active {
    display: block;
}

/* ========================================================================== */
/* 3. SIDEBAR STYLES */
/* ========================================================================== */

/* Sidebar search section styling */
.sidebar-search {
    background: linear-gradient(135deg, #e8f5e8 0%, #f0f8f0 100%) !important;
    border: 2px solid #28a745 !important;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.1);
    transition: all 0.3s ease;
}

.sidebar-search:hover {
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.2);
    transform: translateY(-1px);
}

.sidebar-search .form-control {
    border: 1px solid #28a745;
    background-color: white;
    font-size: 0.9rem;
}

.sidebar-search .form-control:focus {
    border-color: #28a745;
    box-shadow: 0 0 0 0.2rem rgba(40, 167, 69, 0.25);
}

.sidebar-search .btn {
    font-size: 0.85rem;
    font-weight: 600;
}

/* Workspace list styling */
#workspace-list {
    max-height: 125px;
    overflow: scroll;
}

/* ========================================================================== */
/* 4. CHAT INTERFACE STYLES */
/* ========================================================================== */

/* Chat input wrapper */
#input-wrapper {
    max-width: 90%;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%) !important;
    border: 2px solid #007bff !important;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.1);
    transition: all 0.3s ease;
}

#input-wrapper:hover {
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.2);
    border-color: #0056b3;
}

#input-wrapper:focus-within {
    border-color: #0056b3;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Chat input field */
#chat-input {
    min-height: 80px;
    border: none;
    resize: none;
    line-height: 1.5;
}

#chat-input:focus {
    outline: none;
}

/* Service toggler */
#serviceToggler {
    border: 0 !important;
}

/* ========================================================================== */
/* 5. MESSAGE STYLES */
/* ========================================================================== */

/* Message container */
.msg-info {
    background-color: rgba(211, 211, 211, 0.3);
    width: 75%;
}

/* Message icon */
.msg-icon {
    padding: 10px;
    border-radius: 10px;
    font-family: "Inter";
    background-color: #2049de;
    color: white;
    font-weight: 800;
}

/* Message name */
.msg-name {
    font-family: "Inter";
    font-weight: bold;
}

/* Message date */
.msg-date {
    font-family: "Open Sans";
}

/* Message body */
.msg-body {
    font-family: "DM Sans";
    font-size: 1.25rem;
}

/* Message sources */
.msg-sources {
    font-family: "Inter";
    font-size: 0.75rem;
}

/* Message intermediate steps */
.msg-intermediate {
    font-family: "Inter";
    font-weight: bold;
    font-size: 1rem;
}

/* ========================================================================== */
/* 6. DOCUMENT STYLES */
/* ========================================================================== */

/* Document info container */
.doc-info {
    max-width: 90%;
}

/* Document toggle button */
.doc-toggle {
    max-width: 10%;
}

/* Document reference links */
.doc-ref-link,
.source-link {
    background: none !important;
    border: none;
    padding: 0 !important;
    color: blue;
    text-align: left;
    font-size: 0.75rem;
    text-decoration: underline;
    cursor: pointer;
}

/* ========================================================================== */
/* 7. NAVIGATION AND TABS */
/* ========================================================================== */

/* Navigation tabs */
.nav-tabs .nav-link {
    transition: all 0.3s ease;
}

.nav-tabs .nav-link:hover {
    transform: translateY(-2px);
}

.nav-tabs .nav-link.active {
    background: linear-gradient(135deg, #5578de 0%, #4169e1 100%) !important;
    border-color: #5578de !important;
    color: white !important;
    font-weight: 600;
}

/* Document tab navigation */
#document-tab-nav {
    transition: all 0.3s ease;
}

/* Document title styling */
#document-tab .position-sticky h5 {
    color: #007bff !important;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

/* ========================================================================== */
/* 8. UTILITY CLASSES */
/* ========================================================================== */

/* Text utilities */
.word-break {
    text-overflow: ellipsis;
    overflow: hidden;
    text-wrap: nowrap;
}

.text-wrap {
    text-wrap: wrap;
    word-break: break-all;
}

/* List styling */
.list-group-item.active {
    background-color: gainsboro;
    border-color: gainsboro;
    color: black;
}

.list-group-item-action:not(.active):hover {
    z-index: 3;
}

/* Search elements */
.search-element {
    font-size: 0.95rem;
}

.highlight-results > em {
    font-weight: bold;
}

.search-highlight.current-match {
    background-color: orange;
}

/* Copy button */
.copy-button {
    border: none;
    cursor: pointer;
}

/* ========================================================================== */
/* 9. ANIMATIONS AND EFFECTS */
/* ========================================================================== */

/* Grow shrink animation */
.grow-shrink {
    animation: grow-shrink 1s ease-in-out infinite;
}

@keyframes grow-shrink {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

/* Thinking message animations */
.thinking-message-chat {
    animation: thinking-fade-in 0.3s ease-in-out;
}

.thinking-message-chat .msg-body {
    animation: thinking-pulse 1.5s ease-in-out infinite;
}

.thinking-message-chat .spinner-border-sm {
    width: 1rem;
    height: 1rem;
    border-width: 2px;
}

.thinking-text {
    font-style: italic;
    color: #6c757d;
}

@keyframes thinking-pulse {
    0%,
    100% {
        opacity: 0.7;
    }
    50% {
        opacity: 1;
    }
}

@keyframes thinking-fade-in {
    0% {
        opacity: 0;
        transform: translateY(10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Loading text animation */
.loading-text {
    position: relative;
    color: var(--bs-success);
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
    background: rgba(25, 135, 84, 0.1);
}

.loading-text::after {
    content: "Procesando";
    animation: loadingDots 1.5s infinite;
}

.loading-text::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 4px;
    border: 1px solid var(--bs-success);
    animation: pulse 2s ease-in-out infinite;
}

@keyframes loadingDots {
    0% {
        content: "Procesando";
    }
    25% {
        content: "Procesando.";
    }
    50% {
        content: "Procesando..";
    }
    75% {
        content: "Procesando...";
    }
    100% {
        content: "Procesando";
    }
}

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

/* ========================================================================== */
/* 10. EXCERPT EXPLORER */
/* ========================================================================== */

.excerpt-explorer {
    transition: width 0.3s ease;
    z-index: 10;
}

.excerpt-item {
    cursor: pointer;
    transition: all 0.2s ease;
}

.excerpt-item:hover {
    background-color: #f0f7ff !important;
    transform: translateY(-2px);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

.excerpt-text {
    color: #555;
    line-height: 1.4;
    word-wrap: break-word;
}

.excerpt-text-container {
    position: relative;
}

.excerpt-toggle {
    font-size: 0.75rem !important;
    line-height: 1;
    margin-top: 0.25rem;
}

#temp-excerpt-marker {
    transition: background-color 2s;
    padding: 2px 0;
    border-radius: 2px;
}

/* ========================================================================== */
/* 11. ALERT AND BUTTON STYLES */
/* ========================================================================== */

/* Help alert styling */
.alert-info {
    background: linear-gradient(135deg, #d1ecf1 0%, #bee5eb 100%) !important;
    border-color: #17a2b8 !important;
    border-left: 4px solid #17a2b8 !important;
}

/* Disabled button styling */
.btn.disabled,
.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    pointer-events: none;
}

.btn-outline-primary.disabled,
.btn-outline-primary:disabled {
    background-color: #f8f9fa;
    border-color: #dee2e6;
    color: #6c757d;
}

/* ========================================================================== */
/* 12. UPGRADE BANNER HEIGHT CALCULATION */
/* ========================================================================== */

:root {
    --header-base-height: 70px;
    --banner-height: 0px;
}

.upgrade-banner-visible {
    --banner-height: 30px;
}

#chat-content-tabs {
    height: calc(100vh - var(--header-base-height) - var(--banner-height)) !important;
    height: calc(100dvh - var(--header-base-height) - var(--banner-height)) !important;
}

/* Make search content scrollable to preserve tab visibility */
#search-tab {
    height: 100% !important;
    overflow-y: auto !important;
}

#search-tab-content {
    height: 100% !important;
    overflow-y: auto !important;
}

/* ========================================================================== */
/* 13. STICKY CHAT INPUT LAYOUT */
/* ========================================================================== */

#main-tab {
    display: none !important;
}

#main-tab.show.active {
    display: flex !important;
    flex-direction: column !important;
    height: 100% !important;
}

#main-tab.show.active #chat-main {
    flex: 1 !important;
    overflow-y: auto !important;
    overflow-x: hidden !important;
    padding: 1rem !important;
    padding-bottom: 2rem !important;
    scroll-behavior: smooth !important;
}

/* Custom scrollbar styling */
#chat-main::-webkit-scrollbar {
    width: 8px;
}

#chat-main::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

#chat-main::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

#chat-main::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

#main-tab.show.active #chat-bottom {
    position: sticky !important;
    bottom: 0 !important;
    background-color: white !important;
    padding: 0.75rem 1rem !important;
    z-index: 100 !important;
    flex-shrink: 0 !important;
}

#main-tab.show.active #chat-bottom.container-fluid {
    padding-left: 1rem !important;
    padding-right: 1rem !important;
}

/* ========================================================================== */
/* 14. RESPONSIVE DESIGN */
/* ========================================================================== */

/* Mobile and small screens (0px and up) */
@media screen and (min-width: 0) {
    .offcanvas {
        display: block !important;
    }
    .sidebar {
        display: none !important;
    }
    main {
        width: 100%;
    }
    textarea {
        font-size: 1.25rem;
        margin-bottom: 5px;
    }
    .msg-body {
        font-size: 1rem;
    }
    .msg-sources {
        font-size: 0.75rem;
    }
    #user-dropdown {
        right: 0;
    }
    .pagination {
        transform: scale(0.9);
    }
}

/* Small screens (576px and up) */
@media screen and (min-width: 576px) {
    html {
        font-size: 15px;
    }
    .pagination {
        transform: scale(1);
    }
    .msg-body {
        font-size: 1rem;
    }
    .msg-sources {
        font-size: 0.75rem;
    }
    .msg-intermediate {
        font-family: "Inter";
        font-weight: bold;
        font-size: 1rem;
    }
    #user-dropdown {
        right: 15px;
    }
}

/* Large screens (992px and up) */
@media screen and (min-width: 992px) {
    .offcanvas {
        display: none !important;
    }
    .sidebar {
        display: block !important;
        max-height: 100vh;
        overflow: scroll;
        width: 25%;
    }
    main {
        width: 75%;
    }
}

/* Mobile specific styles (max-width: 768px) */
@media (max-width: 768px) {
    /* Upgrade banner mobile adjustments */
    .upgrade-banner-visible {
        --banner-height: 50px;
    }

    /* Document tab mobile responsive */
    #document-tab .position-sticky {
        padding: 0.75rem 1rem !important;
    }

    #document-tab .position-sticky h5 {
        font-size: 1rem !important;
    }

    #document-tab .position-sticky i {
        font-size: 0.9rem;
    }

    /* Navigation tabs mobile styling */
    .nav-tabs .nav-item .nav-link {
        min-height: 70px !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        text-align: center !important;
        padding: 0.75rem 0.5rem !important;
        white-space: normal !important;
        word-wrap: break-word !important;
        line-height: 1.2 !important;
    }

    .nav-tabs .nav-item {
        flex: 1 1 0% !important;
        min-width: 0 !important;
        height: 70px !important;
    }

    #chat-tabs.nav-tabs {
        height: 70px !important;
    }

    #chat-tabs.nav-tabs .nav-item {
        height: 70px !important;
    }

    #chat-tabs.nav-tabs .nav-link {
        height: 70px !important;
        box-sizing: border-box !important;
    }

    /* Excerpt explorer mobile */
    .excerpt-explorer {
        width: 250px !important;
    }

    /* Excerpt items mobile optimizations */
    .excerpt-item {
        margin-bottom: 0.75rem !important;
        padding: 0.75rem !important;
    }

    .excerpt-text {
        font-size: 0.875rem !important;
        line-height: 1.5 !important;
    }

    .excerpt-toggle {
        margin-top: 0.5rem !important;
    }

    .excerpt-modal-btn {
        padding: 0.25rem 0.5rem !important;
        font-size: 0.75rem !important;
    }

    /* Chat input mobile optimizations */
    #chat-bottom {
        position: sticky !important;
        bottom: 0 !important;
        background-color: white !important;
        padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0px)) !important;
        box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.15) !important;
    }

    #chat-input {
        font-size: 16px !important;
        transform: translateZ(0);
    }

    /* Mobile viewport adjustments - account for toggle header row */
    :root {
        --header-base-height: 120px; /* Increased to account for toggle header row on mobile */
    }

    #chat-main {
        padding: 0.75rem !important;
        padding-bottom: 3rem !important;
    }
}

/* ========================================================================== */
/* 15. MODEL TOGGLE STYLES */
/* ========================================================================== */

.model-toggle-container {
    text-align: center;
}

.model-toggle {
    display: inline-flex;
    background: #f8f9fa;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    padding: 4px;
    gap: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.model-toggle input[type="radio"] {
    display: none;
}

.model-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: white;
    border: 1px solid transparent;
    min-width: 90px;
    margin: 0;
}

.model-option:hover {
    background: #f8f9fa;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.model-option.premium:hover {
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
}

.model-toggle input[type="radio"]:checked + .model-option {
    background: #007bff;
    color: white;
    border-color: #0056b3;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.model-toggle input[type="radio"]:checked + .model-option.premium {
    background: linear-gradient(135deg, #ffc107 0%, #f39c12 100%);
    color: #212529;
    border-color: #e0a800;
    box-shadow: 0 2px 8px rgba(255, 193, 7, 0.4);
}

.model-name {
    font-weight: 600;
    font-size: 0.85rem;
    line-height: 1.2;
}

.model-description {
    font-size: 0.7rem;
    opacity: 0.8;
    line-height: 1;
    margin-top: 2px;
}

.model-toggle input[type="radio"]:checked + .model-option .model-description {
    opacity: 1;
}

.model-warning {
    margin-top: 8px;
    padding: 6px 12px;
    background: linear-gradient(135deg, #fff3cd 0%, #ffeaa7 100%);
    border: 1px solid #ffc107;
    border-radius: 6px;
    font-size: 0.75rem;
    color: #856404;
    display: flex;
    align-items: center;
    gap: 6px;
    animation: fadeInWarning 0.3s ease;
}

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

/* Mobile responsiveness for model toggle */
@media (max-width: 768px) {
    .model-toggle {
        flex-direction: row;
        width: 100%;
        max-width: 300px;
    }

    .model-option {
        flex: 1;
        min-width: 80px;
        padding: 6px 12px;
    }

    .model-name {
        font-size: 0.8rem;
    }

    .model-description {
        font-size: 0.65rem;
    }

    .model-warning {
        font-size: 0.7rem;
        padding: 4px 8px;
    }
}

/* ========================================================================== */
/* 16. MODEL INDICATOR BADGES IN MESSAGES */
/* ========================================================================== */

.model-indicator {
    margin-left: auto;
}

.model-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 12px;
    border: 1px solid;
    white-space: nowrap;
    transition: all 0.2s ease;
}

.model-badge i {
    font-size: 0.75rem;
}

.model-standard {
    background: linear-gradient(135deg, #e3f2fd 0%, #bbdefb 100%);
    color: #1976d2;
    border-color: #42a5f5;
}

.model-premium {
    background: linear-gradient(135deg, #fff3e0 0%, #ffcc02 100%);
    color: #f57c00;
    border-color: #ffa726;
    box-shadow: 0 1px 3px rgba(255, 167, 38, 0.2);
}

.model-premium i {
    color: #ff9800;
}

/* Hover effects for model badges */
.model-badge:hover {
    transform: scale(1.05);
}

.model-standard:hover {
    background: linear-gradient(135deg, #bbdefb 0%, #90caf9 100%);
    box-shadow: 0 2px 4px rgba(25, 118, 210, 0.2);
}

.model-premium:hover {
    background: linear-gradient(135deg, #ffcc02 0%, #ffa726 100%);
    box-shadow: 0 2px 4px rgba(255, 167, 38, 0.3);
}

/* Mobile responsiveness for model badges */
@media (max-width: 768px) {
    .model-badge {
        font-size: 0.65rem;
        padding: 1px 6px;
    }

    .model-badge i {
        font-size: 0.7rem;
    }
}
