:root {
    --whatsapp-teal: #008069;
    --whatsapp-green: #25d366;
    --whatsapp-bg: #efe7de;
    --whatsapp-header: #f0f2f5;
    --whatsapp-bubble-user: #dcf8c6;
    --whatsapp-bubble-bot: #ffffff;
    --primary-color: #00a884;
    --primary-hover: #008f6f;
    --bg-color: #f0f2f5;
    --text-main: #111b21;
    --text-secondary: #667781;
    --text-muted: #8696a0;
    --border-color: #e9edef;
    --error-color: #f15c6d;
    --sidebar-width: 350px;
    --header-height: 60px;
    --footer-height: 62px;
}

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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    overflow: hidden;
}

#app {
    height: 100vh;
    width: 100vw;
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Authentication Styles */
.auth-wrapper {
    height: 100%;
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--whatsapp-teal) 0%, var(--primary-color) 100%);
    z-index: 100;
}

.auth-card {
    background: white;
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.1);
    width: 100%;
    max-width: 450px;
    text-align: center;
}

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

.bot-icon {
    font-size: 3.5rem;
    color: var(--whatsapp-teal);
    margin-bottom: 1rem;
}

.auth-header h1 {
    font-size: 1.8rem;
    margin-bottom: 0.5rem;
}

.auth-header p {
    color: var(--text-secondary);
}

.input-group {
    position: relative;
    margin-bottom: 1.5rem;
}

.input-group i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.input-group input {
    width: 100%;
    padding: 1rem 1rem 1rem 3rem;
    border: 1.5px solid var(--border-color);
    border-radius: 12px;
    font-size: 1rem;
    transition: all 0.3s;
}

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

.btn-primary {
    width: 100%;
    padding: 1rem;
    border: none;
    border-radius: 12px;
    background-color: var(--primary-color);
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

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

.auth-footer {
    margin-top: 2rem;
    font-size: 0.95rem;
}

.auth-footer a {
    color: var(--whatsapp-teal);
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
}

.auth-footer a:hover {
    text-decoration: underline;
}

.error-msg {
    color: var(--error-color);
    margin-top: 1rem;
}

/* Main Layout Styles */
.main-layout {
    display: flex;
    height: 100%;
    width: 100%;
    max-width: 1600px;
    background: white;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
}

/* Sidebar Styles */
.sidebar {
    width: var(--sidebar-width);
    height: 100%;
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    background: white;
    transition: transform 0.3s ease;
}

.sidebar-header {
    height: var(--header-height);
    padding: 0 1rem;
    background: var(--whatsapp-header);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

#logout-button {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    transition: all 0.3s;
}

#logout-button:hover {
    color: var(--error-color);
    background: rgba(241, 92, 109, 0.1);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.avatar {
    width: 40px;
    height: 40px;
    background: var(--whatsapp-teal);
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
}

.sidebar-content {
    flex: 1;
    padding: 1rem;
    overflow-y: auto;
}

.search-box-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.search-box-wrapper .input-group {
    margin-bottom: 0;
}

.btn-primary-sm {
    padding: 0.6rem;
    border: none;
    border-radius: 10px;
    background-color: var(--primary-color);
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}

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

.btn-icon {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    transition: color 0.3s;
}

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

.btn-secondary {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--primary-color);
    background: white;
    color: var(--primary-color);
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s;
}

.btn-secondary:hover {
    background: var(--bg-color);
}

.conv-history-label {
    font-size: 0.85rem;
    color: var(--primary-color);
    text-transform: uppercase;
    font-weight: 600;
    margin-bottom: 1rem;
}

.active-conv-info {
    padding: 1rem;
    background: var(--bg-color);
    border-radius: 12px;
    font-family: monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
    word-break: break-all;
    border-left: 4px solid var(--primary-color);
}

.conversation-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.conv-item {
    padding: 0.8rem 1rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 10px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.conv-item i {
    color: var(--text-muted);
}

.conv-item:hover {
    background: var(--whatsapp-header);
    border-color: var(--primary-color);
}

.conv-item.active {
    background: var(--whatsapp-header);
    border-color: var(--primary-color);
    font-weight: 600;
}

.btn-logout {
    width: 100%;
    padding: 0.8rem;
    border: 1px solid var(--error-color);
    background: transparent;
    color: var(--error-color);
    border-radius: 12px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.3s;
}

.btn-logout:hover {
    background: rgba(241, 92, 109, 0.1);
}

.sidebar-footer {
    padding: 1.5rem 1rem;
    text-align: center;
    border-top: 1px solid var(--border-color);
}

.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: var(--text-secondary);
    padding: 2rem;
}

.welcome-screen i {
    font-size: 4rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    opacity: 0.5;
}

.welcome-screen h2 {
    margin-bottom: 0.5rem;
    color: var(--text-main);
}

.welcome-screen p {
    font-size: 1rem;
    max-width: 300px;
}

/* Chat Area Styles */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--whatsapp-bg);
    background-image: url('https://user-images.githubusercontent.com/15075759/28719144-86dc0f70-73b1-11e7-911d-60d70fcded21.png');
    background-blend-mode: overlay;
    position: relative;
}

.chat-header {
    height: var(--header-height);
    padding: 0 1.5rem;
    background: var(--whatsapp-header);
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}

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

.chat-avatar {
    width: 45px;
    height: 45px;
    background: var(--text-muted);
    color: white;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
}

.chat-meta h3 {
    font-size: 1.1rem;
    font-weight: 600;
}

.chat-meta .status {
    font-size: 0.85rem;
    color: var(--primary-color);
}

.messages-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 2rem 10%;
    display: flex;
    flex-direction: column;
}

#messages {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

#messages li {
    max-width: 65%;
    padding: 0.6rem 1rem;
    border-radius: 10px;
    position: relative;
    font-size: 0.95rem;
    line-height: 1.4;
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

#messages li.user {
    align-self: flex-end;
    background: var(--whatsapp-bubble-user);
    border-top-right-radius: 0;
}

#messages li.bot {
    align-self: flex-start;
    background: var(--whatsapp-bubble-bot);
    border-top-left-radius: 0;
}

#messages li .msg-time {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-align: right;
    margin-top: 0.2rem;
}

.chat-footer {
    height: var(--footer-height);
    background: var(--whatsapp-header);
    padding: 0.5rem 1.5rem;
    display: flex;
    align-items: center;
    z-index: 10;
}

#chat-form {
    display: flex;
    width: 100%;
    gap: 0.8rem;
    align-items: center;
}

.btn-extra {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
}

#chat-input {
    flex: 1;
    border: none;
    border-radius: 10px;
    padding: 0.8rem 1.2rem;
    font-size: 1rem;
    background: white;
}

#chat-input:focus {
    outline: none;
}

.btn-send {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    transition: color 0.3s;
}

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

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Responsive Styles */
.mobile-only {
    display: none;
}

@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: -100%;
        top: 0;
        z-index: 1000;
        height: 100%;
        transition: left 0.3s ease;
    }
    
    .sidebar.open {
        left: 0;
        width: 80%;
    }
    
    .mobile-only {
        display: block;
        background: none;
        border: none;
        font-size: 1.5rem;
        margin-right: 1rem;
        color: var(--text-secondary);
    }
    
    .messages-wrapper {
        padding: 1rem 5%;
    }
    
    #messages li {
        max-width: 85%;
    }
}
