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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

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

header {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

header h1 {
    font-size: 24px;
}

.api-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #ccc;
}

.status-dot.connected {
    background: #4caf50;
}

.status-dot.error {
    background: #f44336;
}

.config-card {
    margin-bottom: 20px;
}

.config-form {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto;
    gap: 16px;
    align-items: end;
}

.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    background: #fff;
    padding: 10px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    overflow-x: auto;
}

.tab-btn {
    padding: 10px 20px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 4px;
    font-size: 14px;
    white-space: nowrap;
}

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

.tab-btn.active {
    background: #2196f3;
    color: white;
}

.tab-content {
    display: none;
}

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

.card {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.card h2 {
    margin-bottom: 20px;
    font-size: 18px;
}

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #2196f3;
}

.form-group small {
    color: #666;
    font-size: 12px;
}

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
}

.btn-primary {
    background: #2196f3;
    color: white;
}

.btn-primary:hover {
    background: #1976d2;
}

.result {
    margin-top: 16px;
    padding: 12px;
    border-radius: 4px;
    display: none;
}

.result.success {
    display: block;
    background: #e8f5e9;
    color: #2e7d32;
    border: 1px solid #4caf50;
}

.result.error {
    display: block;
    background: #ffebee;
    color: #c62828;
    border: 1px solid #f44336;
}

.result.info {
    display: block;
    background: #e3f2fd;
    color: #1565c0;
    border: 1px solid #64b5f6;
}

/* Conversations */
.conversations-layout {
    display: grid;
    grid-template-columns: 300px 1fr;
    gap: 20px;
    height: calc(100vh - 200px);
}

.conversations-list {
    overflow-y: auto;
}

.conversation-item {
    padding: 12px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.conversation-item:hover {
    background: #f5f5f5;
}

.conversation-item.active {
    background: #e3f2fd;
}

.conversation-item .phone {
    font-weight: 500;
}

.conversation-item .preview {
    font-size: 12px;
    color: #666;
    margin-top: 4px;
}

.conversation-item .unread {
    background: #f44336;
    color: white;
    font-size: 11px;
    padding: 2px 6px;
    border-radius: 10px;
}

.chat-area {
    display: flex;
    flex-direction: column;
}

#chat-header {
    padding-bottom: 12px;
    border-bottom: 1px solid #eee;
    margin-bottom: 12px;
}

#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 12px 0;
}

.message {
    margin-bottom: 12px;
    max-width: 70%;
}

.message.sent {
    margin-left: auto;
    text-align: right;
}

.message.received {
    margin-right: auto;
}

.message-content {
    padding: 10px 14px;
    border-radius: 16px;
    display: inline-block;
}

.message.sent .message-content {
    background: #2196f3;
    color: white;
}

.message.received .message-content {
    background: #f0f0f0;
}

.message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

#chat-input-area {
    display: flex;
    gap: 8px;
    padding-top: 12px;
    border-top: 1px solid #eee;
}

#chat-input-area textarea {
    flex: 1;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.stat-card {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    text-align: center;
}

.stat-card h3 {
    font-size: 14px;
    color: #666;
    margin-bottom: 8px;
}

.stat-value {
    font-size: 32px;
    font-weight: 600;
    color: #333;
}

.stat-value.success {
    color: #4caf50;
}

.stat-value.error {
    color: #f44336;
}

.stat-value.warning {
    color: #ff9800;
}

/* Devices */
.device-item {
    padding: 16px;
    border: 1px solid #eee;
    border-radius: 8px;
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.device-info h4 {
    margin-bottom: 4px;
}

.device-info p {
    font-size: 12px;
    color: #666;
}

.device-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.device-status.active {
    background: #e8f5e9;
    color: #2e7d32;
}

.device-status.inactive {
    background: #ffebee;
    color: #c62828;
}

.empty {
    color: #999;
    text-align: center;
    padding: 40px;
}

/* Responsive */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .config-form {
        grid-template-columns: 1fr;
    }

    .conversations-layout {
        grid-template-columns: 1fr;
        height: auto;
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
