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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: #f0f2f5;
    color: #111;
}

/* Login Screen */
.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-box {
    background: white;
    padding: 3rem;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
    text-align: center;
    min-width: 350px;
}

.login-box h1 {
    margin-bottom: 2rem;
    color: #333;
}

.btn-primary {
    background: #667eea;
    color: white;
    border: none;
    padding: 12px 32px;
    border-radius: 6px;
    font-size: 16px;
    cursor: pointer;
    transition: background 0.3s;
}

.btn-primary:hover {
    background: #5568d3;
}

.error-message {
    color: #e74c3c;
    margin-top: 1rem;
    font-size: 14px;
}

/* App Container */
.app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.app-header {
    background: white;
    padding: 1rem 2rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Localhost indicator - bright orange background */
body.localhost-mode .app-header {
    background: #ff6600 !important;
    background: linear-gradient(135deg, #ff6600 0%, #ff8800 100%) !important;
    border-bottom: 3px solid #ff4400;
}

body.localhost-mode .app-header h1,
body.localhost-mode .app-header span,
body.localhost-mode .user-info span {
    color: white !important;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.3);
}

.app-header h1 {
    font-size: 20px;
    color: #333;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-info span {
    font-weight: 500;
    color: #667eea;
}

.btn-secondary {
    background: #e0e0e0;
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.3s;
}

.btn-secondary:hover {
    background: #d0d0d0;
}

/* Chat Layout */
.chat-layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

.panel {
    background: white;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
}

.panel-chat {
    width: 70%;
    border-right: 1px solid #e0e0e0;
}

.panel-accordion {
    width: 30%;
    border-right: none;
    overflow-y: auto;
}

.search-phone-section {
    padding: 1rem;
    border-bottom: 2px solid #667eea;
    background: white;
    display: flex;
    gap: 0.5rem;
}

.search-phone-input {
    flex: 1;
    padding: 0.6rem 0.8rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.search-phone-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.btn-search-phone {
    padding: 0.6rem 1rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: 600;
    transition: background 0.2s;
    font-size: 14px;
}

.btn-search-phone:hover {
    background: #5568d3;
}

.panel-header {
    padding: 1rem;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f9f9f9;
}

.panel-header h2 {
    font-size: 16px;
    font-weight: 600;
}

.badge {
    background: #667eea;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
}

/* Accordion Styles */
.accordion-section {
    border-bottom: 1px solid #e0e0e0;
}

.accordion-header {
    padding: 1rem;
    background: #f9f9f9;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: background 0.2s;
}

.accordion-header:hover {
    background: #f0f0f0;
}

.accordion-header h2 {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
}

.accordion-arrow {
    font-size: 12px;
    transition: transform 0.3s;
    margin-left: 0.5rem;
}

.accordion-section.active .accordion-arrow {
    transform: rotate(-180deg);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
}

.accordion-section.active .accordion-content {
    max-height: calc(100vh - 300px);
    overflow-y: auto;
}

/* Conversation List */
.conversation-list {
    flex: 1;
    overflow-y: auto;
}

.conversation-item {
    padding: 1rem;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
}

.conversation-item:hover {
    background: #f9f9f9;
}

.conversation-item.active {
    background: #e3f2fd;
    border-left: 3px solid #667eea;
}

.conversation-item.closed {
    opacity: 0.75;
}

.conversation-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.conversation-phone {
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.conversation-time {
    font-size: 12px;
    color: #888;
}

.conversation-preview {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.5rem;
}

.conversation-meta .meta-right {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.unread-badge {
    background: #f44336;
    color: white;
    padding: 2px 6px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
}

.not-answered {
    font-size: 14px;
    margin-left: 4px;
    animation: pulse 2s infinite;
}

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

.status-badge {
    background: #4caf50;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
}

.status-badge.waiting {
    background: #ff9800;
}

.status-badge.closed {
    background: #9e9e9e;
}

.operator-badge {
    background: #2196f3;
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    margin-left: 4px;
}

.notes-flag {
    font-size: 14px;
    opacity: 0.5;
}

.notes-flag.has-notes {
    opacity: 1;
}

.notes-indicator {
    font-size: 12px;
    color: #888;
}

.notes-indicator.has-notes {
    color: #d35400;
    font-weight: 600;
}

/* Chat Area */
.chat-header {
    padding: 1rem;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f9f9f9;
}

.chat-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.chat-info h2 {
    font-size: 16px;
    margin-bottom: 4px;
}

.chat-phone {
    font-size: 12px;
    color: #888;
}

.chat-actions {
    display: flex;
    gap: 0.5rem;
}

.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s;
}

.btn-assign {
    background: #4caf50;
    color: white;
}

.btn-assign:hover {
    background: #45a049;
}

.btn-release {
    background: #ff9800;
    color: white;
}

.btn-release:hover {
    background: #fb8c00;
}

.btn-transfer {
    background: #2196f3;
    color: white;
}

.btn-transfer:hover {
    background: #1e88e5;
}

.btn-close {
    background: #f44336;
    color: white;
}

.btn-close:hover {
    background: #e53935;
}

.btn-auto {
    background: #2196f3;
    color: white;
}

.btn-auto:hover {
    background: #1e88e5;
}

.btn-toggle-tools {
    background: #9e9e9e;
    color: white;
    font-size: 12px;
    padding: 6px 12px;
}

.btn-toggle-tools:hover {
    background: #757575;
}

.btn-toggle-tools.active {
    background: #667eea;
}

.btn-toggle-tools.active:hover {
    background: #5568d3;
}

.btn-notes,
.btn-notes-save {
    background: #ffe082;
    color: #4e342e;
    font-size: 12px;
}

.btn-notes:hover,
.btn-notes-save:hover {
    background: #ffd54f;
}

.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #e5ddd5;
}

.message {
    max-width: 60%;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    word-wrap: break-word;
}

.message.user {
    background: white;
    margin-right: auto;
    border-bottom-left-radius: 2px;
}

.message.operator, .message.bot, .message.model {
    background: #dcf8c6;
    margin-left: auto;
    border-bottom-right-radius: 2px;
}

.message.tool {
    background: #fff3cd;
    margin-left: auto;
    border-bottom-right-radius: 2px;
    border-left: 3px solid #ff9800;
}

.message.system {
    background: #e3f2fd;
    margin: 0 auto;
    font-style: italic;
    border-radius: 8px;
}

.message-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 0.25rem;
    font-size: 11px;
    color: #666;
}

.message-origin {
    font-weight: 600;
}

.message-time {
    opacity: 0.7;
}

.message-text {
    font-size: 14px;
    line-height: 1.4;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-text pre {
    background: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 12px;
    margin: 8px 0;
    overflow-x: auto;
}

.message-text pre code {
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    color: #333;
}

.message-text code {
    background: #f0f0f0;
    padding: 2px 4px;
    border-radius: 3px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 12px;
    color: #d63384;
}

.message-link {
    color: #667eea;
    text-decoration: none;
    cursor: pointer;
}

.message-link:hover {
    text-decoration: underline;
}

/* Message Input */
.message-input {
    padding: 1rem;
    background: #f9f9f9;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 0.5rem;
}

#input-text {
    flex: 1;
    padding: 0.75rem;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    resize: none;
}

#input-text:focus {
    outline: none;
    border-color: #667eea;
}

.btn-send {
    background: #667eea;
    color: white;
    border: none;
    padding: 0.75rem 2rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.3s;
}

.btn-send:hover {
    background: #5568d3;
}

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: #888;
    font-size: 14px;
}

/* Image Popup */
.image-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.image-popup img {
    max-width: 90%;
    max-height: 90%;
}

.close-popup {
    position: absolute;
    top: 20px;
    right: 20px;
    background: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 16px;
}

/* Scrollbars */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f0f0f0;
}

::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #aaa;
}

/* Mobile-only elements - hidden on desktop */
.mobile-accordion-toggle {
    display: none;
}

.mobile-overlay {
    display: none;
}

.client-ids-toggle {
    display: none;
}

.mobile-actions-toggle {
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    .app-header h1 {
        font-size: 16px;
    }
    
    .user-info {
        gap: 0.5rem;
    }
    
    .user-info span {
        display: none;
    }
    
    /* Hide config and admin buttons on mobile */
    #config-btn,
    #admin-btn {
        display: none !important;
    }
    
    .btn-secondary {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    /* Hide tabs that don't make sense on mobile */
    .tab-button[data-tab="prompts"],
    .tab-button[data-tab="templates"],
    .tab-button[data-tab="users"],
    .tab-button[data-tab="estudio"] {
        display: none !important;
    }
    
    /* Keep only Chat tab visible on mobile, reserve space for Pagos */
    .tabs-container {
        justify-content: flex-start;
    }
    
    .chat-layout {
        flex-direction: column;
        position: relative;
    }
    
    .panel-chat {
        width: 100%;
        height: 100%;
        flex: 1;
    }
    
    .panel-accordion {
        position: fixed;
        top: 0;
        left: 0;
        width: 85%;
        max-width: 320px;
        height: 100%;
        z-index: 1001;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 2px 0 10px rgba(0,0,0,0.3);
    }
    
    .panel-accordion.mobile-visible {
        transform: translateX(0);
    }
    
    /* Overlay when accordion is open */
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 1000;
    }
    
    .mobile-overlay.visible {
        display: block;
    }
    
    /* Toggle button for accordion */
    .mobile-accordion-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        bottom: 100px;
        right: 20px;
        width: 56px;
        height: 56px;
        background: #667eea;
        color: white;
        border: none;
        border-radius: 50%;
        box-shadow: 0 4px 12px rgba(0,0,0,0.3);
        cursor: pointer;
        font-size: 24px;
        z-index: 999;
        transition: background 0.3s;
    }
    
    .mobile-accordion-toggle:hover {
        background: #5568d3;
    }
    
    /* Chat header adjustments */
    .chat-header {
        flex-wrap: wrap;
        padding: 0.75rem;
    }
    
    .chat-info {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    .chat-info h2 {
        font-size: 14px;
    }
    
    .chat-phone {
        font-size: 11px;
    }
    
    /* Client IDs - make collapsible on mobile */
    .client-ids-container {
        width: 100%;
        margin-top: 8px;
    }
    
    .client-ids-container.collapsed {
        display: none !important;
    }
    
    .client-ids-toggle {
        display: inline-block;
        background: #667eea;
        color: white;
        border: none;
        padding: 4px 8px;
        border-radius: 4px;
        font-size: 11px;
        cursor: pointer;
        margin-top: 4px;
    }
    
    /* Chat actions - make menu on mobile */
    .chat-actions {
        display: none !important;
    }
    
    .chat-actions.mobile-menu-open {
        display: flex !important;
        flex-direction: column;
        position: absolute;
        top: calc(100% + 4px);
        right: 0;
        background: white;
        border: 1px solid #e0e0e0;
        border-radius: 6px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.2);
        padding: 0.5rem;
        gap: 0.5rem;
        z-index: 100;
        min-width: 150px;
    }
    
    .chat-actions.mobile-menu-open .btn {
        width: 100%;
        justify-content: flex-start;
    }
    
    .mobile-actions-toggle {
        display: flex;
        background: #667eea;
        color: white;
        border: none;
        padding: 8px 12px;
        border-radius: 6px;
        cursor: pointer;
        font-size: 13px;
        align-items: center;
        gap: 4px;
    }
    
    .chat-controls {
        position: relative;
    }
    
    /* Message input adjustments */
    .message-input {
        padding: 0.5rem;
    }
    
    #input-text {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    .btn-send {
        padding: 0.75rem 1rem;
        font-size: 13px;
    }
    
    .message-input-controls {
        top: 5px;
        right: 70px;
    }
    
    .btn-insert-template {
        padding: 6px 10px;
        font-size: 14px;
    }
    
    /* Documents section */
    .documents-section {
        font-size: 13px;
    }
    
    /* Messages */
    .message {
        max-width: 85%;
        font-size: 14px;
    }
    
    .message-header {
        font-size: 10px;
    }
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
}

.modal-small {
    max-width: 420px;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    font-size: 20px;
    color: #333;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #888;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background 0.3s;
}

.close-btn:hover {
    background: #f0f0f0;
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
    margin-top: 1rem;
}

.transfer-select,
#transfer-comment {
    width: 100%;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    padding: 0.6rem;
    font-family: inherit;
    margin-bottom: 0.75rem;
}

.config-section {
    margin-bottom: 2rem;
}

.config-section h3 {
    font-size: 16px;
    margin-bottom: 0.5rem;
    color: #333;
}

.config-description {
    font-size: 14px;
    color: #666;
    margin-bottom: 1rem;
    line-height: 1.5;
}

.config-textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-family: inherit;
    font-size: 14px;
    resize: vertical;
    min-height: 150px;
}

.config-textarea:focus {
    outline: none;
    border-color: #667eea;
}

.config-actions {
    margin-top: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.config-status {
    font-size: 14px;
    color: #4caf50;
}

/* Tabs */
.tabs-container {
    display: flex;
    background: white;
    border-bottom: 2px solid #e0e0e0;
    padding: 0 2rem;
    gap: 1rem;
}

/* Localhost indicator - tabs with orange background */
body.localhost-mode .tabs-container {
    background: #ff6600 !important;
    background: linear-gradient(135deg, #ff6600 0%, #ff8800 100%) !important;
    border-bottom-color: #ff4400;
}

body.localhost-mode .tab-button {
    color: white !important;
    border-bottom-color: transparent;
}

body.localhost-mode .tab-button:hover {
    color: #ffe6d9 !important;
    background: rgba(255, 255, 255, 0.1);
}

body.localhost-mode .tab-button.active {
    color: white !important;
    border-bottom-color: white !important;
    background: rgba(255, 255, 255, 0.2);
}

.tab-button {
    background: none;
    border: none;
    padding: 1rem;
    font-size: 14px;
    cursor: pointer;
    color: #666;
    border-bottom: 3px solid transparent;
    transition: all 0.3s;
    font-weight: 500;
}

.tab-button:hover {
    color: #333;
}

.tab-button.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

/* Admin Tabs */
.admin-tab {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
}

.admin-header {
    margin-bottom: 2rem;
}

.admin-header h2 {
    color: #333;
    margin-bottom: 1rem;
}

.search-users {
    margin-bottom: 1rem;
}

.search-input {
    width: 100%;
    max-width: 400px;
    padding: 0.75rem;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: 14px;
}

.search-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.admin-content {
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Prompts Container - Two Panel Layout */
/* Higher specificity to override .admin-tab padding and ensure flex layout.
   The prompts container uses a two-column layout with internal padding in child elements,
   so it needs padding: 0 unlike other admin tabs. */
.admin-tab.prompts-container {
    display: flex;
    padding: 0;
    overflow: hidden;
}

.prompts-sidebar {
    width: 33%;
    background: white;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.prompts-sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    background: #f9f9f9;
}

.prompts-sidebar-header h3 {
    font-size: 18px;
    color: #333;
    margin: 0;
}

.prompts-list {
    flex: 1;
    overflow-y: auto;
    padding: 0;
}

.btn-create-prompt {
    width: calc(100% - 3rem);
    margin: 1rem 1.5rem;
    padding: 0.75rem 1rem;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: background 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-create-prompt:hover {
    background: #5568d3;
}

.prompt-list-item {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
    background: white;
}

.prompt-list-item:hover {
    background: #f9f9f9;
}

.prompt-list-item.active {
    background: #e3f2fd;
    border-left: 3px solid #667eea;
}

.prompt-list-item-name {
    font-weight: 600;
    font-size: 14px;
    color: #333;
    margin-bottom: 0.25rem;
}

.prompt-list-item-preview {
    font-size: 12px;
    color: #888;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.prompts-editor {
    width: 67%;
    background: white;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.prompts-editor-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    background: #f9f9f9;
}

.prompts-editor-header h3 {
    font-size: 18px;
    color: #333;
    margin: 0;
}

.prompts-editor-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 1.5rem;
}

.prompt-textarea {
    width: 100%;
    padding: 1rem;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-family: monospace;
    font-size: 14px;
    resize: none;
    flex: 1;
    margin-bottom: 1rem;
}

.prompt-config-row {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.prompt-config-item {
    flex: 1;
    min-width: 150px;
}

.prompt-config-item.large {
    min-width: 200px;
}

.prompt-config-item label {
    display: block;
    margin-bottom: 0.3rem;
    font-weight: 500;
    color: #555;
}

.config-select, 
.config-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.prompt-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

/* Chat Area - Estudio Tab */
.estudio-layout {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 20px;
    gap: 20px;
}

.estudio-control-panel {
    background: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.estudio-control-panel h2 {
    margin-bottom: 15px;
    color: #333;
}

.estudio-controls {
    display: flex;
    gap: 20px;
    align-items: flex-end;
}

.control-group {
    flex: 1;
}

.control-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: #555;
}

.estudio-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
}

.control-buttons {
    display: flex;
    gap: 10px;
}

.estudio-content {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 20px;
    flex: 1;
    min-height: 0;
}

.estudio-panel {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.estudio-panel-header {
    background: #f8f9fa;
    padding: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.estudio-panel-header h3 {
    margin: 0;
    font-size: 16px;
    color: #333;
}

.estudio-messages {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.estudio-message {
    padding: 10px 15px;
    border-radius: 8px;
    max-width: 85%;
    word-wrap: break-word;
}

.estudio-message.user {
    background: #667eea;
    color: white;
    align-self: flex-end;
    margin-left: auto;
}

.estudio-message.bot {
    background: #e9ecef;
    color: #333;
    align-self: flex-start;
}

.estudio-message.system {
    background: #fff3cd;
    color: #856404;
    align-self: center;
    text-align: center;
    font-size: 12px;
    font-style: italic;
}

.estudio-input-area {
    padding: 15px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 10px;
}

.estudio-input-area textarea {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    resize: none;
    font-family: inherit;
}

.estudio-output-content {
    padding: 15px;
    overflow-y: auto;
    flex: 1;
}

.output-section {
    margin-bottom: 20px;
}

.output-section h4 {
    margin-bottom: 8px;
    color: #555;
    font-size: 14px;
}

.output-value {
    background: #f8f9fa;
    padding: 10px;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.error-text {
    color: #dc3545;
}

.estudio-history-content {
    padding: 15px;
    overflow-y: auto;
    flex: 1;
}

.history-message {
    margin-bottom: 15px;
    padding: 10px;
    border-left: 3px solid #667eea;
    background: #f8f9fa;
    border-radius: 4px;
}

.history-message-header {
    font-weight: 600;
    color: #667eea;
    margin-bottom: 5px;
    font-size: 13px;
}

.history-message-content {
    font-size: 13px;
    color: #333;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.history-message.tool {
    border-left-color: #28a745;
}

.history-message.tool .history-message-header {
    color: #28a745;
}

.history-message.model {
    border-left-color: #17a2b8;
}

.history-message.model .history-message-header {
    color: #17a2b8;
}

/* Documents Section */
.documents-section {
    background: #fff;
    border-bottom: 1px solid #e0e0e0;
}

.documents-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #f5f5f5;
    cursor: pointer;
    border-bottom: 1px solid #e0e0e0;
}

.documents-title {
    font-weight: 600;
    font-size: 14px;
    color: #333;
}

.btn-toggle-documents {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    padding: 4px 8px;
}

.btn-toggle-documents:hover {
    color: #333;
}

.documents-list {
    max-height: 200px;
    overflow-y: auto;
    padding: 8px 12px;
}

/* Notes Panel */
.notes-panel {
    background: #fffdf5;
    border-bottom: 1px solid #e0e0e0;
}

.notes-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #fff7e6;
    border-bottom: 1px solid #f0e0c0;
}

.notes-header-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.notes-title {
    font-weight: 600;
    color: #5d4037;
    font-size: 14px;
}

.notes-updated {
    font-size: 11px;
    color: #8d6e63;
}

.btn-toggle-notes {
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 16px;
    color: #8d6e63;
}

#notes-textarea {
    width: 100%;
    border: 1px solid #ead1a4;
    border-radius: 6px;
    padding: 0.75rem;
    font-family: inherit;
    margin: 0 15px;
    resize: vertical;
    min-height: 100px;
    background: #fffef9;
}

.notes-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 10px 15px 15px 15px;
}

.notes-status {
    font-size: 12px;
    color: #4caf50;
}

.notes-status.error {
    color: #f44336;
}

.document-item {
    display: flex;
    align-items: center;
    padding: 8px 10px;
    margin-bottom: 6px;
    background: #f9f9f9;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
    transition: background 0.2s;
}

.document-item:hover {
    background: #f0f0f0;
}

.document-icon {
    font-size: 24px;
    margin-right: 10px;
}

.document-info {
    flex: 1;
    min-width: 0;
}

.document-filename {
    font-weight: 500;
    font-size: 13px;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.document-date {
    font-size: 11px;
    color: #666;
    margin-top: 2px;
}

.document-view {
    font-size: 20px;
    text-decoration: none;
    margin-left: 10px;
    cursor: pointer;
    transition: transform 0.2s;
}

.document-view:hover {
    transform: scale(1.2);
}

.document-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: 10px;
}

.document-play {
    font-size: 20px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.document-play:hover {
    transform: scale(1.2);
}

.document-download {
    font-size: 16px;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s;
}

.document-download:hover {
    transform: scale(1.2);
}

/* Client IDs Container */
.client-ids-container {
    margin-top: 8px;
    padding: 8px;
    background: #f5f5f5;
    border-radius: 6px;
    border: 1px solid #e0e0e0;
}

.client-ids-label {
    font-size: 12px;
    font-weight: 600;
    color: #666;
    margin-right: 8px;
}

.client-ids-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 6px;
}

.client-id-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    background: white;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.client-id-badge:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.client-id-badge .copy-icon {
    font-size: 11px;
    opacity: 0.7;
}

/* Client Info Modal */
.client-info-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.client-info-content {
    background: white;
    border-radius: 12px;
    max-width: 800px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.3);
}

.client-info-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-radius: 12px 12px 0 0;
}

.client-info-header h3 {
    margin: 0;
    font-size: 20px;
}

.client-info-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    transition: background 0.2s;
}

.client-info-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.client-info-body {
    padding: 20px;
}

.client-info-section {
    margin-bottom: 24px;
}

.client-info-section h4 {
    color: #667eea;
    margin-bottom: 12px;
    font-size: 16px;
    border-bottom: 2px solid #667eea;
    padding-bottom: 6px;
}

.client-info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.client-info-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.client-info-field-label {
    font-size: 11px;
    font-weight: 600;
    color: #888;
    text-transform: uppercase;
}

.client-info-field-value {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: #f9f9f9;
    border-radius: 4px;
    font-size: 14px;
    color: #333;
}

.client-info-copy-btn {
    background: #667eea;
    color: white;
    border: none;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    transition: background 0.2s;
}

.client-info-copy-btn:hover {
    background: #5568d3;
}

.client-orders-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
}

.client-orders-table th,
.client-orders-table td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.client-orders-table th {
    background: #f5f5f5;
    font-weight: 600;
    font-size: 12px;
    color: #666;
    text-transform: uppercase;
}

.client-orders-table td {
    font-size: 14px;
}

.client-orders-table tr:hover {
    background: #f9f9f9;
}

.order-status {
    display: inline-block;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
}

.order-status.verificando {
    background: #fff3cd;
    color: #856404;
}

.order-status.preparacion {
    background: #d1ecf1;
    color: #0c5460;
}

.order-status.enviado {
    background: #d4edda;
    color: #155724;
}

.client-info-loading {
    text-align: center;
    padding: 40px;
    color: #888;
}

.client-info-error {
    background: #f8d7da;
    color: #721c24;
    padding: 12px;
    border-radius: 6px;
    border: 1px solid #f5c6cb;
}

/* Template Responses Styles */
.templates-container {
    display: flex;
    gap: 0;
    height: calc(100vh - 120px);
}

.templates-sidebar {
    width: 300px;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
}

.templates-sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.templates-sidebar-header h3 {
    margin: 0;
    font-size: 18px;
}

.templates-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.template-item {
    padding: 12px;
    margin-bottom: 8px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.template-item:hover {
    background: #f5f5f5;
    border-color: #4CAF50;
}

.template-item.active {
    background: #e8f5e9;
    border-color: #4CAF50;
}

.template-item-name {
    font-weight: 600;
    margin-bottom: 4px;
    color: #333;
}

.template-item-preview {
    font-size: 13px;
    color: #666;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.templates-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

.templates-editor-header {
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.templates-editor-header h3 {
    margin: 0;
    font-size: 18px;
}

.templates-editor-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.template-form {
    max-width: 800px;
}

.template-form-group {
    margin-bottom: 20px;
}

.template-form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #333;
}

.template-form-group input,
.template-form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
}

.template-form-group textarea {
    min-height: 200px;
    resize: vertical;
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-danger {
    background: #f44336;
}

.btn-danger:hover {
    background: #d32f2f;
}

#template-editor-actions {
    display: flex;
    gap: 10px;
}

/* Template dropdown in message input */
.message-input {
    position: relative;
}

.message-input-controls {
    position: absolute;
    top: 10px;
    right: 80px;
    z-index: 10;
    display: flex;
    gap: 6px;
    align-items: center;
}

.btn-insert-template {
    background: white;
    border: 1px solid #ddd;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
    position: relative;
}

.btn-insert-template:hover {
    background: #f5f5f5;
    border-color: #4CAF50;
}

.templates-dropdown {
    position: fixed;
    width: 320px;
    max-height: 400px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1001;
    display: flex;
    flex-direction: column;
}

.template-search {
    padding: 10px;
    border: none;
    border-bottom: 1px solid #e0e0e0;
    font-size: 14px;
}

.template-search:focus {
    outline: none;
    border-bottom-color: #4CAF50;
}

.templates-dropdown-list {
    flex: 1;
    overflow-y: auto;
    max-height: 350px;
}

.template-dropdown-item {
    padding: 12px;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background 0.2s;
    user-select: none;
    -webkit-user-select: none;
    pointer-events: auto;
}

.template-dropdown-item:last-child {
    border-bottom: none;
}

.template-dropdown-item:hover {
    background: #e8f5e9;
}

.template-dropdown-item:active {
    background: #c8e6c9;
}

.template-dropdown-item strong {
    color: #1b5e20;
    font-weight: 600;
}

