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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
}

.logo i {
    font-size: 2rem;
    color: #25D366;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
    color: white;
}

.user-details {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.phone-number {
    font-size: 0.875rem;
    opacity: 0.8;
}

.btn-logout {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

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

/* Main Content */
.main {
    padding: 2rem 0;
}

/* QR Code Section */
.qr-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 200px);
}

.qr-container {
    background: white;
    border-radius: 20px;
    padding: 3rem;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    text-align: center;
    max-width: 500px;
    width: 100%;
}

.qr-header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    color: #333;
    font-weight: 600;
}

.qr-header p {
    color: #666;
    margin-bottom: 2rem;
    font-size: 1rem;
}

.qr-code-wrapper {
    margin-bottom: 2rem;
}

.qr-loader {
    padding: 3rem 0;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #25D366;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

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

    100% {
        transform: rotate(360deg);
    }
}

.qr-code-container {
    padding: 1rem;
}

.qr-code-container img {
    max-width: 280px;
    width: 100%;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
}

.qr-refresh {
    margin-top: 1rem;
}

.btn-refresh {
    background: #25D366;
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.btn-refresh:hover {
    background: #20b858;
    transform: translateY(-2px);
}

/* Loading Info */
.loading-info {
    margin-bottom: 1rem;
}

.loading-bar {
    background: #f0f0f0;
    border-radius: 10px;
    height: 8px;
    margin-bottom: 0.5rem;
    overflow: hidden;
}

.loading-progress {
    background: linear-gradient(90deg, #25D366, #20b858);
    height: 100%;
    border-radius: 10px;
    transition: width 0.3s ease;
    width: 0%;
}

/* Connection Status */
.connection-status {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border-radius: 8px;
    background: #f8f9fa;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #dc3545;
    animation: pulse 2s infinite;
}

.status-indicator.connected {
    background: #25D366;
}

.status-indicator.connecting {
    background: #ffc107;
}

@keyframes pulse {
    0% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }

    100% {
        opacity: 1;
    }
}

/* Chat Interface */
.chat-interface {
    background: white;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    height: calc(100vh - 160px);
}

.chat-layout {
    display: flex;
    height: 100%;
}

/* Sidebar */
.sidebar {
    width: 350px;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
}

.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #333;
}

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

.btn-icon {
    background: none;
    border: none;
    padding: 0.5rem;
    border-radius: 6px;
    cursor: pointer;
    color: #666;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: #e9ecef;
    color: #333;
}

.search-bar {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    position: relative;
}

.search-bar i {
    position: absolute;
    left: 2rem;
    top: 50%;
    transform: translateY(-50%);
    color: #666;
}

.search-bar input {
    width: 100%;
    padding: 0.75rem 0.75rem 0.75rem 2.5rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 0.875rem;
    background: white;
}

.search-bar input:focus {
    outline: none;
    border-color: #25D366;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}

.no-chats {
    padding: 3rem 1.5rem;
    text-align: center;
    color: #666;
}

.no-chats i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.chat-item {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #f0f0f0;
    cursor: pointer;
    transition: background-color 0.3s ease;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.chat-item:hover {
    background: #e9ecef;
}

.chat-item.active {
    background: #25D366;
    color: white;
}

.chat-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #25D366;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.chat-item.active .chat-avatar {
    background: rgba(255, 255, 255, 0.2);
}

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

.chat-name {
    font-weight: 500;
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-last-message {
    font-size: 0.875rem;
    opacity: 0.7;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-meta {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.25rem;
}

.chat-time {
    font-size: 0.75rem;
    opacity: 0.7;
}

.chat-unread {
    background: #25D366;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 500;
}

.chat-item.active .chat-unread {
    background: rgba(255, 255, 255, 0.9);
    color: #25D366;
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

.chat-placeholder {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.placeholder-content {
    text-align: center;
    color: #666;
}

.placeholder-content i {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.3;
}

.placeholder-content h3 {
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.chat-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8f9fa;
}

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

.chat-header .chat-avatar {
    width: 45px;
    height: 45px;
    font-size: 1.125rem;
}

.chat-details h3 {
    font-size: 1.125rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.chat-details p {
    font-size: 0.875rem;
    color: #666;
}

.messages-area {
    flex: 1;
    overflow-y: auto;
    background: #f0f2f5;
}

.messages-container {
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.message {
    max-width: 70%;
    padding: 0.75rem 1rem;
    border-radius: 18px;
    word-wrap: break-word;
    position: relative;
}

.message.sent {
    align-self: flex-end;
    background: #25D366;
    color: white;
    border-bottom-right-radius: 4px;
}

.message.received {
    align-self: flex-start;
    background: white;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.message-content {
    margin-bottom: 0.25rem;
}

.message-media {
    margin-bottom: 0.5rem;
    border-radius: 8px;
    overflow: hidden;
}

.message-media img {
    max-width: 100%;
    height: auto;
    display: block;
}

.message-time {
    font-size: 0.75rem;
    opacity: 0.7;
    text-align: right;
}

.message.sent .message-time {
    color: rgba(255, 255, 255, 0.8);
}

.message-input-area {
    padding: 1rem 1.5rem;
    border-top: 1px solid #e0e0e0;
    background: #f8f9fa;
}

.message-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 0.75rem;
    background: white;
    border-radius: 24px;
    padding: 0.5rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.input-container {
    flex: 1;
}

.input-container textarea {
    width: 100%;
    border: none;
    outline: none;
    resize: none;
    font-family: inherit;
    font-size: 0.9rem;
    padding: 0.75rem 1rem;
    border-radius: 18px;
    background: transparent;
    max-height: 120px;
    line-height: 1.4;
}

.btn-send {
    background: #25D366;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.btn-send:hover {
    background: #20b858;
    transform: scale(1.05);
}

.btn-send:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    padding: 0.5rem;
    border-radius: 6px;
    transition: background-color 0.3s ease;
}

.btn-close:hover {
    background: #f0f0f0;
}

.modal-body {
    padding: 1.5rem;
}

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

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #333;
}

.input-group input,
.input-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.9rem;
}

.input-group input:focus,
.input-group textarea:focus {
    outline: none;
    border-color: #25D366;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid #e0e0e0;
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
}

.btn-primary,
.btn-secondary {
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
}

.btn-primary {
    background: #25D366;
    color: white;
}

.btn-primary:hover {
    background: #20b858;
}

.btn-secondary {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #ddd;
}

.btn-secondary:hover {
    background: #e9ecef;
}

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

.toast {
    background: white;
    border-radius: 8px;
    padding: 1rem 1.5rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border-left: 4px solid #25D366;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 300px;
    animation: slideIn 0.3s ease;
}

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

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

.toast-icon {
    font-size: 1.25rem;
}

.toast.success .toast-icon {
    color: #25D366;
}

.toast.error .toast-icon {
    color: #dc3545;
}

.toast.warning .toast-icon {
    color: #ffc107;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 10px;
    }

    .header-content {
        flex-direction: column;
        gap: 1rem;
    }

    .qr-container {
        padding: 2rem 1.5rem;
        margin: 0 10px;
    }

    .chat-interface {
        height: calc(100vh - 100px);
    }

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

    .chat-layout {
        flex-direction: column;
    }

    .sidebar {
        height: 40%;
        border-right: none;
        border-bottom: 1px solid #e0e0e0;
    }

    .chat-area {
        height: 60%;
    }

    .message {
        max-width: 85%;
    }
}

@media (max-width: 480px) {
    .qr-header h1 {
        font-size: 1.5rem;
    }

    .qr-container {
        padding: 1.5rem 1rem;
    }

    .modal-content {
        width: 95%;
        margin: 10px;
    }

    .sidebar-header {
        padding: 1rem;
    }

    .search-bar {
        padding: 0.75rem 1rem;
    }

    .chat-item {
        padding: 0.75rem 1rem;
    }

    .message-input-wrapper {
        padding: 0.25rem;
    }
}