/* CSS Reset & Variables */
:root {
    --primary-color: #008069;
    --primary-dark: #006653;
    --primary-light: #d9fdd3;
    --incoming-bubble: #ffffff;
    --chat-bg: #efeae2;
    --border-color: #e9edef;
    --header-bg: #f0f2f5;
    --text-primary: #111b21;
    --text-secondary: #667781;
    --bg-main: #eae6df;
    --error-color: #ea0038;
    --success-color: #25d366;
    --shadow-sm: 0 1px 3px rgba(11,20,26,.08);
    --shadow-md: 0 4px 20px rgba(0,0,0,.08);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

html, body {
    height: 100%;
    background-color: var(--bg-main);
    overflow: hidden;
}

/* App Container */
.app-container {
    display: flex;
    width: 100vw;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

/* 3-Column Layout Workspace */
.main-workspace {
    display: flex;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Left Pane (Chats List) */
.left-pane {
    width: 30%;
    min-width: 340px;
    max-width: 420px;
    height: 100%;
    background: #ffffff;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
}

.pane-header {
    height: 60px;
    background-color: var(--header-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
}

.user-profile {
    position: relative;
    width: 40px;
    height: 40px;
}

.user-profile img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
}

.user-status-dot {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid var(--header-bg);
    background-color: #8696a0;
}

.user-status-dot.connected {
    background-color: var(--success-color);
    box-shadow: 0 0 8px var(--success-color);
}

.header-actions {
    display: flex;
    gap: 16px;
}

.header-actions button {
    background: none;
    border: none;
    font-size: 20px;
    color: #54656f;
    cursor: pointer;
    transition: color 0.2s;
}

.header-actions button:hover {
    color: var(--text-primary);
}

/* Search Bar */
.search-container {
    padding: 8px 12px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: #ffffff;
    border-bottom: 1px solid var(--border-color);
}

.search-wrapper {
    position: relative;
    flex: 1;
}

.search-icon {
    position: absolute;
    left: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
    font-size: 14px;
}

.search-wrapper input {
    width: 100%;
    padding: 7px 12px 7px 42px;
    border-radius: 8px;
    background-color: var(--header-bg);
    border: none;
    font-size: 14px;
    outline: none;
    color: var(--text-primary);
}

.search-wrapper input::placeholder {
    color: var(--text-secondary);
}

.filter-btn {
    background: none;
    border: none;
    color: #54656f;
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
}

/* Chat list cards */
.chats-list {
    flex: 1;
    overflow-y: auto;
}

.loading-chats {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 10px;
    padding: 40px;
    color: var(--text-secondary);
    font-size: 14px;
}

.chat-card {
    display: flex;
    gap: 12px;
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.15s;
    align-items: center;
}

.chat-card:hover {
    background-color: var(--header-bg);
}

.chat-card.active {
    background-color: #ebebeb;
}

.chat-card img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
}

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

.chat-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.chat-card-header h4 {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-card-header .time {
    font-size: 12px;
    color: var(--text-secondary);
}

.chat-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-card-footer .snippet {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unread-badge {
    background-color: var(--success-color);
    color: #ffffff;
    font-size: 11px;
    font-weight: 600;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0 4px;
}

/* Center Pane (Chat window) */
.chat-pane {
    flex: 1;
    height: 100%;
    background-color: var(--chat-bg);
    display: flex;
    flex-direction: column;
    position: relative;
}

/* Empty placeholder */
.empty-state {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: #f8f9fa;
    display: none;
    justify-content: center;
    align-items: center;
    border-bottom: 6px solid var(--primary-color);
}

.empty-state.active {
    display: flex;
}

.empty-content {
    text-align: center;
    max-width: 460px;
    padding: 20px;
}

.empty-icon-circle {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: #eef7f4;
    display: flex;
    justify-content: center;
    align-items: center;
    margin: 0 auto 24px;
}

.empty-icon-circle i {
    font-size: 64px;
    color: var(--primary-color);
}

.empty-content h1 {
    font-size: 28px;
    font-weight: 300;
    color: #41525d;
    margin-bottom: 12px;
}

.empty-content p {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.5;
}

.empty-divider {
    height: 1px;
    background-color: var(--border-color);
    margin: 32px 0;
}

.empty-subtext {
    font-size: 12px !important;
}

/* Active chat pane */
.active-chat-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100%;
}

.chat-header {
    height: 60px;
    background-color: var(--header-bg);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
}

.chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    flex: 1;
    min-width: 0;
}

.chat-header-info img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.chat-meta h3 {
    font-size: 15px;
    font-weight: 500;
    color: var(--text-primary);
}

.chat-meta p {
    font-size: 12px;
    color: var(--text-secondary);
}

.chat-header-actions {
    display: flex;
    gap: 20px;
}

.chat-header-actions button {
    background: none;
    border: none;
    color: #54656f;
    font-size: 18px;
    cursor: pointer;
}

/* Messages area */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 20px 40px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    background-repeat: repeat;
}

.msg-bubble {
    max-width: 60%;
    padding: 8px 12px;
    border-radius: 8px;
    font-size: 14.2px;
    line-height: 1.4;
    position: relative;
    word-break: break-word;
    box-shadow: var(--shadow-sm);
    display: flex;
    flex-direction: column;
}

.msg-bubble.sent {
    background-color: var(--primary-light);
    align-self: flex-end;
}

.msg-bubble.received {
    background-color: var(--incoming-bubble);
    align-self: flex-start;
}

.msg-meta-row {
    align-self: flex-end;
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    font-size: 11px;
    color: var(--text-secondary);
}

.msg-meta-row i {
    font-size: 14px;
}

.msg-meta-row i.blue-tick {
    color: #53bdeb;
}

/* Input Footer */
.chat-footer {
    height: 60px;
    background-color: var(--header-bg);
    display: flex;
    align-items: center;
    padding: 10px 16px;
    gap: 12px;
}

.footer-icon-btn {
    background: none;
    border: none;
    color: #54656f;
    font-size: 22px;
    cursor: pointer;
    transition: color 0.2s;
}

.footer-icon-btn:hover {
    color: var(--text-primary);
}

.message-input-form {
    flex: 1;
    display: flex;
    gap: 12px;
}

.message-input-form input {
    flex: 1;
    padding: 10px 18px;
    border-radius: 8px;
    border: none;
    outline: none;
    font-size: 14.5px;
    background-color: #ffffff;
    color: var(--text-primary);
}

.send-btn {
    background: none;
    border: none;
    color: #54656f;
    font-size: 20px;
    cursor: pointer;
}

.send-btn:hover {
    color: var(--primary-color);
}

/* Right Pane: Settings sidebar */
.right-pane {
    width: 28%;
    min-width: 320px;
    max-width: 380px;
    height: 100%;
    background-color: #ffffff;
    border-left: 1px solid var(--border-color);
    display: none;
    flex-direction: column;
    box-shadow: -2px 0 10px rgba(0,0,0,0.03);
}

.right-pane.active {
    display: flex;
}

.right-pane-header {
    height: 60px;
    background-color: var(--header-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
}

.right-pane-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.right-pane-header .close-btn {
    background: none;
    border: none;
    font-size: 18px;
    color: var(--text-secondary);
    cursor: pointer;
}

.right-pane-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* Cards inside settings */
.settings-card {
    background: #f8f9fa;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.card-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-dark);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.session-info-row {
    display: flex;
    justify-content: space-between;
    font-size: 13px;
    color: var(--text-primary);
}

.status-badge {
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    background-color: #e9edef;
    color: var(--text-secondary);
}

.status-badge.connected {
    background-color: #e6f9ed;
    color: var(--success-color);
}

/* Switches styling */
.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: var(--text-primary);
}

.switch {
    position: relative;
    display: inline-block;
    width: 38px;
    height: 20px;
}

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

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: .3s;
}

.slider:before {
    position: absolute;
    content: "";
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
}

input:checked + .slider {
    background-color: var(--primary-color);
}

input:checked + .slider:before {
    transform: translateX(18px);
}

.slider.round {
    border-radius: 20px;
}

.slider.round:before {
    border-radius: 50%;
}

/* Input elements */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.input-group label {
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
}

.input-group textarea, .input-group input {
    width: 100%;
    padding: 8px 12px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    outline: none;
    font-size: 13px;
    resize: none;
    background: #ffffff;
}

.input-group textarea:focus, .input-group input:focus {
    border-color: var(--primary-color);
}

/* Terminal log console */
.log-console {
    background: #1e1e1e;
    color: #e1e1e1;
    font-family: 'Courier New', Courier, monospace;
    font-size: 11px;
    padding: 10px;
    border-radius: 6px;
    max-height: 180px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 4px;
    border: 1px solid #333;
}

.log-line {
    word-break: break-all;
    line-height: 1.3;
}

.log-line.text-muted {
    color: #7f7f7f;
}

/* Login Overlay */
.login-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-main);
    z-index: 100;
    display: none;
    justify-content: center;
    align-items: center;
}

.login-overlay.active {
    display: flex;
}

.login-card {
    background: #ffffff;
    width: 480px;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    padding: 36px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.login-header {
    text-align: center;
}

.wa-business-logo {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    color: var(--primary-color);
    margin-bottom: 16px;
}

.logo-icon {
    font-size: 32px;
}

.logo-text {
    font-size: 22px;
    font-weight: 700;
}

.logo-text .badge {
    font-size: 9px;
    background-color: var(--primary-color);
    color: #ffffff;
    padding: 2px 5px;
    border-radius: 4px;
    vertical-align: middle;
    margin-left: 2px;
}

.login-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}

.login-header p {
    font-size: 13.5px;
    color: var(--text-secondary);
}

.login-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 10px;
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom: 2px solid var(--primary-color);
    margin-bottom: -2px;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

#form-session textarea {
    height: 100px;
    font-family: monospace;
    font-size: 11px;
}

.submit-btn {
    width: 100%;
    padding: 12px;
    background-color: var(--primary-color);
    color: #ffffff;
    font-weight: 600;
    font-size: 14.5px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    transition: background-color 0.2s;
    margin-top: 8px;
}

.submit-btn:hover {
    background-color: var(--primary-dark);
}

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

.helper-text {
    font-size: 11px;
    color: var(--text-secondary);
}

/* Coming Soon display */
.coming-soon-container {
    text-align: center;
    padding: 16px 0;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.coming-soon-badge {
    background-color: #fff8e1;
    color: #b78103;
    font-weight: 600;
    font-size: 12px;
    padding: 4px 10px;
    border-radius: 12px;
    align-self: center;
    display: flex;
    align-items: center;
    gap: 4px;
}

.disabled-group label {
    color: #b5b5b5;
}

.disabled-group input {
    background-color: #f5f5f5;
    border-color: #e5e5e5;
    cursor: not-allowed;
}

.login-footer {
    text-align: center;
    font-size: 11px;
    color: var(--text-secondary);
}

/* Scrollbar tweaks */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-thumb {
    background-color: rgba(11,20,26,.2);
    border-radius: 3px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
