/**
 * WhatsApp CRM - Estilos Premium
 */

:root {
    /* Cores principais */
    --primary: #25D366;
    --primary-dark: #128C7E;
    --primary-light: #34EE7F;
    --primary-hover: #1FA855;

    /* Background */
    --bg-dark: #0a0f1a;
    --bg-darker: #060a12;
    --bg-card: #111827;
    --bg-card-hover: #1a2234;
    --bg-input: #0d1117;

    /* Borders */
    --border: #1f2937;
    --border-light: #374151;

    /* Text */
    --text: #f9fafb;
    --text-secondary: #9ca3af;
    --text-muted: #6b7280;

    /* Status */
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;

    /* Chat */
    --chat-sent: #075e54;
    --chat-received: #1f2937;

    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
    --shadow-primary: 0 4px 20px rgba(37, 211, 102, 0.25);

    /* Spacing */
    --sidebar-width: 260px;
    --list-width: 360px;
    --profile-width: 320px;

    /* Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition: 0.2s ease;
    --transition-slow: 0.3s ease;
}

/* ============================================
   RESET & BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    line-height: 1.6;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-light);
}

/* ============================================
   UTILITIES
   ============================================ */
.hidden {
    display: none !important;
}

.text-muted {
    color: var(--text-muted);
}

.text-secondary {
    color: var(--text-secondary);
}

.text-success {
    color: var(--success);
}

.text-warning {
    color: var(--warning);
}

.text-danger {
    color: var(--danger);
}

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: var(--shadow-primary);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(37, 211, 102, 0.35);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-outline:hover:not(:disabled) {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(37, 211, 102, 0.1);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 12px;
}

.btn-ghost:hover:not(:disabled) {
    background: var(--bg-card-hover);
    color: var(--text);
}

.btn-danger {
    background: linear-gradient(135deg, var(--danger), #dc2626);
    color: #fff;
}

.btn-sm {
    padding: 6px 14px;
    font-size: 13px;
    border-radius: var(--radius-sm);
}

.btn-block {
    width: 100%;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.btn-icon:hover {
    background: var(--bg-card-hover);
    color: var(--text);
}

/* ============================================
   FORMS
   ============================================ */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.15);
}

.form-control::placeholder {
    color: var(--text-muted);
}

textarea.form-control {
    resize: vertical;
    min-height: 100px;
    line-height: 1.5;
}

.input-icon {
    position: relative;
}

.input-icon i {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 18px;
    pointer-events: none;
}

.input-icon input {
    padding-left: 44px;
}

.input-group {
    display: flex;
    gap: 8px;
}

.input-group .form-control {
    flex: 1;
}

/* ============================================
   ALERTS
   ============================================ */
.alert {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
}

.alert-error {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid var(--danger);
    color: var(--danger);
}

.alert-success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid var(--success);
    color: var(--success);
}

/* ============================================
   LOGIN PAGE
   ============================================ */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg-darker) 0%, var(--bg-dark) 50%, #0d1526 100%);
    padding: 20px;
}

.login-card {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 48px;
    box-shadow: var(--shadow-lg);
}

.login-header {
    text-align: center;
    margin-bottom: 36px;
}

.login-logo {
    width: 72px;
    height: 72px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 20px;
    box-shadow: var(--shadow-primary);
}

.login-logo i {
    font-size: 36px;
    color: #fff;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-muted);
    font-size: 14px;
}

.login-footer {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
}

.login-footer code {
    background: var(--bg-input);
    padding: 2px 8px;
    border-radius: 4px;
    font-family: monospace;
    color: var(--primary);
}

/* ============================================
   APP LAYOUT
   ============================================ */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo i {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    color: #fff;
}

.logo span {
    font-size: 18px;
    font-weight: 700;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 12px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 4px;
    cursor: pointer;
}

.nav-item:hover {
    background: var(--bg-card-hover);
    color: var(--text);
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(37, 211, 102, 0.15), rgba(37, 211, 102, 0.05));
    color: var(--primary);
    border: 1px solid rgba(37, 211, 102, 0.25);
}

.nav-item i {
    font-size: 20px;
}

.nav-item .badge {
    margin-left: auto;
    background: var(--primary);
    color: #000;
    padding: 2px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, var(--info), #2563eb);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    font-weight: 600;
    font-size: 14px;
}

.user-role {
    font-size: 12px;
    color: var(--text-muted);
}

.btn-logout {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: var(--transition);
    text-decoration: none;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    flex: 1;
    overflow: hidden;
    background: var(--bg-dark);
}

.page {
    display: none;
    height: 100%;
}

.page.active {
    display: flex;
    flex-direction: column;
}

.page-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-card);
}

.page-header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
}

.page-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

/* ============================================
   CONVERSATIONS LAYOUT
   ============================================ */
.conversations-layout {
    display: flex;
    height: 100%;
    overflow: hidden;
}

/* Lista de conversas */
.conversations-list {
    width: var(--list-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.list-header {
    padding: 20px;
    border-bottom: 1px solid var(--border);
}

.list-header h2 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 16px;
}

.list-actions {
    display: flex;
    gap: 8px;
}

.search-box {
    flex: 1;
    position: relative;
}

.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 16px;
}

.search-box input {
    width: 100%;
    padding: 10px 12px 10px 40px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: 13px;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
}

.filter-dropdown {
    position: relative;
}

.tag-filter-dropdown {
    display: none;
}

.tag-filter-dropdown.active {
    display: block;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 8px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 150px;
    display: none;
    z-index: 100;
}

.dropdown-menu.active {
    display: block;
}

.dropdown-menu a {
    display: block;
    padding: 10px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: var(--transition);
}

.dropdown-menu a:hover {
    background: var(--bg-card-hover);
    color: var(--text);
}

.list-tabs {
    display: flex;
    padding: 0 8px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-darker);
    overflow-x: auto;
}

.tab {
    padding: 10px 10px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-muted);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

.tab:hover {
    color: var(--text-secondary);
}

.tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
}

.tab .count {
    background: var(--bg-card);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
}

.conversations-items {
    flex: 1;
    overflow-y: auto;
}

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-muted);
    text-align: center;
    padding: 40px;
}

.empty-state i {
    font-size: 64px;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* Conversation Item */
.conversation-item {
    display: flex;
    gap: 12px;
    padding: 16px;
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: var(--transition);
}

.conversation-item:hover {
    background: var(--bg-card-hover);
}

.conversation-item.active {
    background: rgba(37, 211, 102, 0.1);
    border-left: 3px solid var(--primary);
}

.conv-avatar {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    flex-shrink: 0;
}

.conv-content {
    flex: 1;
    min-width: 0;
}

.conv-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.conv-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-time {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.conv-preview {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 6px;
}

.conv-meta {
    display: flex;
    align-items: center;
    gap: 8px;
}

.conv-tag {
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
}

.conv-tag.active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.conv-unread {
    width: 20px;
    height: 20px;
    background: var(--primary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: #000;
    margin-left: auto;
}

/* ============================================
   CHAT AREA
   ============================================ */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-darker);
    min-width: 0;
}

.chat-placeholder {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
}

.chat-placeholder i {
    font-size: 80px;
    margin-bottom: 20px;
    opacity: 0.3;
}

.chat-placeholder h3 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.chat-header {
    padding: 16px 20px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-contact {
    display: flex;
    align-items: center;
    gap: 12px;
}

.contact-avatar {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 600;
    color: #fff;
}

.contact-info h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.contact-info span {
    font-size: 13px;
    color: var(--text-muted);
}

.chat-actions {
    display: flex;
    gap: 4px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Message Bubbles */
.message {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    position: relative;
}

.message.received {
    background: var(--chat-received);
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.message.sent {
    background: var(--chat-sent);
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.message-content {
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.message-meta {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin-top: 6px;
}

.message-time {
    font-size: 11px;
    color: var(--text-muted);
}

.message-status i {
    font-size: 14px;
    color: var(--text-muted);
}

.message-status.read i {
    color: var(--info);
}

.message-ai-badge {
    font-size: 10px;
    background: rgba(168, 85, 247, 0.2);
    color: #a855f7;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

/* Reply button on messages */
.msg-reply-btn {
    position: absolute;
    top: 6px;
    right: -32px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 50%;
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: var(--text-muted);
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s;
}

.message.received .msg-reply-btn {
    right: auto;
    left: -32px;
}

.message:hover .msg-reply-btn {
    opacity: 1;
}

.msg-reply-btn:hover {
    color: var(--primary);
    border-color: var(--primary);
}

/* Reaction pop-in animation */
@keyframes popIn {
    0% {
        transform: scale(0);
        opacity: 0;
    }

    70% {
        transform: scale(1.3);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Date Separator */
.date-separator {
    text-align: center;
    margin: 20px 0;
}

.date-separator span {
    background: var(--bg-card);
    padding: 6px 16px;
    border-radius: 20px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Chat Input */
.chat-input {
    padding: 16px 20px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.input-actions {
    display: flex;
    gap: 4px;
}

.input-wrapper {
    flex: 1;
}

.input-wrapper textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    color: var(--text);
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 150px;
    line-height: 1.5;
}

.input-wrapper textarea:focus {
    outline: none;
    border-color: var(--primary);
}

.btn-send {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-send:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-primary);
}

/* ============================================
   PROFILE SIDEBAR
   ============================================ */
.profile-sidebar {
    width: var(--profile-width);
    background: var(--bg-card);
    border-left: 1px solid var(--border);
    overflow-y: auto;
    flex-shrink: 0;
}

.profile-header {
    padding: 24px;
    text-align: center;
    border-bottom: 1px solid var(--border);
}

.profile-avatar {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    font-weight: 600;
    color: #fff;
    margin: 0 auto 16px;
}

.profile-header h3 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 4px;
}

.profile-header span {
    font-size: 13px;
    color: var(--text-muted);
    display: block;
    margin-bottom: 16px;
}

.profile-section {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
}

.profile-section h4 {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 16px;
}

.profile-field {
    margin-bottom: 12px;
}

.profile-field label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

.profile-field span {
    font-size: 14px;
    color: var(--text);
}

/* Subscription card */
.subscription-card {
    background: var(--bg-input);
    border-radius: var(--radius-md);
    padding: 12px;
    margin-bottom: 12px;
}

.sub-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.sub-name {
    font-weight: 600;
    font-size: 14px;
}

.sub-status {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 600;
}

.sub-status.active {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.sub-status.expired {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.sub-details {
    font-size: 12px;
    color: var(--text-muted);
}

.sub-details p {
    margin-bottom: 4px;
}

.tags-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag {
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 500;
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
}

.btn-add-tag {
    font-size: 12px;
    padding: 4px 12px;
    border-radius: 20px;
    background: transparent;
    border: 1px dashed var(--border);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
    transition: var(--transition);
}

.btn-add-tag:hover {
    border-color: var(--primary);
    color: var(--primary);
}

/* ============================================
   AGENTS GRID
   ============================================ */
.agents-grid,
.attendants-grid,
.departments-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
    padding: 24px 32px;
    overflow-y: auto;
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    transition: var(--transition);
}

.card:hover {
    border-color: var(--border-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
}

.card-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 600;
    color: #fff;
}

.card-avatar.agent {
    background: linear-gradient(135deg, #a855f7, #7c3aed);
}

.card-avatar.attendant {
    background: linear-gradient(135deg, var(--info), #2563eb);
}

.card-avatar.department {
    background: linear-gradient(135deg, var(--warning), #d97706);
}

.card-title {
    flex: 1;
}

.card-title h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
}

.card-title span {
    font-size: 12px;
    color: var(--text-muted);
}

.card-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--success);
}

.card-status.inactive {
    background: var(--text-muted);
}

.card-body {
    margin-bottom: 16px;
}

.card-body p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.card-footer {
    display: flex;
    gap: 8px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

/* ============================================
   SETTINGS
   ============================================ */
.settings-container {
    max-width: 100%;
    padding: 24px 32px;
    overflow-y: auto;
}

.settings-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-bottom: 20px;
}

.settings-section h3 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 20px;
    color: var(--text);
}

.settings-section h3 i {
    color: var(--primary);
}

/* ============================================
   MODAL
   ============================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    z-index: 1000;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--bg-card-hover);
    color: var(--text);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1200px) {
    :root {
        --profile-width: 280px;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {

    /* Hide profile sidebar only on tablet, mobile has its own overlay */
    .profile-sidebar {
        display: none;
    }
}

/* Old 768px query removed - replaced by comprehensive mobile rules below */

/* ============================================
   STATUS BADGES
   ============================================ */
.chat-status {
    display: flex;
    align-items: center;
    margin-right: 8px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.status-badge.pending {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-badge.ai {
    background: rgba(99, 102, 241, 0.15);
    color: #818cf8;
    border: 1px solid rgba(99, 102, 241, 0.3);
}

.status-badge.human {
    background: rgba(59, 130, 246, 0.15);
    color: var(--info);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.status-badge.closed {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.3);
}

/* Action Buttons */
.btn-icon.btn-ai {
    color: #818cf8;
}

.btn-icon.btn-ai:hover {
    background: rgba(99, 102, 241, 0.15);
    color: #a5b4fc;
}

.btn-icon.btn-danger-icon {
    color: var(--text-secondary);
}

.btn-icon.btn-danger-icon:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--danger);
}

.message-ai-badge {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    background: rgba(99, 102, 241, 0.2);
    color: #a5b4fc;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    margin-right: 4px;
}

/* ============================================
   SHORTCUTS DROPDOWN
   ============================================ */
.shortcuts-dropdown {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-height: 200px;
    overflow-y: auto;
    z-index: 100;
}

.shortcut-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    cursor: pointer;
    transition: var(--transition);
    border-bottom: 1px solid var(--border);
}

.shortcut-item:last-child {
    border-bottom: none;
}

.shortcut-item:hover,
.shortcut-item.active {
    background: rgba(37, 211, 102, 0.1);
}

.shortcut-cmd {
    font-weight: 600;
    color: var(--primary);
    font-family: 'Fira Code', monospace;
    font-size: 13px;
    flex-shrink: 0;
}

.shortcut-title {
    color: var(--text-muted);
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ============================================
   STATS CARDS (Dashboard)
   ============================================ */
.stats-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    text-align: center;
    transition: var(--transition);
}

.stats-card:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stats-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin: 0 auto 12px;
}

.stats-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 4px;
}

.stats-label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 500;
}

/* ============================================
   AGENT CARD (reusable for lists)
   ============================================ */
.agent-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.agent-card:hover {
    border-color: var(--border-light);
    background: var(--bg-card-hover);
}

/* ============================================
   SPIN ANIMATION
   ============================================ */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

/* ============================================
   DASHBOARD PAGE - wider container
   ============================================ */
#page-dashboard .settings-container,
#page-history .settings-container,
#page-chatbot .settings-container,
#page-shortcuts .settings-container,
#page-tags .settings-container {
    max-width: 100%;
}

/* ============================================
   MULTI-COLUMN LAYOUT
   Seções fluem naturalmente em 2 colunas
   sem forçar alinhamento horizontal
   ============================================ */
#page-settings .settings-container form,
#page-templates .settings-container form,
#page-send .settings-container {
    columns: 2;
    column-gap: 20px;
}

#page-settings .settings-container form .settings-section,
#page-templates .settings-container form .settings-section,
#page-send .settings-container .settings-section {
    break-inside: avoid;
    margin-bottom: 20px;
}

#page-settings .settings-container form>button[type="submit"],
#page-templates .settings-container form>button[type="submit"] {
    break-inside: avoid;
    column-span: all;
}

#page-send .settings-container>.alert {
    column-span: all;
    margin-bottom: 20px;
}

/* ============================================
   SHORTCUTS PAGE
   ============================================ */
#page-shortcuts #shortcuts-list .shortcut-item {
    margin-bottom: 0;
}

/* ============================================
   CHATBOT PAGE - fix dropdown cortado
   ============================================ */
#page-chatbot .settings-container,
#page-ai-alerts .settings-container {
    overflow: visible;
}

#page-chatbot .settings-section,
#page-ai-alerts .settings-section {
    overflow: visible;
}

.bot-actions-menu {
    position: relative;
    display: inline-block;
}

.bot-actions-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px 10px;
    border-radius: var(--radius-md);
    font-size: 18px;
    transition: var(--transition);
}

.bot-actions-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text);
}

.bot-actions-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    margin-top: 4px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    z-index: 200;
    overflow: hidden;
}

.bot-actions-dropdown button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 13px;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
}

.bot-actions-dropdown button:hover {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text);
}

.bot-actions-dropdown button.danger {
    color: var(--danger);
}

.bot-actions-dropdown button.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* ============================================
   RESPONSIVO
   ============================================ */
@media (max-width: 1100px) {

    #page-settings .settings-container form,
    #page-templates .settings-container form,
    #page-send .settings-container {
        columns: 1;
    }
}

/* Hidden utility */
.hidden {
    display: none !important;
}

/* ============================================
   TOGGLE SWITCH
   ============================================ */
.toggle-switch {
    width: 40px;
    height: 22px;
    background: var(--bg-input);
    border-radius: 11px;
    position: relative;
    cursor: pointer;
    transition: background 0.3s;
    border: 1px solid var(--border);
}

.toggle-switch.active {
    background: var(--success);
    border-color: var(--success);
}

.toggle-knob {
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    position: absolute;
    top: 2px;
    left: 3px;
    transition: transform 0.3s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.toggle-switch.active .toggle-knob {
    transform: translateX(17px);
}

/* ============================================
   CHATBOT EDITOR - Sidebar Drag Items
   ============================================ */
.node-drag-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: grab;
    transition: all 0.2s;
    user-select: none;
}

.node-drag-item:hover {
    border-color: var(--primary);
    background: rgba(37, 99, 235, 0.08);
    transform: translateY(-1px);
}

.node-drag-item:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.node-drag-item i {
    font-size: 14px;
}

/* ============================================
   DRAWFLOW CANVAS OVERRIDES
   ============================================ */
#drawflow-canvas .drawflow {
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(circle, rgba(255, 255, 255, 0.06) 1px, transparent 1px);
    background-size: 24px 24px;
}

#drawflow-canvas .drawflow .drawflow-node {
    border-radius: 12px;
    border: 1px solid var(--border);
    background: var(--bg-card);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
    min-width: 200px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
}

#drawflow-canvas .drawflow .drawflow-node.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37, 99, 235, 0.3), 0 4px 16px rgba(0, 0, 0, 0.3);
}

#drawflow-canvas .drawflow .drawflow-node .drawflow_content_node {
    padding: 0;
    width: 100%;
}

/* Node header */
.df-node-header {
    padding: 10px 14px;
    border-radius: 11px 11px 0 0;
    font-size: 12px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.df-node-body {
    padding: 12px 14px;
}

.df-node-body textarea,
.df-node-body input,
.df-node-body select {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: 13px;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    resize: vertical;
}

.df-node-body textarea:focus,
.df-node-body input:focus,
.df-node-body select:focus {
    border-color: var(--primary);
    outline: none;
}

.df-node-body label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
}

.df-node-body .field-group {
    margin-bottom: 10px;
}

.df-node-body .field-group:last-child {
    margin-bottom: 0;
}

/* Node colors by type */
.df-node-header.type-text {
    background: rgba(37, 99, 235, 0.15);
    color: #60a5fa;
}

.df-node-header.type-menu {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
}

.df-node-header.type-question {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
}

.df-node-header.type-transfer {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
}

.df-node-header.type-close {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
}

.df-node-header.type-delay {
    background: rgba(251, 191, 36, 0.15);
    color: #fbbf24;
}

.df-node-header.type-ai_response {
    background: rgba(168, 85, 247, 0.15);
    color: #c084fc;
}

/* Connection lines */
#drawflow-canvas .drawflow .connection .main-path {
    stroke: var(--primary);
    stroke-width: 2;
}

/* Input/Output ports */
#drawflow-canvas .drawflow .drawflow-node .input,
#drawflow-canvas .drawflow .drawflow-node .output {
    background: var(--primary);
    border: 2px solid var(--bg-card);
}

/* Menu options section */
.df-menu-options {
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.df-menu-option {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 6px;
    border: 1px solid var(--border);
    font-size: 12px;
}

.df-menu-option .option-num {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    flex-shrink: 0;
}

.df-menu-option input {
    flex: 1;
    border: none !important;
    background: transparent !important;
    padding: 2px 4px !important;
    font-size: 12px !important;
}

.df-add-option {
    padding: 6px;
    border: 1px dashed var(--border);
    border-radius: 6px;
    text-align: center;
    font-size: 12px;
    color: var(--text-muted);
    cursor: pointer;
    transition: all 0.2s;
}

.df-add-option:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(37, 99, 235, 0.05);
}

/* Bot list action buttons */
.bot-actions-menu {
    position: relative;
}

.bot-actions-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 6px;
    font-size: 18px;
    transition: all 0.2s;
}

.bot-actions-btn:hover {
    background: var(--bg-input);
    color: var(--text-primary);
}

.bot-actions-dropdown {
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.3);
    min-width: 150px;
    z-index: 10;
    overflow: hidden;
}

.bot-actions-dropdown button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
    transition: background 0.2s;
}

.bot-actions-dropdown button:hover {
    background: var(--bg-input);
}

.bot-actions-dropdown button.danger {
    color: var(--danger);
}

.bot-actions-dropdown button.danger:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Department badge in bot table */
.dept-badge {
    display: inline-flex;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(37, 99, 235, 0.15);
    color: #60a5fa;
}

/* ============================================
   MEDIA PREVIEW BAR (Chat)
   ============================================ */
.media-preview-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
    border: 1px solid var(--border);
    animation: slideDown 0.2s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.media-preview-content {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.media-preview-thumb {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    object-fit: cover;
    border: 1px solid var(--border);
}

.media-preview-file {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--text-secondary);
}

.media-preview-file i {
    font-size: 20px;
    color: var(--primary);
}

.media-preview-size {
    font-size: 11px;
    color: var(--text-muted);
    flex-shrink: 0;
}

/* Attach button */
.btn-attach:hover {
    color: var(--primary) !important;
    background: rgba(37, 211, 102, 0.1);
}

/* Drag over state */
.chat-messages.drag-over {
    border: 2px dashed var(--primary);
    background: rgba(37, 211, 102, 0.05);
}

/* ============================================
   SHORTCUT MEDIA BADGES
   ============================================ */
.shortcut-media-badge {
    margin-left: auto;
    font-size: 14px;
    flex-shrink: 0;
}

.sc-media-tag {
    display: inline-flex;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: rgba(37, 211, 102, 0.15);
    color: var(--primary);
}

/* ============================================
   SHORTCUT MODAL - MEDIA UPLOAD
   ============================================ */
.sc-media-upload {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.sc-media-preview {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: var(--bg-input);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.sc-media-preview img {
    max-width: 120px;
    max-height: 80px;
    border-radius: 6px;
    object-fit: cover;
}

.sc-media-preview .btn-icon {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    font-size: 14px;
    background: var(--bg-card);
    border-radius: 50%;
}

.sc-file-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    padding: 4px 8px;
}

.sc-file-badge i {
    font-size: 18px;
    color: var(--primary);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 8px 16px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-outline:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(37, 211, 102, 0.05);
}

/* ============================================
   MEDIA IN CHAT MESSAGES
   ============================================ */
.msg-media {
    margin-bottom: 4px;
}

.msg-media-image {
    cursor: pointer;
    border-radius: 8px;
    overflow: hidden;
    max-width: 280px;
}

.msg-media-image img {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
    transition: transform 0.2s ease;
}

.msg-media-image:hover img {
    transform: scale(1.02);
}

.msg-media-audio {
    padding: 12px;
    background: rgba(0, 0, 0, 0.15);
    border-radius: 12px;
    min-width: 250px;
}

.msg-media-audio audio {
    width: 100%;
    height: 36px;
    border-radius: 18px;
    outline: none;
}

.msg-media-audio audio::-webkit-media-controls-panel {
    background: rgba(255, 255, 255, 0.08);
    border-radius: 18px;
}

.msg-media-video {
    border-radius: 8px;
    overflow: hidden;
    max-width: 320px;
}

.msg-media-video video {
    width: 100%;
    height: auto;
    display: block;
    border-radius: 8px;
}

.msg-doc-link {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 13px;
    transition: background 0.2s;
}

.msg-doc-link:hover {
    background: rgba(255, 255, 255, 0.1);
}

.msg-doc-link i:first-child {
    font-size: 24px;
    color: var(--danger);
}

.msg-doc-link span {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.msg-doc-link i:last-child {
    font-size: 16px;
    color: var(--primary);
}

/* ============================================
   MEDIA LIGHTBOX
   ============================================ */
.media-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.92);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
    cursor: zoom-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.media-lightbox img {
    max-width: 90vw;
    max-height: 85vh;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    cursor: default;
}

.lightbox-toolbar {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 8px;
    z-index: 10;
}

.lightbox-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    border: none;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: background 0.2s;
    text-decoration: none;
}

.lightbox-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* K3 Modal Buttons */
.k3-cancel-btn:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    color: #fff !important;
    transform: translateY(-1px);
    transition: all 0.15s ease;
}

.k3-cancel-btn {
    transition: all 0.15s ease;
}

.k3-save-btn:hover {
    background: #16a34a !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.4);
    transition: all 0.15s ease;
}

.k3-save-btn {
    transition: all 0.15s ease;
}

/* ============================================
   MOBILE HAMBURGER BUTTON
   ============================================ */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    z-index: 998;
    align-items: center;
    padding: 0 16px;
    gap: 12px;
}

.mobile-header .logo {
    gap: 8px;
}

.mobile-header .logo i {
    width: 32px;
    height: 32px;
    font-size: 18px;
}

.mobile-header .logo span {
    font-size: 16px;
}

.btn-hamburger {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--text);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-hamburger:hover {
    background: var(--bg-card-hover);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 999;
    backdrop-filter: blur(2px);
}

.sidebar-overlay.active {
    display: block;
}

/* Mobile back button in chat header */
.btn-back-mobile {
    display: none;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--text);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    margin-right: 8px;
    flex-shrink: 0;
}

/* Profile close button - hidden on desktop */
.profile-close-btn {
    display: none;
    position: absolute;
    top: 16px;
    right: 16px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-card-hover);
    border: 1px solid var(--border);
    color: var(--text);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    z-index: 10;
}

/* Profile sidebar overlay */
.profile-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
}

.profile-overlay.active {
    display: block;
}

/* ============================================
   RESPONSIVE - MOBILE (max-width 768px)
   ============================================ */
@media (max-width: 768px) {

    /* Show mobile header */
    .mobile-header {
        display: flex;
    }

    /* App layout */
    .app-layout {
        flex-direction: column;
        padding-top: 56px;
    }

    /* === SIDEBAR === */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: none;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 25px rgba(0, 0, 0, 0.5);
    }

    /* === MAIN CONTENT === */
    .main-content {
        width: 100%;
        height: calc(100vh - 56px);
    }

    /* === PAGE HEADERS === */
    .page-header {
        padding: 16px;
        flex-wrap: wrap;
        gap: 12px;
    }

    .page-header h1 {
        font-size: 18px;
    }

    .page-header p {
        font-size: 12px;
    }

    /* === CONVERSATIONS LAYOUT === */
    .conversations-layout {
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        height: 0 !important;
        /* force flex-basis to work */
        min-height: 0 !important;
    }

    .conversations-list {
        width: 100% !important;
        flex: 1 !important;
        display: flex !important;
        flex-direction: column !important;
        min-height: 0 !important;
        border-right: none !important;
    }

    .conversations-items {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    .chat-area {
        display: none !important;
        width: 100% !important;
        flex: 1;
        min-height: 0;
    }

    /* When conversation is active on mobile */
    .conversations-layout.chat-active .conversations-list {
        display: none !important;
    }

    .conversations-layout.chat-active .chat-area {
        display: flex !important;
        flex-direction: column;
        flex: 1;
    }

    /* === PROFILE SIDEBAR (mobile overlay) === */
    .profile-sidebar {
        display: block !important;
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        left: auto !important;
        width: 85vw !important;
        max-width: 360px !important;
        z-index: 9999 !important;
        transform: translateX(100%) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        box-shadow: none !important;
        border-left: none !important;
        background: var(--bg-card) !important;
        overflow-y: auto !important;
        flex-shrink: 0 !important;
    }

    .profile-sidebar.open {
        transform: translateX(0) !important;
        box-shadow: -4px 0 25px rgba(0, 0, 0, 0.5) !important;
    }

    .profile-close-btn {
        display: flex !important;
    }

    /* Show back button */
    .btn-back-mobile {
        display: flex;
    }

    /* Contact name clickable */
    .chat-contact .contact-info {
        cursor: pointer;
    }

    .chat-contact .contact-info h3 {
        color: var(--primary);
    }

    /* === CHAT HEADER MOBILE REDESIGN (CSS Grid) === */
    .chat-header {
        display: grid !important;
        grid-template-columns: auto 1fr !important;
        grid-template-rows: auto auto auto !important;
        gap: 2px 8px !important;
        padding: 8px 12px !important;
        align-items: center !important;
    }

    /* chat-contact becomes transparent, children join the grid */
    .chat-contact {
        display: contents !important;
    }

    /* Back button: column 1, spanning all rows */
    .btn-back-mobile {
        grid-column: 1 !important;
        grid-row: 1 / 4 !important;
        align-self: center !important;
        flex-shrink: 0;
    }

    /* Hide avatar on mobile */
    .chat-contact .contact-avatar {
        display: none !important;
    }

    /* Row 1, col 2: Name */
    .chat-contact .contact-info {
        grid-column: 2 !important;
        grid-row: 1 !important;
        min-width: 0 !important;
        cursor: pointer;
    }

    .chat-contact .contact-info h3 {
        font-size: 15px !important;
        font-weight: 600 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        line-height: 1.3 !important;
    }

    /* Hide phone in contact-info, shown via JS in actions row */
    .chat-contact .contact-info span {
        display: none !important;
    }

    /* Row 2, col 2: phone (left) + buttons (right) */
    .chat-actions {
        grid-column: 2 !important;
        grid-row: 2 !important;
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
        flex-wrap: nowrap !important;
    }

    .chat-status {
        display: none !important;
    }

    .chat-actions .btn-icon {
        width: 30px !important;
        height: 30px !important;
        font-size: 15px !important;
        flex-shrink: 0 !important;
    }

    /* Row 3, col 2: applied tags */
    #header-tags {
        grid-column: 2 !important;
        grid-row: 3 !important;
    }

    .chat-messages {
        padding: 12px !important;
    }

    .message {
        max-width: 85% !important;
    }

    /* === CHAT INPUT === */
    .chat-input {
        padding: 8px 12px !important;
        gap: 6px !important;
    }

    .input-wrapper {
        flex: 1;
    }

    .input-wrapper textarea {
        padding: 10px 12px !important;
        font-size: 16px !important;
        min-height: 52px !important;
        max-height: 120px !important;
        line-height: 1.4 !important;
        overflow-y: auto !important;
        /* Prevents iOS zoom */
    }

    .btn-send {
        width: 44px !important;
        height: 44px !important;
        font-size: 20px !important;
        flex-shrink: 0 !important;
    }

    .chat-input .btn-icon {
        width: 34px !important;
        height: 34px !important;
    }

    /* === LIST HEADER === */
    .list-header {
        padding: 16px;
    }

    .list-header h2 {
        font-size: 18px;
        margin-bottom: 12px;
    }

    /* === TABS === */
    .tab {
        padding: 10px 12px;
        font-size: 12px;
    }

    /* === SETTINGS/PAGES === */
    .settings-container {
        padding: 16px !important;
    }

    .settings-section {
        padding: 16px;
        box-sizing: border-box !important;
        margin-bottom: 0 !important;
        margin-top: 0 !important;
    }

    /* Dashboard charts containment */
    #chart-hourly {
        gap: 1px !important;
        overflow-x: hidden !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    #chart-hourly>div {
        min-width: 0 !important;
    }

    #chart-split {
        width: 100% !important;
        overflow-x: hidden !important;
    }

    #chart-split>div {
        width: 100% !important;
    }

    /* Force settings-container to not overflow horizontally */
    .settings-container {
        overflow-x: hidden !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
    }

    /* === TABLES RESPONSIVE === */
    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* === GRIDS === */
    .agents-grid,
    .attendants-grid,
    .departments-grid,
    .dashboard-cards,
    .dashboard-charts {
        grid-template-columns: 1fr !important;
        padding: 0 !important;
        gap: 16px !important;
    }

    /* Unified spacing via flex column on settings containers */
    .settings-container,
    .settings-container form {
        display: flex !important;
        flex-direction: column !important;
        gap: 16px !important;
        overflow-x: hidden !important;
        max-width: 100vw !important;
        box-sizing: border-box !important;
        padding: 16px !important;
    }

    .settings-container form {
        padding: 0 !important;
    }

    .dashboard-cards {
        margin-bottom: 0 !important;
    }

    .dashboard-charts {
        margin: 0 !important;
    }

    /* Top Etiquetas */
    .settings-container>.settings-section {
        margin-top: 0 !important;
    }

    /* === SCHEDULE ROWS (Horário de Atendimento) === */
    [id^="day-row-"] {
        flex-wrap: wrap !important;
        gap: 6px !important;
        padding: 8px 10px !important;
    }

    [id^="day-row-"]>label {
        min-width: unset !important;
        font-size: 13px !important;
    }

    [id^="day-row-"]>div {
        flex: unset !important;
        width: 100% !important;
        gap: 6px !important;
    }

    [id^="day-row-"] input[type="time"] {
        max-width: none !important;
        flex: 1 !important;
        font-size: 13px !important;
    }

    [id^="day-row-"]>span[id^="day-status-"] {
        display: none !important;
    }

    /* === SHORTCUTS CARDS === */
    #shortcuts-list .agent-card {
        overflow: hidden !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    #shortcuts-list .agent-card>div:first-child {
        flex-wrap: wrap !important;
        gap: 4px !important;
    }

    #shortcuts-list .agent-card pre {
        white-space: pre-wrap !important;
        word-break: break-word !important;
        overflow-wrap: break-word !important;
        max-width: 100% !important;
    }

    /* === MODALS === */
    .modal-content,
    .k3-modal {
        width: 95% !important;
        max-width: none !important;
        margin: 10px !important;
        max-height: 90vh !important;
    }

    /* === CHAT HEADER CONTACT smaller === */
    .contact-avatar {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }

    .contact-info h3 {
        font-size: 14px;
    }

    .contact-info span {
        font-size: 11px;
    }

    /* Touch-friendly conversation items */
    .conversation-item {
        padding: 14px 16px;
    }

    /* Smaller badges */
    .status-badge {
        font-size: 11px;
        padding: 3px 8px;
    }

    /* Smaller empty states */
    .empty-state i {
        font-size: 48px;
    }

    .empty-state p {
        font-size: 13px;
    }

    .chat-placeholder i {
        font-size: 56px;
    }

    .chat-placeholder h3 {
        font-size: 16px;
    }
}

/* ============================================
   FLOW BUILDER - Drawflow Nodes
   ============================================ */

/* Node drag items in sidebar */
.node-drag-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 12px;
    font-weight: 500;
    cursor: grab;
    transition: all 0.2s;
    user-select: none;
}

.node-drag-item:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: var(--primary);
}

.node-drag-item:active {
    cursor: grabbing;
}

/* Drawflow node overrides */
.drawflow .drawflow-node {
    background: var(--bg-card) !important;
    border: 1px solid var(--border) !important;
    border-radius: 10px !important;
    min-width: 240px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.drawflow .drawflow-node.selected {
    border-color: var(--primary) !important;
    box-shadow: 0 0 0 2px rgba(37, 211, 102, 0.2);
}

/* Node headers by type */
.df-node-header {
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    border-radius: 9px 9px 0 0;
    color: #fff;
}

.df-node-header.type-start {
    background: linear-gradient(135deg, #25D366, #128C7E);
}

.df-node-header.type-text {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
}

.df-node-header.type-menu {
    background: linear-gradient(135deg, #8b5cf6, #7c3aed);
}

.df-node-header.type-question {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
}

.df-node-header.type-transfer {
    background: linear-gradient(135deg, #f97316, #ea580c);
}

.df-node-header.type-close {
    background: linear-gradient(135deg, #ef4444, #dc2626);
}

.df-node-header.type-delay {
    background: linear-gradient(135deg, #6b7280, #4b5563);
}

.df-node-header.type-ai_response {
    background: linear-gradient(135deg, #a855f7, #9333ea);
}

.df-node-header.type-fallback {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.df-node-header.type-tag {
    background: linear-gradient(135deg, #25D366, #10b981);
}

/* Loading spinner animation */
@keyframes spin {
    from {
        transform: rotate(0deg);
    }

    to {
        transform: rotate(360deg);
    }
}

@keyframes slideIn {
    from {
        transform: translateX(100px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Node body */
.df-node-body {
    padding: 10px 12px;
}

.df-node-body .field-group {
    margin-bottom: 6px;
}

.df-node-body label {
    display: block;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 3px;
}

.df-node-body textarea,
.df-node-body input,
.df-node-body select {
    width: 100%;
    padding: 5px 8px;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-primary);
    resize: vertical;
}

/* Menu options */
.df-menu-options {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.df-menu-option {
    display: flex;
    align-items: center;
    gap: 6px;
}

.df-menu-option .option-num {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.df-menu-option input {
    flex: 1;
}

/* Toggle switch (used in bot editor) */
.toggle-switch {
    width: 36px;
    height: 20px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    cursor: pointer;
    transition: background 0.3s;
    position: relative;
}

.toggle-switch.active {
    background: var(--success);
}

.toggle-switch .toggle-knob {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    position: absolute;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
}

.toggle-switch.active .toggle-knob {
    transform: translateX(16px);
}

/* Bot actions dropdown */
.bot-actions-menu {
    position: relative;
}

.bot-actions-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
}

.bot-actions-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.bot-actions-dropdown {
    position: absolute;
    right: 0;
    top: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    min-width: 140px;
    z-index: 10;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.bot-actions-dropdown button {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 13px;
    cursor: pointer;
}

.bot-actions-dropdown button:hover {
    background: rgba(255, 255, 255, 0.05);
}

.bot-actions-dropdown button.danger {
    color: #ef4444;
}

/* Drawflow connection lines */
.drawflow .connection .main-path {
    stroke: var(--primary) !important;
    stroke-width: 2 !important;
}

/* Dept badge */
.dept-badge {
    background: rgba(139, 92, 246, 0.15);
    color: #a78bfa;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
}