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

:root {
    --primary: #25D366;
    --primary-dark: #128C7E;
    --secondary: #34B7F1;
    --sidebar-bg: #102033;
    --sidebar-hover: #1c314a;
    --sidebar-border: rgba(255,255,255,0.08);
    --text-light: #94a3b8;
    --panel-bg: #f4f7fb;
    --surface: #ffffff;
    --surface-soft: #eef4f8;
    --text-dark: #162033;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(180deg, #edf3f8 0%, #f7f9fc 100%);
    color: #333;
}

.login-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
}

.login-box {
    background: white;
    padding: 50px;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    width: 100%;
    max-width: 420px;
}

.login-box h1 {
    text-align: center;
    margin-bottom: 10px;
    color: var(--primary);
    font-size: 32px;
}

.login-box p {
    text-align: center;
    color: #666;
    margin-bottom: 30px;
}

.form-group {
    margin-bottom: 25px;
}

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

.form-group input {
    width: 100%;
    padding: 14px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.3s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.1);
}

.btn-primary {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
}

.btn-primary:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4);
}

.btn-primary:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    padding: 10px 20px;
    background: var(--secondary);
    color: white;
    text-decoration: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s;
    display: inline-block;
}

.btn-secondary:hover {
    background: #2a9fd8;
    transform: translateY(-2px);
}

.error {
    background: #fee2e2;
    color: #991b1b;
    padding: 14px;
    border-radius: 8px;
    margin-bottom: 20px;
    border-left: 4px solid #dc2626;
}

.dashboard {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 220px;
    background: linear-gradient(180deg, #102033 0%, #162942 100%);
    color: white;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 1000;
    padding: 14px;
}

.sidebar-header {
    padding: 18px 16px 20px;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-header h1 {
    font-size: 18px;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.2;
}

.sidebar-header h1::before {
    content: "💬";
    font-size: 22px;
}

.sidebar-menu {
    flex: 1;
    padding: 18px 0;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    color: var(--text-light);
    text-decoration: none;
    transition: all 0.3s;
    font-size: 14px;
    font-weight: 600;
    border-left: 3px solid transparent;
    border-radius: 12px;
    margin-bottom: 6px;
}

.menu-item:hover {
    background: var(--sidebar-hover);
    color: white;
    border-left-color: var(--primary);
}

.menu-item.active {
    background: var(--sidebar-hover);
    color: white;
    border-left-color: var(--primary);
}

.menu-item-icon {
    font-size: 18px;
    width: 22px;
    text-align: center;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--sidebar-border);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: rgba(255,255,255,0.06);
    border: 1px solid rgba(255,255,255,0.05);
    border-radius: 14px;
    margin-bottom: 10px;
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary) 0%, #72f0a4 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 600;
    color: #0f172a;
}

.user-details {
    flex: 1;
}

.user-name {
    font-weight: 600;
    font-size: 13px;
    color: white;
}

.user-role {
    font-size: 11px;
    color: var(--text-light);
}

.btn-logout {
    width: 100%;
    padding: 10px 12px;
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 12px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    text-align: center;
    text-decoration: none;
    display: block;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.2);
}

.main-content {
    flex: 1;
    margin-left: 220px;
    background: transparent;
}

.topbar {
    background: rgba(255,255,255,0.85);
    backdrop-filter: blur(14px);
    padding: 18px 28px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(148, 163, 184, 0.18);
}

.topbar-title-group {
    display: flex;
    align-items: center;
    gap: 14px;
}

.topbar h2 {
    font-size: 22px;
    color: var(--text-dark);
}

.topbar-actions {
    display: flex;
    gap: 15px;
    align-items: center;
}

.menu-toggle {
    display: none;
    width: 42px;
    height: 42px;
    border: 1px solid rgba(148, 163, 184, 0.25);
    border-radius: 12px;
    background: rgba(255,255,255,0.92);
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
    cursor: pointer;
}

.menu-toggle span {
    width: 18px;
    height: 2px;
    border-radius: 999px;
    background: #334155;
    display: block;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.25s ease, visibility 0.25s ease;
    z-index: 999;
}

.content {
    padding: 20px;
}

.dashboard-hero {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    margin-bottom: 20px;
    padding: 16px 20px;
    border-radius: 12px;
    background: linear-gradient(135deg, #16324d 0%, #1c7c63 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(22, 50, 77, 0.15);
}

.eyebrow {
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.7;
    margin-bottom: 4px;
}

.dashboard-hero h1 {
    font-size: 20px;
    margin-bottom: 6px;
}

.hero-text {
    max-width: 500px;
    line-height: 1.4;
    color: rgba(255,255,255,0.8);
    font-size: 13px;
}

.hero-highlight {
    min-width: 220px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 12px 16px;
    border-radius: 10px;
    background: rgba(255,255,255,0.12);
    border: 1px solid rgba(255,255,255,0.16);
}

.hero-highlight-label {
    font-size: 10px;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    opacity: 0.7;
    margin-bottom: 4px;
}

.hero-highlight strong {
    font-size: 16px;
    margin-bottom: 4px;
}

.hero-highlight small {
    color: rgba(255,255,255,0.7);
    line-height: 1.3;
    font-size: 12px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    background: rgba(255,255,255,0.96);
    padding: 14px 16px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.06);
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.3s;
    border: 1px solid rgba(148, 163, 184, 0.12);
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.08);
}

.stat-icon {
    width: 46px;
    height: 46px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}

.stat-icon.green {
    background: rgba(37, 211, 102, 0.1);
}

.stat-icon.blue {
    background: rgba(52, 183, 241, 0.1);
}

.stat-icon.purple {
    background: rgba(139, 92, 246, 0.1);
}

.stat-icon.orange {
    background: rgba(251, 146, 60, 0.1);
}

.stat-info h3 {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 4px;
    line-height: 1.2;
}

.stat-info p {
    color: #64748b;
    font-size: 13px;
}

.card {
    background: rgba(255,255,255,0.98);
    padding: 22px;
    border-radius: 20px;
    box-shadow: 0 14px 36px rgba(15, 23, 42, 0.06);
    margin-bottom: 20px;
    border: 1px solid rgba(148, 163, 184, 0.12);
}

.card h2 {
    margin-bottom: 18px;
    color: var(--text-dark);
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card h2::before {
    content: "";
    width: 4px;
    height: 24px;
    background: var(--primary);
    border-radius: 2px;
}

#status-container {
    margin: 16px 0 18px;
}

.status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border-radius: 10px;
    font-weight: 600;
    margin-bottom: 12px;
    font-size: 14px;
}

.status::before {
    content: "";
    width: 10px;
    height: 10px;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

.status.connected {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
    border: 2px solid rgba(34, 197, 94, 0.3);
}

.status.connected::before {
    background: #16a34a;
}

.status.disconnected {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 2px solid rgba(239, 68, 68, 0.3);
}

.status.disconnected::before {
    background: #dc2626;
}

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

#qrcode-container {
    margin-top: 22px;
    text-align: center;
    padding: 22px;
    background: var(--surface-soft);
    border-radius: 18px;
    border: 2px dashed #cbd5e1;
}

#qrcode-container h3 {
    margin-bottom: 16px;
    color: var(--text-dark);
}

#qrcode {
    max-width: 240px;
    border: 4px solid white;
    border-radius: 15px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    padding: 12px;
    background: white;
}

#qrcode-container p {
    margin-top: 15px;
    color: #64748b;
}

.messages-container {
    margin-top: 20px;
    overflow-x: auto;
}

.messages-table {
    width: 100%;
    border-collapse: collapse;
}

.messages-table th,
.messages-table td {
    padding: 15px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
}

.messages-table th {
    background: #f8fafc;
    font-weight: 600;
    color: #475569;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.messages-table tr {
    transition: background 0.2s;
}

.messages-table tr:hover {
    background: #f8fafc;
}

.messages-table tr.sent {
    background: rgba(37, 211, 102, 0.05);
}

.messages-table tr.received {
    background: rgba(52, 183, 241, 0.05);
}

.message-body {
    max-width: 400px;
    word-wrap: break-word;
    color: #334155;
}

.no-messages {
    text-align: center;
    color: #94a3b8;
    padding: 60px;
    font-size: 16px;
}

.badge {
    display: inline-block;
    padding: 6px 12px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.dashboard-panels {
    display: grid;
    grid-template-columns: minmax(0, 1.7fr) minmax(240px, 0.9fr);
    gap: 18px;
    align-items: start;
}

.card-connection {
    min-height: 100%;
}

.connection-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.connection-actions .btn-primary,
.connection-actions .btn-danger {
    width: auto;
    min-width: 220px;
}

.quick-panel {
    background: linear-gradient(180deg, #f9fbfd 0%, #eef5f8 100%);
}

.quick-list {
    display: grid;
    gap: 12px;
}

.quick-item {
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(255,255,255,0.92);
    border: 1px solid rgba(148, 163, 184, 0.14);
}

.quick-label {
    display: block;
    font-size: 12px;
    color: #64748b;
    margin-bottom: 6px;
}

.quick-item strong {
    color: var(--text-dark);
    font-size: 18px;
}

.bot-last-message {
    margin-top: 18px;
    padding: 14px 16px;
    border-radius: 16px;
    background: rgba(15, 23, 42, 0.03);
    border: 1px solid rgba(148, 163, 184, 0.14);
}

.bot-last-message strong {
    display: block;
    margin-top: 8px;
    color: var(--text-dark);
    font-size: 14px;
    line-height: 1.5;
    word-break: break-word;
}

.badge.success {
    background: rgba(34, 197, 94, 0.1);
    color: #16a34a;
}

.badge.info {
    background: rgba(52, 183, 241, 0.1);
    color: #0284c7;
}

.badge.warning {
    background: rgba(251, 146, 60, 0.16);
    color: #c2410c;
}

.table-subtext {
    margin-top: 4px;
    color: #64748b;
    font-size: 12px;
}

.chamados-table td strong {
    color: var(--text-dark);
}

.btn-danger {
    padding: 14px 18px;
    background: rgba(220, 38, 38, 0.1);
    color: #b91c1c;
    border: 1px solid rgba(220, 38, 38, 0.24);
    border-radius: 12px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.btn-danger:hover {
    background: rgba(220, 38, 38, 0.16);
}

.btn-danger:disabled {
    opacity: 0.7;
    cursor: wait;
}

.settings-hero {
    margin-bottom: 24px;
}

.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 18px;
    align-items: start;
}

.settings-card {
    display: grid;
    gap: 18px;
}

.settings-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 18px;
}

.settings-helper {
    color: #64748b;
    max-width: 760px;
    line-height: 1.5;
}

.settings-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.settings-save-btn {
    width: auto;
    min-width: 190px;
}

.settings-label {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-dark);
}

.settings-status {
    padding: 14px 16px;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid transparent;
}

.settings-status.success {
    background: rgba(34, 197, 94, 0.12);
    color: #15803d;
    border-color: rgba(34, 197, 94, 0.25);
}

.settings-status.error {
    background: rgba(239, 68, 68, 0.12);
    color: #b91c1c;
    border-color: rgba(239, 68, 68, 0.25);
    white-space: pre-wrap;
}

.settings-status.info {
    background: rgba(52, 183, 241, 0.12);
    color: #0369a1;
    border-color: rgba(52, 183, 241, 0.25);
}

.code-editor {
    width: 100%;
    min-height: 68vh;
    resize: vertical;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.22);
    background: #0f172a;
    color: #e2e8f0;
    padding: 18px;
    font: 14px/1.6 'Consolas', 'Courier New', monospace;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.04);
}

.code-editor:focus {
    outline: 2px solid rgba(37, 211, 102, 0.2);
    border-color: rgba(37, 211, 102, 0.55);
}

.code-editor-small {
    min-height: 48vh;
}

@media (max-width: 900px) {
    .menu-toggle {
        display: inline-flex;
    }

    .sidebar {
        width: min(84vw, 290px);
        transform: translateX(-110%);
        transition: transform 0.28s ease;
        box-shadow: 0 20px 50px rgba(15, 23, 42, 0.24);
    }

    .main-content {
        margin-left: 0;
    }

    body.sidebar-open .sidebar {
        transform: translateX(0);
    }

    body.sidebar-open .sidebar-overlay {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .topbar,
    .content {
        padding: 18px;
    }

    .topbar {
        position: sticky;
        top: 0;
        z-index: 900;
    }

    .topbar-actions {
        gap: 10px;
    }

    .dashboard-hero,
    .dashboard-panels {
        grid-template-columns: 1fr;
        display: grid;
    }

    .dashboard-hero {
        padding: 20px;
    }

    .dashboard-hero h1 {
        font-size: 22px;
    }

    .hero-highlight {
        min-width: 0;
    }

    .connection-actions .btn-primary,
    .connection-actions .btn-danger {
        width: 100%;
        min-width: 0;
    }

    .settings-toolbar {
        flex-direction: column;
    }

    .settings-grid {
        grid-template-columns: 1fr;
    }

    .settings-actions {
        width: 100%;
    }

    .settings-actions .btn-primary,
    .settings-actions .btn-secondary {
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 768px) {
    .topbar {
        align-items: flex-start;
        flex-direction: column;
        gap: 12px;
    }

    .topbar-title-group,
    .topbar-actions {
        width: 100%;
    }

    .topbar-actions {
        justify-content: flex-start;
        flex-wrap: wrap;
    }

    .content {
        padding: 16px;
    }

    .dashboard-hero {
        gap: 16px;
        padding: 18px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .messages-table {
        min-width: 680px;
    }

    .card {
        padding: 18px;
    }

    #qrcode {
        max-width: 100%;
    }

    .code-editor {
        min-height: 56vh;
        padding: 14px;
        font-size: 13px;
    }
}
