/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Body Styles - Default (agents, companies, clients) */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    min-height: 100vh;
    padding: 20px;
}

/* Body Styles - Dashboard Variant */
body.dashboard {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f5f5f5;
    padding: 0;
}

/* Body Styles - Index Variant */
body.index {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Body Styles - Companies Variant */
body.companies {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* Body Styles - Clients Variant */
body.clients {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
}

/* Body Styles - Agents Variant */
body.agents {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

/* Container */
.container {
    max-width: 1400px;
    margin: 0 auto;
}

.container.dashboard {
    padding: 40px 24px;
}

/* Loading Container (index.html) */
.loading-container {
    text-align: center;
    color: white;
}

/* Navbar (Dashboard) */
.navbar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar h1 {
    font-size: 24px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.superuser-badge {
    display: inline-block;
    background: #ffc107;
    color: #333;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
}

.logout-btn {
    padding: 8px 16px;
    background: rgba(255,255,255,0.2);
    border: 1px solid rgba(255,255,255,0.3);
    color: white;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
}

.logout-btn:hover {
    background: rgba(255,255,255,0.3);
}

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: white;
    padding: 20px 30px;
    border-radius: 15px;
    margin-bottom: 20px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

.header h1 {
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Card (Dashboard) */
.card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    margin-bottom: 24px;
}

.card h2 {
    color: #333;
    margin-bottom: 16px;
    font-size: 20px;
}

.company-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.info-item {
    padding: 12px;
    background: #f8f9fa;
    border-radius: 8px;
}

.info-item label {
    display: block;
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
    font-weight: 600;
}

.info-item value {
    font-size: 16px;
    color: #333;
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s;
    text-decoration: none;
    display: inline-block;
    font-weight: 600;
}

.btn:hover {
    transform: translateY(-2px);
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover {
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

body.agents .btn-primary {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
}

body.agents .btn-primary:hover {
    box-shadow: 0 4px 12px rgba(240, 147, 251, 0.4);
}

.btn-primary.companies {
    background: #667eea;
}

.btn-primary.companies:hover {
    background: #5568d3;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.btn-primary.clients {
    background: #4facfe;
}

.btn-primary.clients:hover {
    background: #3d9aed;
    box-shadow: 0 4px 12px rgba(79, 172, 254, 0.4);
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    box-shadow: 0 4px 12px rgba(108, 117, 125, 0.4);
}

.btn-success {
    background: #28a745;
    color: white;
}

.btn-success:hover {
    background: #218838;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.4);
}

.btn-warning {
    background: #ffc107;
    color: #333;
}

.btn-warning:hover {
    background: #e0a800;
    box-shadow: 0 4px 12px rgba(255, 193, 7, 0.4);
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.4);
}

.btn-small {
    padding: 5px 10px;
    font-size: 12px;
    margin: 0 3px;
}

.btn-icon {
    background: none;
    border: 1px solid #ddd;
    padding: 8px 15px;
    border-radius: 8px;
    cursor: pointer;
    color: #666;
    font-size: 14px;
    transition: all 0.3s;
}

.btn-icon:hover {
    background: #f8f9fa;
    border-color: #f093fb;
    color: #f093fb;
}

.btn-reset {
    background: #6c757d;
    color: white;
}

.btn-reset:hover {
    background: #5a6268;
}

.btn-version {
    padding: 4px 10px;
    font-size: 11px;
}

.clear-chat-btn {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.5);
    color: white;
    padding: 5px 10px;
    border-radius: 5px;
    font-size: 12px;
    cursor: pointer;
}

.clear-chat-btn:hover {
    background: rgba(255,255,255,0.2);
}

/* Content */
.content {
    background: white;
    border-radius: 15px;
    padding: 30px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
}

/* Form Section */
.form-section {
    display: none;
    margin-bottom: 30px;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 10px;
}

.form-section.active {
    display: block;
}

.form-section.active.with-chat {
    display: grid;
    grid-template-columns: 1fr 450px;
    gap: 20px;
}

.form-content {
    min-width: 0;
}

/* Form Group */
.form-group {
    margin-bottom: 20px;
}

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

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

.form-group textarea {
    resize: vertical;
    min-height: 150px;
    font-family: 'Courier New', monospace;
}

.form-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

/* Table */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

table th,
table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #ddd;
}

table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
}

table tr:hover {
    background: #f8f9fa;
}

.actions {
    display: flex;
    gap: 5px;
}

/* Responsive Table Component - Base Styles */
.responsive-table,
.companies-table,
.agents-table,
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 16px;
}

.responsive-table th,
.responsive-table td,
.companies-table th,
.companies-table td,
.agents-table th,
.agents-table td,
table th,
table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

.responsive-table th,
.companies-table th,
.agents-table th,
table th {
    background: #f8f9fa;
    font-weight: 600;
    color: #333;
}

.responsive-table tr:hover,
.companies-table tr:hover,
.agents-table tr:hover,
table tbody tr:hover {
    background: #f8f9fa;
}

/* Alert */
.alert {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    display: none;
}

.alert.show {
    display: block;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

/* Loading */
.loading {
    text-align: center;
    padding: 20px;
    display: none;
}

.loading.show {
    display: block;
}

.loading.dashboard {
    padding: 40px;
    color: #666;
}

.empty-state {
    text-align: center;
    padding: 40px;
    color: #6c757d;
}

/* Spinner */
.spinner {
    width: 50px;
    height: 50px;
    margin: 0 auto 20px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner.dashboard {
    width: 40px;
    height: 40px;
    margin: 0 auto 16px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Tool Selector */
.tool-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 10px;
    margin-top: 10px;
}

.tool-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 5px;
    min-height: 44px;
    overflow: hidden;
}

.tool-item input[type="checkbox"] {
    width: auto;
    flex-shrink: 0;
    margin-top: 3px;
}

.tool-item label {
    flex: 1;
    word-break: break-word;
    overflow-wrap: break-word;
    line-height: 1.4;
    font-size: 13px;
    font-weight: 500;
    color: #333;
    cursor: pointer;
}

.tool-item:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
}

.tool-selector-specific .tool-item:hover {
    background: #fff9e6;
    border-color: #ff9800;
}

/* Chat Test Panel */
.chat-test-panel {
    background: white;
    border-radius: 10px;
    border: 2px solid #f093fb;
    display: flex;
    flex-direction: column;
    height: 800px;
    position: sticky;
    top: 20px;
}

.chat-header {
    padding: 15px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    border-radius: 8px 8px 0 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    margin: 0;
    font-size: 16px;
}

.chat-status {
    font-size: 12px;
    opacity: 0.9;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.chat-message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.chat-message.user {
    align-items: flex-end;
}

.chat-message.agent {
    align-items: flex-start;
}

.message-bubble {
    max-width: 80%;
    padding: 10px 15px;
    border-radius: 15px;
    word-wrap: break-word;
    line-height: 1.4;
    white-space: pre-wrap;
}

.chat-message.user .message-bubble {
    background: #f093fb;
    color: white;
    border-bottom-right-radius: 5px;
}

.chat-message.agent .message-bubble {
    background: white;
    color: #333;
    border: 1px solid #ddd;
    border-bottom-left-radius: 5px;
}

.message-time {
    font-size: 11px;
    color: #6c757d;
    margin-top: 5px;
    padding: 0 5px;
}

.chat-input-area {
    padding: 15px;
    background: white;
    border-top: 1px solid #ddd;
    border-radius: 0 0 8px 8px;
}

.chat-input-wrapper {
    display: flex;
    gap: 10px;
}

.chat-input-wrapper input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 20px;
    font-size: 14px;
}

.chat-input-wrapper button {
    padding: 10px 20px;
    border: none;
    border-radius: 20px;
    background: #f093fb;
    color: white;
    cursor: pointer;
    transition: all 0.3s;
}

.chat-input-wrapper button:hover {
    background: #e081ea;
}

.chat-input-wrapper button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.chat-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #6c757d;
    text-align: center;
    padding: 20px;
}

.chat-empty-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

.typing-indicator {
    display: none;
    align-items: center;
    gap: 5px;
    padding: 10px 15px;
}

.typing-indicator.show {
    display: flex;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #6c757d;
    animation: typing 1.4s infinite;
}

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

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

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Message Attachments */
.message-attachment {
    margin-top: 10px;
    border-radius: 10px;
    overflow: hidden;
    max-width: 100%;
}

.attachment-image {
    max-width: 100%;
    max-height: 300px;
    display: block;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s;
}

.attachment-image:hover {
    transform: scale(1.02);
}

.attachment-video {
    max-width: 100%;
    max-height: 300px;
    border-radius: 8px;
}

.attachment-audio {
    width: 100%;
    max-width: 300px;
}

.attachment-document {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 8px;
    text-decoration: none;
    color: #333;
    transition: all 0.3s;
}

.attachment-document:hover {
    background: #e9ecef;
    border-color: #f093fb;
}

.attachment-icon {
    font-size: 24px;
    color: #f093fb;
}

.attachment-info {
    flex: 1;
}

.attachment-name {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 3px;
}

.attachment-type {
    font-size: 12px;
    color: #6c757d;
    text-transform: uppercase;
}

.attachment-caption {
    margin-top: 8px;
    font-size: 13px;
    color: #666;
    font-style: italic;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    background: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 300px;
    animation: slideIn 0.3s ease-out;
    border-left: 4px solid #28a745;
}

.toast.error {
    border-left-color: #dc3545;
}

.toast.warning {
    border-left-color: #ffc107;
}

.toast.info {
    border-left-color: #17a2b8;
}

.toast-icon {
    font-size: 20px;
}

.toast-message {
    flex: 1;
    color: #333;
    font-size: 14px;
}

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

@keyframes slideOut {
    from {
        transform: translateX(0);
        opacity: 1;
    }
    to {
        transform: translateX(400px);
        opacity: 0;
    }
}

.toast.removing {
    animation: slideOut 0.3s ease-out forwards;
}

.auto-save-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: #6c757d;
    margin-left: 10px;
}

.auto-save-indicator.saving {
    color: #f093fb;
}

.auto-save-indicator.saved {
    color: #28a745;
}

/* Context Editor */
.context-editor {
    background: white;
    border-top: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
    margin-bottom: 10px;
}

.context-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #f8f9fa;
    cursor: pointer;
    user-select: none;
}

.context-editor.expanded .context-header {
    border-bottom: 1px solid #ddd;
}

.context-header:hover {
    background: #e9ecef;
}

.context-header h4 {
    margin: 0;
    font-size: 13px;
    color: #333;
    display: flex;
    align-items: center;
    gap: 8px;
}

.context-toggle {
    font-size: 16px;
    transition: transform 0.3s;
}

.context-toggle.expanded {
    transform: rotate(180deg);
}

.context-content {
    padding: 0;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, padding 0.3s ease;
}

.context-editor.expanded .context-content {
    padding: 15px;
    max-height: 300px;
    overflow-y: auto;
}

.context-textarea {
    width: 100%;
    min-height: 220px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    font-size: 12px;
    resize: vertical;
    background: #f8f9fa;
}

.context-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
}

.context-actions small {
    color: #6c757d;
    font-size: 11px;
}

.context-actions button {
    padding: 5px 12px;
    font-size: 11px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s;
}

.json-valid {
    color: #28a745;
}

.json-invalid {
    color: #dc3545;
}

/* Media Section */
.media-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 12px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 8px;
    margin-bottom: 10px;
    transition: all 0.3s;
}

.media-item:hover {
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    border-color: #f093fb;
}

.media-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 6px;
    object-fit: cover;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
}

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

.media-title {
    font-weight: 600;
    color: #333;
    margin-bottom: 3px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.media-type-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 600;
    border-radius: 12px;
    text-transform: uppercase;
}

.media-type-image { background: #e3f2fd; color: #1976d2; }
.media-type-video { background: #f3e5f5; color: #7b1fa2; }
.media-type-audio { background: #fff3e0; color: #f57c00; }
.media-type-document { background: #e8f5e9; color: #388e3c; }

.media-description {
    font-size: 12px;
    color: #666;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.media-tags {
    display: flex;
    gap: 5px;
    flex-wrap: wrap;
    margin-top: 5px;
}

.media-tag {
    background: #f093fb;
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 500;
}

.media-meta {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

.media-actions {
    display: flex;
    gap: 5px;
    flex-shrink: 0;
}

.media-url {
    font-size: 11px;
    color: #6c757d;
    background: #f8f9fa;
    padding: 4px 8px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    cursor: pointer;
    display: inline-block;
    margin-top: 4px;
}

.media-url:hover {
    background: #e9ecef;
    color: #333;
}

.upload-progress {
    margin-top: 10px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 5px;
    border-left: 3px solid #f093fb;
    display: none;
}

.upload-progress.show {
    display: block;
}

/* Modal de Versionamento */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.show {
    display: flex;
}

.modal {
    background: white;
    border-radius: 15px;
    padding: 30px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: modalSlideIn 0.3s ease-out;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 2px solid #f093fb;
}

.modal-header h2 {
    margin: 0;
    color: #333;
    font-size: 24px;
}

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

.modal-close:hover {
    background: #f8f9fa;
    color: #333;
}

.version-history {
    margin-top: 20px;
    max-height: 300px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 8px;
}

.version-item {
    padding: 15px;
    border-bottom: 1px solid #f0f0f0;
    transition: background 0.3s;
    cursor: pointer;
}

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

.version-item:hover {
    background: #f8f9fa;
}

.version-item.current {
    background: #e8f5e9;
    border-left: 4px solid #28a745;
}

.version-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.version-name {
    font-weight: 600;
    color: #333;
    font-size: 15px;
}

.version-badge {
    background: #f093fb;
    color: white;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
}

.version-badge.current-badge {
    background: #28a745;
}

.version-date {
    font-size: 12px;
    color: #6c757d;
    margin-bottom: 5px;
}

.version-description {
    font-size: 13px;
    color: #666;
    line-height: 1.4;
}

.version-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

/* Config Variables */
.config-vars-container {
    background: #fff;
    padding: 15px;
    border-radius: 5px;
    border: 1px solid #ddd;
}

.config-var-item {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

.config-var-item input {
    flex: 1;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 3px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
}

.badge-success {
    background: #d4edda;
    color: #155724;
}

.badge-secondary {
    background: #e2e3e5;
    color: #383d41;
}

/* Utility Classes */
small {
    display: block;
    margin-top: 5px;
    color: #6c757d;
}

.hidden-for-admin {
    display: none !important;
}

/* Responsive */
@media (max-width: 1200px) {
    .form-section.active.with-chat {
        grid-template-columns: 1fr;
    }

    .chat-test-panel {
        position: static;
        height: 500px;
    }
}

/* Mobile Responsiveness for Tables */
@media (max-width: 768px) {
    /* Dashboard container padding */
    .container.dashboard {
        padding: 20px 12px;
    }

    /* Card padding */
    .card {
        padding: 16px;
    }

    /* Navbar responsive */
    .navbar {
        flex-direction: column;
        gap: 12px;
        padding: 12px;
    }

    .navbar h1 {
        font-size: 20px;
    }

    .user-info {
        flex-direction: column;
        gap: 8px;
        font-size: 14px;
        text-align: center;
        width: 100%;
    }

    /* Hide table headers and make rows display as cards */
    .responsive-table thead,
    .companies-table thead,
    .agents-table thead,
    table thead {
        display: none;
    }

    .responsive-table,
    .companies-table,
    .agents-table,
    table {
        border: 0;
    }

    .responsive-table tbody,
    .companies-table tbody,
    .agents-table tbody,
    table tbody {
        display: block;
    }

    .responsive-table tr,
    .companies-table tr,
    .agents-table tr,
    table tbody tr {
        display: block;
        margin-bottom: 16px;
        border: 1px solid #e0e0e0;
        border-radius: 8px;
        padding: 12px;
        background: white;
    }

    .responsive-table tr:hover,
    .companies-table tr:hover,
    .agents-table tr:hover,
    table tbody tr:hover {
        background: white;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    }

    .responsive-table td,
    .companies-table td,
    .agents-table td,
    table td {
        display: block;
        text-align: right;
        padding: 8px 0;
        border-bottom: 1px solid #f0f0f0;
        position: relative;
        padding-left: 50%;
    }

    .responsive-table td:last-child,
    .companies-table td:last-child,
    .agents-table td:last-child,
    table td:last-child {
        border-bottom: 0;
    }

    .responsive-table td:before,
    .companies-table td:before,
    .agents-table td:before,
    table td:before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 45%;
        padding-right: 10px;
        text-align: left;
        font-weight: 600;
        color: #666;
    }

    /* Buttons in mobile */
    .responsive-table td button,
    .companies-table td button,
    .agents-table td button,
    table td button {
        width: 100%;
        margin-bottom: 8px;
        margin-right: 0 !important;
        display: block;
    }

    .responsive-table td button:last-child,
    .companies-table td button:last-child,
    .agents-table td button:last-child,
    table td button:last-child {
        margin-bottom: 0;
    }

    /* Células de ações em mobile */
    .responsive-table td.actions,
    .companies-table td.actions,
    .agents-table td.actions,
    table td.actions {
        display: flex;
        flex-direction: column;
        gap: 8px;
        padding-left: 0;
    }

    .responsive-table td.actions:before,
    .companies-table td.actions:before,
    .agents-table td.actions:before,
    table td.actions:before {
        position: static;
        width: 100%;
        margin-bottom: 8px;
    }

    /* Info items in dashboard */
    .company-info .info-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }

    .company-info .info-item label {
        font-size: 12px;
    }

    .company-info .info-item value {
        font-size: 14px;
    }

    /* Buttons responsive */
    .btn {
        font-size: 14px;
        padding: 10px 16px;
    }

    #myCompanyActions {
        flex-direction: column;
        gap: 8px !important;
    }

    #myCompanyActions button {
        width: 100%;
    }

    /* Agents header responsive */
    .agents-header {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px;
    }

    .agents-header h2 {
        font-size: 18px;
        margin-bottom: 0;
    }

    .agents-header button {
        width: 100%;
    }

    /* Company info grid mobile */
    .company-info {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    /* Card titles */
    .card h2 {
        font-size: 18px;
        margin-bottom: 12px;
    }

    /* Connection actions mobile */
    .connection-actions {
        flex-direction: column;
    }

    .connection-actions button {
        flex: 1 1 100%;
        width: 100%;
        min-width: auto;
    }

    /* Card grid mobile */
    .card-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* Header mobile */
    .header {
        flex-direction: column;
        align-items: stretch;
        gap: 16px;
        padding: 16px;
    }

    .header h1 {
        font-size: 20px;
    }

    .header > div {
        width: 100%;
    }

    .header > div:last-child {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .header .btn {
        width: 100%;
        text-align: center;
    }

    /* Form section mobile */
    .form-section {
        padding: 16px;
        margin-bottom: 16px;
    }

    .form-section h2 {
        font-size: 18px;
    }

    /* Form groups mobile */
    .form-group {
        margin-bottom: 16px;
    }

    .form-group label {
        font-size: 14px;
    }

    .form-group input,
    .form-group textarea,
    .form-group select {
        font-size: 16px; /* Evita zoom no iOS */
        padding: 12px;
    }

    .form-group textarea {
        min-height: 120px;
    }

    .form-group small {
        font-size: 12px;
    }

    /* Form actions mobile */
    .form-actions {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .form-actions button {
        width: 100%;
    }

    /* Content area mobile */
    .content {
        padding: 0;
    }

    #companiesTable,
    #agentsTable,
    #clientsTable {
        padding: 16px;
    }

    #companiesTable h2,
    #agentsTable h2,
    #clientsTable h2 {
        font-size: 18px;
        margin-bottom: 12px;
    }
}

/* Card Grid Styles - For WhatsApp connections and similar views */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.card-grid .connection-card,
.card-grid .card {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 1.5rem;
    background: white;
    transition: transform 0.2s, box-shadow 0.2s;
}

.card-grid .connection-card:hover,
.card-grid .card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.connection-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 1rem;
}

.connection-name {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2c3e50;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

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

.status-disconnected {
    background: #f8d7da;
    color: #721c24;
}

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

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

.connection-info {
    margin: 1rem 0;
}

.connection-info p {
    margin: 0.5rem 0;
    color: #7f8c8d;
    font-size: 0.9rem;
}

.connection-info strong {
    color: #2c3e50;
}

.qrcode-container {
    text-align: center;
    margin: 1rem 0;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 4px;
}

.qrcode-container img {
    max-width: 100%;
    height: auto;
    border-radius: 4px;
}

.connection-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 1rem;
}

.connection-actions button {
    flex: 1 1 calc(50% - 0.25rem);
    min-width: 120px;
    padding: 0.5rem 0.75rem;
    font-size: 0.85rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Header Actions */
.header-actions {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

/* Toast Styles */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    color: white;
    font-weight: 500;
    min-width: 300px;
    opacity: 0;
    transform: translateX(400px);
    transition: all 0.3s ease;
}

.toast.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-success {
    background: #28a745;
}

.toast-error {
    background: #dc3545;
}

.toast-info {
    background: #17a2b8;
}

.toast-warning {
    background: #ffc107;
    color: #333;
}

/* Modal Styles */
.modal-overlay {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.4);
    align-items: center;
    justify-content: center;
}

.modal-overlay.show {
    display: flex;
}

.modal-content {
    background-color: #fefefe;
    margin: auto;
    padding: 2rem;
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

.modal-header {
    margin-bottom: 1.5rem;
}

.modal-header h2 {
    margin: 0;
    color: #2c3e50;
}

.modal-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1.5rem;
    flex-wrap: wrap;
}

.modal-actions button {
    flex: 1 1 auto;
    min-width: 120px;
}

/* Toggle Switch Styles */
.toggle-switch {
    position: relative;
    display: inline-block;
    width: 56px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 28px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 20px;
    width: 20px;
    left: 4px;
    bottom: 4px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

.toggle-switch input:checked + .toggle-slider {
    background-color: #10b981;
}

.toggle-switch input:checked + .toggle-slider:before {
    transform: translateX(28px);
}

.toggle-switch input:disabled + .toggle-slider {
    opacity: 0.5;
    cursor: not-allowed;
}
